aboutsummaryrefslogtreecommitdiff
path: root/NvCloth/samples/resources
diff options
context:
space:
mode:
authorMarijn Tamis <[email protected]>2018-05-03 18:22:48 +0200
committerMarijn Tamis <[email protected]>2018-05-03 18:22:48 +0200
commitca32c59a58d37c1822e185a2d5f3d0d3e8943593 (patch)
treeb06b9eec03f34344ef8fc31aa147b2714d3962ee /NvCloth/samples/resources
parentForced rename of platform folders in cmake dir. Git didn't pick this up before. (diff)
downloadnvcloth-ca32c59a58d37c1822e185a2d5f3d0d3e8943593.tar.xz
nvcloth-ca32c59a58d37c1822e185a2d5f3d0d3e8943593.zip
NvCloth 1.1.4 Release. (24070740)
Diffstat (limited to 'NvCloth/samples/resources')
-rw-r--r--NvCloth/samples/resources/shaders/common_buffers.hlsl2
-rw-r--r--NvCloth/samples/resources/shaders/weighted_model_skinned.hlsl109
-rw-r--r--NvCloth/samples/resources/shaders/weighted_model_skinned_textured.hlsl110
3 files changed, 221 insertions, 0 deletions
diff --git a/NvCloth/samples/resources/shaders/common_buffers.hlsl b/NvCloth/samples/resources/shaders/common_buffers.hlsl
index 1aa3386..3011243 100644
--- a/NvCloth/samples/resources/shaders/common_buffers.hlsl
+++ b/NvCloth/samples/resources/shaders/common_buffers.hlsl
@@ -23,6 +23,8 @@ cbuffer Object : register(b2)
{
row_major matrix model;
float4 defaultColor;
+ uint boneoffsetoffset;
+ uint submesh;
};
#endif \ No newline at end of file
diff --git a/NvCloth/samples/resources/shaders/weighted_model_skinned.hlsl b/NvCloth/samples/resources/shaders/weighted_model_skinned.hlsl
new file mode 100644
index 0000000..8cfc7bd
--- /dev/null
+++ b/NvCloth/samples/resources/shaders/weighted_model_skinned.hlsl
@@ -0,0 +1,109 @@
+#include "common_buffers.hlsl"
+#include "lighting.hlsl"
+
+SamplerState defaultSampler : register(s0);
+Texture2D diffuseTexture : register(t0);
+Texture2D bonesTexture : register(t1);
+
+struct VS_INPUT
+{
+ float3 position : POSITION0;
+ float3 normal : NORMAL0;
+ float2 uv : TEXCOORD0;
+ uint4 boneIndices : TEXCOORD1;
+ float4 boneWeights : TEXCOORD2;
+};
+
+struct VS_OUTPUT
+{
+ float4 position : SV_POSITION;
+ float4 worldPos : POSITION0;
+ float2 uv : TEXCOORD0;
+ float3 normal : NORMAL0;
+};
+
+VS_OUTPUT VS(VS_INPUT iV)
+{
+ VS_OUTPUT oV;
+
+ float4x4 boneMatrix0;
+ boneMatrix0[0] = bonesTexture.Load(int3(0, iV.boneIndices.x, 0));
+ boneMatrix0[1] = bonesTexture.Load(int3(1, iV.boneIndices.x, 0));
+ boneMatrix0[2] = bonesTexture.Load(int3(2, iV.boneIndices.x, 0));
+ boneMatrix0[3] = bonesTexture.Load(int3(3, iV.boneIndices.x, 0));
+ float4x4 boneMatrix1;
+ boneMatrix1[0] = bonesTexture.Load(int3(0, iV.boneIndices.y, 0));
+ boneMatrix1[1] = bonesTexture.Load(int3(1, iV.boneIndices.y, 0));
+ boneMatrix1[2] = bonesTexture.Load(int3(2, iV.boneIndices.y, 0));
+ boneMatrix1[3] = bonesTexture.Load(int3(3, iV.boneIndices.y, 0));
+ float4x4 boneMatrix2;
+ boneMatrix2[0] = bonesTexture.Load(int3(0, iV.boneIndices.z, 0));
+ boneMatrix2[1] = bonesTexture.Load(int3(1, iV.boneIndices.z, 0));
+ boneMatrix2[2] = bonesTexture.Load(int3(2, iV.boneIndices.z, 0));
+ boneMatrix2[3] = bonesTexture.Load(int3(3, iV.boneIndices.z, 0));
+ float4x4 boneMatrix3;
+ boneMatrix3[0] = bonesTexture.Load(int3(0, iV.boneIndices.w, 0));
+ boneMatrix3[1] = bonesTexture.Load(int3(1, iV.boneIndices.w, 0));
+ boneMatrix3[2] = bonesTexture.Load(int3(2, iV.boneIndices.w, 0));
+ boneMatrix3[3] = bonesTexture.Load(int3(3, iV.boneIndices.w, 0));
+
+ float4x4 offsetMatrix0;
+ offsetMatrix0[0] = bonesTexture.Load(int3(0, iV.boneIndices.x + boneoffsetoffset, 0));
+ offsetMatrix0[1] = bonesTexture.Load(int3(1, iV.boneIndices.x + boneoffsetoffset, 0));
+ offsetMatrix0[2] = bonesTexture.Load(int3(2, iV.boneIndices.x + boneoffsetoffset, 0));
+ offsetMatrix0[3] = bonesTexture.Load(int3(3, iV.boneIndices.x + boneoffsetoffset, 0));
+ float4x4 offsetMatrix1;
+ offsetMatrix1[0] = bonesTexture.Load(int3(0, iV.boneIndices.y + boneoffsetoffset, 0));
+ offsetMatrix1[1] = bonesTexture.Load(int3(1, iV.boneIndices.y + boneoffsetoffset, 0));
+ offsetMatrix1[2] = bonesTexture.Load(int3(2, iV.boneIndices.y + boneoffsetoffset, 0));
+ offsetMatrix1[3] = bonesTexture.Load(int3(3, iV.boneIndices.y + boneoffsetoffset, 0));
+ float4x4 offsetMatrix2;
+ offsetMatrix2[0] = bonesTexture.Load(int3(0, iV.boneIndices.z + boneoffsetoffset, 0));
+ offsetMatrix2[1] = bonesTexture.Load(int3(1, iV.boneIndices.z + boneoffsetoffset, 0));
+ offsetMatrix2[2] = bonesTexture.Load(int3(2, iV.boneIndices.z + boneoffsetoffset, 0));
+ offsetMatrix2[3] = bonesTexture.Load(int3(3, iV.boneIndices.z + boneoffsetoffset, 0));
+ float4x4 offsetMatrix3;
+ offsetMatrix3[0] = bonesTexture.Load(int3(0, iV.boneIndices.w + boneoffsetoffset, 0));
+ offsetMatrix3[1] = bonesTexture.Load(int3(1, iV.boneIndices.w + boneoffsetoffset, 0));
+ offsetMatrix3[2] = bonesTexture.Load(int3(2, iV.boneIndices.w + boneoffsetoffset, 0));
+ offsetMatrix3[3] = bonesTexture.Load(int3(3, iV.boneIndices.w + boneoffsetoffset, 0));
+
+
+ float3 skinnedPos0 = mul(mul(float4(iV.position, 1.0f), offsetMatrix0), boneMatrix0).xyz;
+ float3 skinnedPos1 = mul(mul(float4(iV.position, 1.0f), offsetMatrix1), boneMatrix1).xyz;
+ float3 skinnedPos2 = mul(mul(float4(iV.position, 1.0f), offsetMatrix2), boneMatrix2).xyz;
+ float3 skinnedPos3 = mul(mul(float4(iV.position, 1.0f), offsetMatrix3), boneMatrix3).xyz;
+ float3 skinnedPos =
+ skinnedPos0 * iV.boneWeights.x +
+ skinnedPos1 * iV.boneWeights.y +
+ skinnedPos2 * iV.boneWeights.z +
+ skinnedPos3 * iV.boneWeights.w;
+
+ float4 worldSpacePos = mul(float4(skinnedPos, 1.0f), model);
+ oV.position = mul(worldSpacePos, viewProjection);
+
+ oV.worldPos = worldSpacePos;
+
+ // normals
+ float3 skinnedNorm0 = mul(mul(float4(iV.normal, 0.0f), offsetMatrix0), boneMatrix0).xyz;
+ float3 skinnedNorm1 = mul(mul(float4(iV.normal, 0.0f), offsetMatrix1), boneMatrix1).xyz;
+ float3 skinnedNorm2 = mul(mul(float4(iV.normal, 0.0f), offsetMatrix2), boneMatrix2).xyz;
+ float3 skinnedNorm3 = mul(mul(float4(iV.normal, 0.0f), offsetMatrix3), boneMatrix3).xyz;
+ float3 localNormal =
+ skinnedNorm0 * iV.boneWeights.x +
+ skinnedNorm1 * iV.boneWeights.y +
+ skinnedNorm2 * iV.boneWeights.z +
+ skinnedNorm3 * iV.boneWeights.w;
+ float3 worldNormal = mul(float4(localNormal, 0.0f), model).xyz;
+ oV.normal = worldNormal;
+
+ oV.uv = iV.uv;
+
+ return oV;
+}
+
+float4 PS(VS_OUTPUT iV) : SV_Target0
+{
+ float3 lightColor = CalcPixelLight(defaultColor.xyz, iV.worldPos.xyz, iV.normal);
+ return float4(lightColor, 1);
+} \ No newline at end of file
diff --git a/NvCloth/samples/resources/shaders/weighted_model_skinned_textured.hlsl b/NvCloth/samples/resources/shaders/weighted_model_skinned_textured.hlsl
new file mode 100644
index 0000000..11a7379
--- /dev/null
+++ b/NvCloth/samples/resources/shaders/weighted_model_skinned_textured.hlsl
@@ -0,0 +1,110 @@
+#include "common_buffers.hlsl"
+#include "lighting.hlsl"
+
+SamplerState defaultSampler : register(s0);
+Texture2D diffuseTexture : register(t0);
+Texture2D bonesTexture : register(t1);
+
+struct VS_INPUT
+{
+ float3 position : POSITION0;
+ float3 normal : NORMAL0;
+ float2 uv : TEXCOORD0;
+ uint4 boneIndices : TEXCOORD1;
+ float4 boneWeights : TEXCOORD2;
+};
+
+struct VS_OUTPUT
+{
+ float4 position : SV_POSITION;
+ float4 worldPos : POSITION0;
+ float2 uv : TEXCOORD0;
+ float3 normal : NORMAL0;
+};
+
+VS_OUTPUT VS(VS_INPUT iV)
+{
+ VS_OUTPUT oV;
+
+ float4x4 boneMatrix0;
+ boneMatrix0[0] = bonesTexture.Load(int3(0, iV.boneIndices.x, 0));
+ boneMatrix0[1] = bonesTexture.Load(int3(1, iV.boneIndices.x, 0));
+ boneMatrix0[2] = bonesTexture.Load(int3(2, iV.boneIndices.x, 0));
+ boneMatrix0[3] = bonesTexture.Load(int3(3, iV.boneIndices.x, 0));
+ float4x4 boneMatrix1;
+ boneMatrix1[0] = bonesTexture.Load(int3(0, iV.boneIndices.y, 0));
+ boneMatrix1[1] = bonesTexture.Load(int3(1, iV.boneIndices.y, 0));
+ boneMatrix1[2] = bonesTexture.Load(int3(2, iV.boneIndices.y, 0));
+ boneMatrix1[3] = bonesTexture.Load(int3(3, iV.boneIndices.y, 0));
+ float4x4 boneMatrix2;
+ boneMatrix2[0] = bonesTexture.Load(int3(0, iV.boneIndices.z, 0));
+ boneMatrix2[1] = bonesTexture.Load(int3(1, iV.boneIndices.z, 0));
+ boneMatrix2[2] = bonesTexture.Load(int3(2, iV.boneIndices.z, 0));
+ boneMatrix2[3] = bonesTexture.Load(int3(3, iV.boneIndices.z, 0));
+ float4x4 boneMatrix3;
+ boneMatrix3[0] = bonesTexture.Load(int3(0, iV.boneIndices.w, 0));
+ boneMatrix3[1] = bonesTexture.Load(int3(1, iV.boneIndices.w, 0));
+ boneMatrix3[2] = bonesTexture.Load(int3(2, iV.boneIndices.w, 0));
+ boneMatrix3[3] = bonesTexture.Load(int3(3, iV.boneIndices.w, 0));
+
+ float4x4 offsetMatrix0;
+ offsetMatrix0[0] = bonesTexture.Load(int3(0, iV.boneIndices.x + boneoffsetoffset, 0));
+ offsetMatrix0[1] = bonesTexture.Load(int3(1, iV.boneIndices.x + boneoffsetoffset, 0));
+ offsetMatrix0[2] = bonesTexture.Load(int3(2, iV.boneIndices.x + boneoffsetoffset, 0));
+ offsetMatrix0[3] = bonesTexture.Load(int3(3, iV.boneIndices.x + boneoffsetoffset, 0));
+ float4x4 offsetMatrix1;
+ offsetMatrix1[0] = bonesTexture.Load(int3(0, iV.boneIndices.y + boneoffsetoffset, 0));
+ offsetMatrix1[1] = bonesTexture.Load(int3(1, iV.boneIndices.y + boneoffsetoffset, 0));
+ offsetMatrix1[2] = bonesTexture.Load(int3(2, iV.boneIndices.y + boneoffsetoffset, 0));
+ offsetMatrix1[3] = bonesTexture.Load(int3(3, iV.boneIndices.y + boneoffsetoffset, 0));
+ float4x4 offsetMatrix2;
+ offsetMatrix2[0] = bonesTexture.Load(int3(0, iV.boneIndices.z + boneoffsetoffset, 0));
+ offsetMatrix2[1] = bonesTexture.Load(int3(1, iV.boneIndices.z + boneoffsetoffset, 0));
+ offsetMatrix2[2] = bonesTexture.Load(int3(2, iV.boneIndices.z + boneoffsetoffset, 0));
+ offsetMatrix2[3] = bonesTexture.Load(int3(3, iV.boneIndices.z + boneoffsetoffset, 0));
+ float4x4 offsetMatrix3;
+ offsetMatrix3[0] = bonesTexture.Load(int3(0, iV.boneIndices.w + boneoffsetoffset, 0));
+ offsetMatrix3[1] = bonesTexture.Load(int3(1, iV.boneIndices.w + boneoffsetoffset, 0));
+ offsetMatrix3[2] = bonesTexture.Load(int3(2, iV.boneIndices.w + boneoffsetoffset, 0));
+ offsetMatrix3[3] = bonesTexture.Load(int3(3, iV.boneIndices.w + boneoffsetoffset, 0));
+
+
+ float3 skinnedPos0 = mul(mul(float4(iV.position, 1.0f), offsetMatrix0), boneMatrix0).xyz;
+ float3 skinnedPos1 = mul(mul(float4(iV.position, 1.0f), offsetMatrix1), boneMatrix1).xyz;
+ float3 skinnedPos2 = mul(mul(float4(iV.position, 1.0f), offsetMatrix2), boneMatrix2).xyz;
+ float3 skinnedPos3 = mul(mul(float4(iV.position, 1.0f), offsetMatrix3), boneMatrix3).xyz;
+ float3 skinnedPos =
+ skinnedPos0 * iV.boneWeights.x +
+ skinnedPos1 * iV.boneWeights.y +
+ skinnedPos2 * iV.boneWeights.z +
+ skinnedPos3 * iV.boneWeights.w;
+
+ float4 worldSpacePos = mul(float4(skinnedPos, 1.0f), model);
+ oV.position = mul(worldSpacePos, viewProjection);
+
+ oV.worldPos = worldSpacePos;
+
+ // normals
+ float3 skinnedNorm0 = mul(mul(float4(iV.normal, 0.0f), offsetMatrix0), boneMatrix0).xyz;
+ float3 skinnedNorm1 = mul(mul(float4(iV.normal, 0.0f), offsetMatrix1), boneMatrix1).xyz;
+ float3 skinnedNorm2 = mul(mul(float4(iV.normal, 0.0f), offsetMatrix2), boneMatrix2).xyz;
+ float3 skinnedNorm3 = mul(mul(float4(iV.normal, 0.0f), offsetMatrix3), boneMatrix3).xyz;
+ float3 localNormal =
+ skinnedNorm0 * iV.boneWeights.x +
+ skinnedNorm1 * iV.boneWeights.y +
+ skinnedNorm2 * iV.boneWeights.z +
+ skinnedNorm3 * iV.boneWeights.w;
+ float3 worldNormal = mul(float4(localNormal, 0.0f), model).xyz;
+ oV.normal = worldNormal;
+
+ oV.uv = iV.uv;
+
+ return oV;
+}
+
+float4 PS(VS_OUTPUT iV): SV_Target0
+{
+ float4 textureColor = diffuseTexture.Sample(defaultSampler, iV.uv);
+ return textureColor;
+ //return float4(CalcPixelLight(textureColor, iV.worldPos, iV.normal), 1);
+} \ No newline at end of file