OSDN Git Service

スプライトをセル分割して表示できるようにした。
[shooting3/shootinggame.git] / ShootingGame / BasicSprites.GeometryShader.gs.hlsl
index e38ed4a..1d71ee7 100644 (file)
@@ -16,7 +16,8 @@ struct GeometryShaderInput
     float4 origin : TRANSFORM0;
     float2 offset : TRANSFORM1;
     float rotation : TRANSFORM2;
-    float4 color : COLOR0;
+       float4 textureCellInfo : TRANSFORM3;
+       float4 color : COLOR0;
 };
 
 struct PixelShaderInput
@@ -38,10 +39,10 @@ void main(point GeometryShaderInput input[1], inout TriangleStream<PixelShaderIn
     sincos(input[0].rotation, sinRotation, cosRotation);
 
     float2 texCoord[4];
-    texCoord[0] = float2(0,0);
-    texCoord[1] = float2(1,0);
-    texCoord[2] = float2(0,1);
-    texCoord[3] = float2(1,1);
+    texCoord[0] = float2(input[0].textureCellInfo.x                             ,input[0].textureCellInfo.y);
+    texCoord[1] = float2(input[0].textureCellInfo.x + input[0].textureCellInfo.z,input[0].textureCellInfo.y);
+    texCoord[2] = float2(input[0].textureCellInfo.x                             ,input[0].textureCellInfo.y + input[0].textureCellInfo.w);
+    texCoord[3] = float2(input[0].textureCellInfo.x + input[0].textureCellInfo.z,input[0].textureCellInfo.y + input[0].textureCellInfo.w);
 
     float2 posDelta[4];
     posDelta[0] = float2(-input[0].offset.x,  input[0].offset.y);