Finished first version of shader compiler. HLSL -> DXIL.
Submitting vertex and frag shader needed to display a triangle.
This commit is contained in:
4
Assets/source/SolidColor.frag.hlsl
Normal file
4
Assets/source/SolidColor.frag.hlsl
Normal file
@@ -0,0 +1,4 @@
|
||||
float4 main(float4 Color : TEXCOORD0) : SV_Target0
|
||||
{
|
||||
return Color;
|
||||
}
|
||||
39
Assets/source/Triangle.vert.hlsl
Normal file
39
Assets/source/Triangle.vert.hlsl
Normal file
@@ -0,0 +1,39 @@
|
||||
struct Input
|
||||
{
|
||||
uint VertexIndex : SV_VertexID;
|
||||
};
|
||||
|
||||
struct Output
|
||||
{
|
||||
float4 Color : TEXCOORD0;
|
||||
float4 Position : SV_Position;
|
||||
};
|
||||
|
||||
Output main(Input input)
|
||||
{
|
||||
Output output;
|
||||
float2 pos;
|
||||
if (input.VertexIndex == 0)
|
||||
{
|
||||
pos = (-1.0f).xx;
|
||||
output.Color = float4(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (input.VertexIndex == 1)
|
||||
{
|
||||
pos = float2(1.0f, -1.0f);
|
||||
output.Color = float4(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (input.VertexIndex == 2)
|
||||
{
|
||||
pos = float2(0.0f, 1.0f);
|
||||
output.Color = float4(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
output.Position = float4(pos, 0.0f, 1.0f);
|
||||
return output;
|
||||
}
|
||||
Reference in New Issue
Block a user