subtle paper texture for depth sense comfort
This commit is contained in:
parent
8f5ad356fe
commit
76d72afef9
5 changed files with 19 additions and 5 deletions
|
@ -2,16 +2,23 @@
|
||||||
|
|
||||||
//--name = dofdev/backbox
|
//--name = dofdev/backbox
|
||||||
//--color:color = 1, 1, 1, 1
|
//--color:color = 1, 1, 1, 1
|
||||||
|
//--tex_scale = 1
|
||||||
|
//--diffuse = white
|
||||||
|
|
||||||
float4 color;
|
float4 color;
|
||||||
|
float tex_scale;
|
||||||
|
Texture2D diffuse : register(t0);
|
||||||
|
SamplerState diffuse_s : register(s0);
|
||||||
|
|
||||||
struct vsIn {
|
struct vsIn {
|
||||||
float4 pos : SV_Position;
|
float4 pos : SV_Position;
|
||||||
float3 norm : NORMAL0;
|
float3 norm : NORMAL0;
|
||||||
|
float2 uv : TEXCOORD0;
|
||||||
// float4 col : COLOR0;
|
// float4 col : COLOR0;
|
||||||
};
|
};
|
||||||
struct psIn {
|
struct psIn {
|
||||||
float4 pos : SV_POSITION;
|
float4 pos : SV_POSITION;
|
||||||
|
float2 uv : TEXCOORD0;
|
||||||
float4 color : COLOR0;
|
float4 color : COLOR0;
|
||||||
float3 normal : NORMAL0;
|
float3 normal : NORMAL0;
|
||||||
float3 world_pos : WORLD;
|
float3 world_pos : WORLD;
|
||||||
|
@ -35,16 +42,19 @@ psIn vs(vsIn input, uint id : SV_InstanceID) {
|
||||||
// flip input normals to treat backfaces like normal
|
// flip input normals to treat backfaces like normal
|
||||||
o.normal = normalize(mul(-input.norm, (float3x3)sk_inst[id].world));
|
o.normal = normalize(mul(-input.norm, (float3x3)sk_inst[id].world));
|
||||||
|
|
||||||
|
o.uv = input.uv * tex_scale;
|
||||||
o.color = color * sk_inst[id].color;
|
o.color = color * sk_inst[id].color;
|
||||||
|
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
float4 ps(psIn input) : SV_TARGET {
|
float4 ps(psIn input) : SV_TARGET {
|
||||||
|
float4 col = diffuse.Sample(diffuse_s, input.uv);
|
||||||
|
|
||||||
float3 view_dir = normalize(input.world_pos - input.cam_pos);
|
float3 view_dir = normalize(input.world_pos - input.cam_pos);
|
||||||
|
|
||||||
// Fresnel effect calculation
|
// Fresnel effect calculation
|
||||||
float fresnel = 1.0 - saturate(dot(-view_dir, input.normal));
|
float fresnel = 1.0 - saturate(dot(-view_dir, input.normal));
|
||||||
fresnel = pow(fresnel, 5.0); // Adjust power for different falloff rates
|
fresnel = pow(fresnel, 5.0); // Adjust power for different falloff rates
|
||||||
float value = 0.5;
|
float value = 0.5;
|
||||||
return float4(fresnel * input.color.rgb * value, input.color.a);
|
return lerp(col, float4(1), 0.666) * float4(fresnel * input.color.rgb * value, input.color.a);
|
||||||
}
|
}
|
BIN
Assets/meshes/assets.glb
(Stored with Git LFS)
BIN
Assets/meshes/assets.glb
(Stored with Git LFS)
Binary file not shown.
BIN
Assets/paper.jpg
Normal file
BIN
Assets/paper.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 382 KiB |
|
@ -40,7 +40,7 @@ psIn vs(vsIn input, uint id : SV_InstanceID) {
|
||||||
float4 ps(psIn input) : SV_TARGET {
|
float4 ps(psIn input) : SV_TARGET {
|
||||||
float4 col = diffuse.Sample(diffuse_s, input.uv);
|
float4 col = diffuse.Sample(diffuse_s, input.uv);
|
||||||
|
|
||||||
col = col * input.color;
|
col = lerp(col, float4(1), 0.666) * input.color;
|
||||||
|
|
||||||
return col;
|
return col;
|
||||||
}
|
}
|
|
@ -14,6 +14,7 @@ static class Arts
|
||||||
static Material mat_backbox = new Material("backbox.hlsl");
|
static Material mat_backbox = new Material("backbox.hlsl");
|
||||||
static Material mat_justcolor = new Material("justcolor.hlsl");
|
static Material mat_justcolor = new Material("justcolor.hlsl");
|
||||||
|
|
||||||
|
static Tex tex_box = Tex.FromFile("paper.jpg");
|
||||||
static Quat food_ori = Quat.Identity;
|
static Quat food_ori = Quat.Identity;
|
||||||
|
|
||||||
static XYZi last_headpos = new(0, 0, 0);
|
static XYZi last_headpos = new(0, 0, 0);
|
||||||
|
@ -31,6 +32,9 @@ static class Arts
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mat_mono.SetTexture("diffuse", tex_mono);
|
||||||
|
mat_box.SetTexture("diffuse", tex_box);
|
||||||
|
mat_backbox.SetTexture("diffuse", tex_box);
|
||||||
|
|
||||||
mat_backbox.FaceCull = Cull.Front;
|
mat_backbox.FaceCull = Cull.Front;
|
||||||
mat_backbox.Transparency = Transparency.Add;
|
mat_backbox.Transparency = Transparency.Add;
|
||||||
|
|
Loading…
Add table
Reference in a new issue