diff options
Diffstat (limited to 'examples/hello/hello.slang')
| -rw-r--r-- | examples/hello/hello.slang | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/examples/hello/hello.slang b/examples/hello/hello.slang index f495d12b4..5a68979ce 100644 --- a/examples/hello/hello.slang +++ b/examples/hello/hello.slang @@ -1,24 +1,28 @@ // hello.slang +// This file provides a simple vertex and fragment shader that can be compiled +// using Slang. This code should also be valid as HLSL, and thus it does not +// use any of the new language features supported by Slang. + cbuffer Uniforms { - float4x4 modelViewProjection; + float4x4 modelViewProjection; } struct AssembledVertex { - float3 position; - float3 color; + float3 position : POSITION; + float3 color : COLOR; }; struct CoarseVertex { - float3 color; + float3 color; }; struct Fragment { - float4 color; + float4 color; }; @@ -26,48 +30,47 @@ struct Fragment struct VertexStageInput { - AssembledVertex assembledVertex : A; + AssembledVertex assembledVertex; }; struct VertexStageOutput { - CoarseVertex coarseVertex : CoarseVertex; - float4 sv_position : SV_Position; + CoarseVertex coarseVertex : CoarseVertex; + float4 sv_position : SV_Position; }; VertexStageOutput vertexMain(VertexStageInput input) { - VertexStageOutput output; + VertexStageOutput output; - float3 position = input.assembledVertex.position; - float3 color = input.assembledVertex.color; + float3 position = input.assembledVertex.position; + float3 color = input.assembledVertex.color; - output.coarseVertex.color = color; - output.sv_position = mul(modelViewProjection, float4(position, 1.0)); + output.coarseVertex.color = color; + output.sv_position = mul(modelViewProjection, float4(position, 1.0)); - return output; + return output; } // Fragment Shader struct FragmentStageInput { - CoarseVertex coarseVertex : CoarseVertex; + CoarseVertex coarseVertex : CoarseVertex; }; struct FragmentStageOutput { - Fragment fragment : SV_Target; + Fragment fragment : SV_Target; }; FragmentStageOutput fragmentMain(FragmentStageInput input) { - FragmentStageOutput output; + FragmentStageOutput output; - float3 color = input.coarseVertex.color; + float3 color = input.coarseVertex.color; - output.fragment.color = float4(color, 1.0); + output.fragment.color = float4(color, 1.0); - return output; + return output; } - |
