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 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); } }; };