53 lines
1.3 KiB
Plaintext
53 lines
1.3 KiB
Plaintext
import Bindless;
|
|
|
|
struct VertexOut {
|
|
float4 outPosition : SV_Position;
|
|
float4 screenPosition : ScreenPosition;
|
|
float4 vertexColor : CoarseColor;
|
|
float2 texCoord0 : TexCoord0;
|
|
};
|
|
|
|
struct CameraData {
|
|
float4x4 view;
|
|
float4x4 proj;
|
|
};
|
|
|
|
uniform ParameterBlock<CameraData> camera;
|
|
|
|
struct PerInstanceData {
|
|
float4x4 transform;
|
|
Sampler2D.RID textureID;
|
|
}
|
|
|
|
[[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(camera.proj, mul(camera.view, mul(pcb.transform, float4(position, 1.0f))));
|
|
output.screenPosition = mul(camera.proj, mul(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 {
|
|
if (let texture = pcb.textureID) {
|
|
return float4(texture.Sample(uv0).rgb, 1.0f) * interpolatedColors;
|
|
} else {
|
|
return interpolatedColors;
|
|
}
|
|
}
|
|
|