custom hand shader
This commit is contained in:
parent
290ada0f0c
commit
041ceea867
2 changed files with 51 additions and 3 deletions
45
Assets/hand.hlsl
Normal file
45
Assets/hand.hlsl
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
#include "stereokit.hlsli"
|
||||||
|
|
||||||
|
//--name = dofdev/hand
|
||||||
|
//--color:color = 1, 1, 1, 1
|
||||||
|
//--tex_scale = 1
|
||||||
|
//--diffuse = white
|
||||||
|
|
||||||
|
float4 color;
|
||||||
|
float tex_scale;
|
||||||
|
Texture2D diffuse : register(t0);
|
||||||
|
SamplerState diffuse_s : register(s0);
|
||||||
|
|
||||||
|
struct vsIn {
|
||||||
|
float4 pos : SV_Position;
|
||||||
|
float3 norm : NORMAL0;
|
||||||
|
float2 uv : TEXCOORD0;
|
||||||
|
float4 col : COLOR0;
|
||||||
|
};
|
||||||
|
struct psIn {
|
||||||
|
float4 pos : SV_POSITION;
|
||||||
|
float2 uv : TEXCOORD0;
|
||||||
|
float4 color : COLOR0;
|
||||||
|
uint view_id : SV_RenderTargetArrayIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
psIn vs(vsIn input, uint id : SV_InstanceID) {
|
||||||
|
psIn o;
|
||||||
|
o.view_id = id % sk_view_count;
|
||||||
|
id = id / sk_view_count;
|
||||||
|
|
||||||
|
float3 world = mul(float4(input.pos.xyz, 1), sk_inst[id].world).xyz;
|
||||||
|
o.pos = mul(float4(world, 1), sk_viewproj[o.view_id]);
|
||||||
|
|
||||||
|
float3 normal = normalize(mul(input.norm, (float3x3)sk_inst[id].world));
|
||||||
|
|
||||||
|
o.uv = input.uv * tex_scale;
|
||||||
|
float3 norm_color = float3(0.5) + (normal * 0.5);
|
||||||
|
float3 norm_shade = float3(0.5) + (norm_color * 0.5);
|
||||||
|
o.color = float4(norm_shade, 1) * input.col; // input.col * color * sk_inst[id].color;
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
float4 ps(psIn input) : SV_TARGET {
|
||||||
|
float4 col = diffuse.Sample(diffuse_s, input.uv);
|
||||||
|
return input.color * col * float4(1, 1, 1, 0.1333);
|
||||||
|
}
|
|
@ -8,6 +8,7 @@ static class Arts
|
||||||
static Model assets_model = Model.FromFile("meshes/assets.glb", Shader.Unlit);
|
static Model assets_model = Model.FromFile("meshes/assets.glb", Shader.Unlit);
|
||||||
static Dictionary<string, Mesh> meshes = new();
|
static Dictionary<string, Mesh> meshes = new();
|
||||||
static Material mat_mono = new Material("mono.hlsl");
|
static Material mat_mono = new Material("mono.hlsl");
|
||||||
|
static Material mat_hand = Default.MaterialHand;
|
||||||
static Material mat_unlit = new Material("unlit.hlsl");
|
static Material mat_unlit = new Material("unlit.hlsl");
|
||||||
static Material mat_both = new Material("unlit.hlsl");
|
static Material mat_both = new Material("unlit.hlsl");
|
||||||
static Material mat_backface = new Material("backface.hlsl");
|
static Material mat_backface = new Material("backface.hlsl");
|
||||||
|
@ -43,13 +44,15 @@ static class Arts
|
||||||
|
|
||||||
// draw ontop of everything
|
// draw ontop of everything
|
||||||
mat_colorcursor.DepthTest = DepthTest.Always;
|
mat_colorcursor.DepthTest = DepthTest.Always;
|
||||||
|
|
||||||
|
mat_hand.Shader = Shader.FromFile("hand.hlsl");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Frame()
|
public static void Frame()
|
||||||
{
|
{
|
||||||
if (SK.GetStepper<PassthroughFBExt>().Enabled) {
|
// if (SK.GetStepper<PassthroughFBExt>().Enabled) {
|
||||||
Input.HandVisible(Handed.Max, false);
|
// Input.HandVisible(Handed.Max, false);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// world
|
// world
|
||||||
// Matrix m4_dof = Mono.dof_pose.ToMatrix(Mono.dof_scl);
|
// Matrix m4_dof = Mono.dof_pose.ToMatrix(Mono.dof_scl);
|
||||||
|
|
Loading…
Add table
Reference in a new issue