58 lines
1.5 KiB
Plaintext
58 lines
1.5 KiB
Plaintext
|
|
struct VertexOut {
|
|
float4 outPosition : SV_Position;
|
|
float4 screenPosition : ScreenPosition;
|
|
float4 vertexColor : CoarseColor;
|
|
float2 texCoord0 : TexCoord0;
|
|
};
|
|
|
|
struct CameraData {
|
|
float4x4 view;
|
|
float4x4 proj;
|
|
};
|
|
|
|
struct PerFrameData {
|
|
CameraData camera;
|
|
Sampler2D texture;
|
|
}
|
|
|
|
ParameterBlock<PerFrameData> perFrameData;
|
|
|
|
struct PerInstanceData {
|
|
float4x4 transform;
|
|
}
|
|
|
|
[[vk::push_constant]]
|
|
uniform ConstantBuffer<PerInstanceData> pcb;
|
|
|
|
[shader("vertex")]
|
|
VertexOut VertexMain(
|
|
uint vertexId: SV_VertexID,
|
|
float3 position,
|
|
float3 color,
|
|
float2 texCoord0,
|
|
) {
|
|
VertexOut output;
|
|
output.outPosition = mul(perFrameData.camera.proj, mul(perFrameData.camera.view, mul(pcb.transform, float4(position, 1.0f))));
|
|
output.screenPosition = mul(perFrameData.camera.proj, mul(perFrameData.camera.view, mul(pcb.transform, float4(position, 1.0f))));
|
|
output.vertexColor = float4(color, 1.0f);
|
|
output.texCoord0 = texCoord0 * 2.0f;
|
|
return output;
|
|
}
|
|
|
|
[shader("fragment")]
|
|
float4 FragmentMain(
|
|
float4 interpolatePosition : ScreenPosition,
|
|
float4 interpolatedColors : CoarseColor,
|
|
float2 uv0 : TexCoord0,
|
|
) : SV_Target0 {
|
|
float4 outColor;
|
|
if (interpolatePosition.x < 0) {
|
|
outColor = float4(perFrameData.texture.SampleLevel(uv0, 0).rgb, 1.0f) * interpolatedColors;
|
|
} else {
|
|
outColor = float4(perFrameData.texture.Sample(uv0).rgb, 1.0f) * interpolatedColors;
|
|
}
|
|
return outColor;
|
|
}
|
|
|