Uniform buffer
This commit is contained in:
29
shaders/22_shader_ubo.slang
Normal file
29
shaders/22_shader_ubo.slang
Normal file
@@ -0,0 +1,29 @@
|
||||
struct VSInput {
|
||||
float2 inPosition;
|
||||
float3 inColor;
|
||||
};
|
||||
|
||||
struct UniformBuffer {
|
||||
float4x4 model;
|
||||
float4x4 view;
|
||||
float4x4 proj;
|
||||
};
|
||||
ConstantBuffer<UniformBuffer> ubo;
|
||||
|
||||
struct VSOutput {
|
||||
float4 pos : SV_Position;
|
||||
float3 color;
|
||||
};
|
||||
|
||||
[shader("vertex")]
|
||||
VSOutput vertMain(VSInput input) {
|
||||
VSOutput output;
|
||||
output.color = input.inColor;
|
||||
output.pos = mul(ubo.proj, mul(ubo.view, mul(ubo.model, float4(input.inPosition, 0.0, 1.0))));
|
||||
return output;
|
||||
}
|
||||
|
||||
[shader("fragment")]
|
||||
float4 fragMain(VSOutput vertIn) : SV_Target {
|
||||
return float4(vertIn.color, 1.0);
|
||||
}
|
||||
Reference in New Issue
Block a user