| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- mixin SelectionBase
- {
- raster
- {
- fill = wire;
- };
-
- depth
- {
- bias = 0.00001f;
- };
-
- blend
- {
- target
- {
- enabled = true;
- color = { srcA, srcIA, add };
- };
- };
-
- code
- {
- cbuffer FragParams
- {
- float4 selColor;
- };
- float4 fsmain(in float4 inPos : SV_Position) : SV_Target
- {
- return selColor;
- }
- };
- };
- mixin
- #ifdef USE_BLEND_SHAPES
- #ifdef USE_SKELETON
- SelectionSkinnedMorph
- #else
- SelectionMorph
- #endif
- #else
- #ifdef USE_SKELETON
- SelectionSkinned
- #else
- Selection
- #endif
- #endif
- {
- mixin SelectionBase;
- code
- {
- struct VertexInput
- {
- float3 position : POSITION;
-
- #ifdef USE_SKELETON
- uint4 blendIndices : BLENDINDICES;
- float4 blendWeights : BLENDWEIGHT;
- #endif
-
- #ifdef USE_BLEND_SHAPES
- float3 deltaPosition : POSITION1;
- float4 deltaNormal : NORMAL1;
- #endif
- };
-
- cbuffer VertParams
- {
- float4x4 matWorldViewProj;
- };
-
- #ifdef USE_SKELETON
- StructuredBuffer<float4> boneMatrices;
-
- float3x4 getBoneMatrix(uint idx)
- {
- float4 row0 = boneMatrices[idx * 3 + 0];
- float4 row1 = boneMatrices[idx * 3 + 1];
- float4 row2 = boneMatrices[idx * 3 + 2];
-
- return float3x4(row0, row1, row2);
- }
-
- float3x4 getBlendMatrix(VertexInput input)
- {
- float3x4 result = input.blendWeights.x * getBoneMatrix(input.blendIndices.x);
- result += input.blendWeights.y * getBoneMatrix(input.blendIndices.y);
- result += input.blendWeights.z * getBoneMatrix(input.blendIndices.z);
- result += input.blendWeights.w * getBoneMatrix(input.blendIndices.w);
-
- return result;
- }
- #endif
-
- void vsmain(VertexInput input, out float4 oPosition : SV_Position)
- {
- #ifdef USE_BLEND_SHAPES
- float4 position = float4(input.position + input.deltaPosition, 1.0f);
- #else
- float4 position = float4(input.position, 1.0f);
- #endif
-
- #ifdef USE_SKELETON
- float3x4 blendMatrix = getBlendMatrix(input);
- position = float4(mul(blendMatrix, position), 1.0f);
- #endif
- oPosition = mul(matWorldViewProj, position);
- }
- };
- };
|