Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //These HLSL/GLSL pastes is "HLSL" that Diligent Engine "converts" into GLSL (it's actually GLSL with a bunch of defines and includes on top).
- cbuffer Constants
- {
- float4x4 g_WorldViewProj;
- float4x4 g_JointModels[255];
- float4x4 g_LinkMatrix;
- //int boneIndex;
- };
- struct PSInput
- {
- float4 Pos : SV_POSITION;
- float4 Normal : NORMAL0;
- float4 Color : COLOR0;
- float2 Uv : TEXCOORD0;
- };
- // Vertex shader takes two inputs: vertex position and color.
- // By convention, Diligent Engine expects vertex shader inputs to
- // be labeled as ATTRIBn, where n is the attribute number
- PSInput main( float3 pos : ATTRIB0, float3 normal : ATTRIB1,uint color : ATTRIB2,float2 uv : ATTRIB3, //Vertex
- int vertexNumDummy : ATTRIB4, int index0 : ATTRIB5, float boneWeight : ATTRIB6, int index1 : ATTRIB7, float3 weldPos : ATTRIB8, float3 weldNormal : ATTRIB9) //Welding
- {
- /*CONST FLOAT f = 1.0f / 255.0f;
- r = f * (FLOAT)(unsigned char) (dw >> 16);
- g = f * (FLOAT)(unsigned char) (dw >> 8);
- b = f * (FLOAT)(unsigned char) (dw >> 0);
- a = f * (FLOAT)(unsigned char) (dw >> 24);*/
- PSInput ps;
- //TODO: Remove conditional and optimize everything
- if (index0 != -1)
- {
- ps.Pos = mul(mul(float4(pos, 1.0), mul(g_LinkMatrix, g_JointModels[index0])), boneWeight);
- ps.Normal = mul(mul(float4(normal, 1.0), mul(g_LinkMatrix, g_JointModels[index0])), boneWeight);
- ps.Pos += mul(mul(float4(weldPos, 1.0), g_JointModels[index1]), 1.0f - boneWeight);
- //else ps.Pos += mul(mul(float4(pos, 1.0), mul(g_LinkMatrix, g_JointModels[index0])), 1.0f - boneWeight);
- ps.Normal += mul(mul(float4(weldNormal, 1.0), g_JointModels[index1]), 1.0f - boneWeight);
- ps.Pos = mul(ps.Pos, g_WorldViewProj);
- ps.Normal = mul(ps.Normal, g_WorldViewProj);
- /*if (vertexNumDummy == -1)
- {
- ps.Color = float4(1.0, 0.0, 0.0, 1.0);
- }
- else
- {
- ps.Color = float4(boneWeight, boneWeight, boneWeight, 1.0);
- if (index0 == index1)
- {
- ps.Color = float4(0.0, 0.0, 1.0, 1.0);
- }
- }*/
- }
- else
- {
- ps.Pos = mul(float4(pos, 1.0), g_WorldViewProj);
- ps.Normal = mul(float4(normal, 1.0), g_WorldViewProj);
- ps.Color = float4(float3(0.0, 1.0, 0.0), 1.0);
- }
- float a = ((color & 0xff000000) >> 24);
- float r = ((color & 0xff0000) >> 16);
- float g = ((color & 0xff00) >> 8);
- float b = ((color & 0xff));
- /*if(vertexNumDummy == -1) */ps.Color = float4(r, g, b, a) / 255.0;
- //else ps.Color = float4(float3(boneWeight, 0.0, 0.0), 1.0);
- ps.Uv = uv;
- return ps;
- }
Add Comment
Please, Sign In to add comment