Skip to content

Commit cddf0b9

Browse files
[Rendering] WIP on shader handling;
1 parent 51d13e4 commit cddf0b9

File tree

20 files changed

+714
-397
lines changed

20 files changed

+714
-397
lines changed

BuiltinResources/Hidden/Shaders/Debug/NormalDebug.shader

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ Begin Parameters
22

33
End Parameters
44

5+
Begin Input
6+
POSITION
7+
NORMAL
8+
End Input
9+
510
Begin Instancing
611
End Instancing
712

@@ -31,7 +36,7 @@ VertexOutput VertexMain(Input input)
3136
float3 position = input.position;
3237

3338
output.normal = input.normal;
34-
output.position = mul(mul(mul(projection, view), world), float4(position, 1.0));
39+
output.position = mul(ProjectionViewWorld(world), float4(position, 1.0));
3540

3641
return output;
3742
}

BuiltinResources/Hidden/Shaders/Debug/TangentDebug.shader

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ Variants BITANGENT_COLOR
22

33
Begin Parameters
44

5-
varying vec3 v_tangent : TANGENT
6-
varying vec3 v_bitangent : BITANGENT
7-
85
variant: BITANGENT_COLOR uniform float tangentOrBitangent
96

107
End Parameters
118

9+
Begin Input
10+
POSITION
11+
TANGENT
12+
End Input
13+
1214
Begin Instancing
1315
End Instancing
1416

@@ -43,7 +45,7 @@ VertexOutput VertexMain(Input input)
4345
float3 position = input.position;
4446

4547
output.tangent = input.tangent;
46-
output.position = mul(mul(mul(projection, view), world), float4(position, 1.0));
48+
output.position = mul(ProjectionViewWorld(world), float4(position, 1.0));
4749

4850
return output;
4951
}

BuiltinResources/Hidden/Shaders/Default/SolidColor.shader

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ uniform color mainColor
66

77
End Parameters
88

9+
Begin Input
10+
POSITION
11+
End Input
12+
913
Begin Instancing
1014
End Instancing
1115

@@ -21,11 +25,13 @@ End Common
2125

2226
Begin Vertex
2327

28+
/*
2429
[[vk::binding(1, StapleUniformBufferSet)]]
2530
cbuffer Uniforms
2631
{
2732
float4 mainColor;
2833
};
34+
*/
2935

3036
struct Input
3137
{
@@ -38,10 +44,10 @@ VertexOutput VertexMain(Input input)
3844
VertexOutput output;
3945

4046
float3 position = input.position;
41-
float4 color = mainColor;
47+
float4 color = float4(1, 0, 0, 1);//mainColor;
4248

4349
output.color = color;
44-
output.position = mul(mul(mul(projection, view), world), float4(position, 1.0));
50+
output.position = mul(ProjectionViewWorld(world), float4(position, 1.0));
4551

4652
return output;
4753
}

BuiltinResources/Hidden/Shaders/Default/Standard.shader

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,21 @@ uniform float alphaThreshold = 0.25
2222

2323
End Parameters
2424

25+
Begin Input
26+
POSITION
27+
TEXCOORD0
28+
NORMAL
29+
TANGENT
30+
BITANGENT
31+
COLOR0
32+
End Input
33+
2534
Begin Instancing
2635
End Instancing
2736

2837
Begin Common
2938

39+
/*
3040
[[vk::binding(1, StapleUniformBufferSet)]]
3141
cbuffer Uniforms
3242
{
@@ -37,10 +47,11 @@ cbuffer Uniforms
3747
float cutout;
3848
float alphaThreshold;
3949
};
50+
*/
4051

4152
struct VertexOutput
4253
{
43-
float3 position : SV_Position;
54+
float4 position : SV_Position;
4455
float3 worldPosition;
4556
float3 lightNormal;
4657
float2 coords;
@@ -73,12 +84,12 @@ VertexOutput VertexMain(Input input)
7384

7485
float4x4 model = world;
7586

76-
float4x4 projectionViewWorld = mul(mul(projection, view), model);
77-
float4x4 viewWorld = mul(view, model);
87+
float4x4 projectionViewWorld = ProjectionViewWorld(model);
88+
float4x4 viewWorld = ViewWorld(model);
7889

7990
float4 vertexPosition = mul(projectionViewWorld, float4(input.position, 1.0));
8091

81-
output.position = vertexPosition.xyz;
92+
output.position = vertexPosition;
8293

8394
output.worldPosition = mul(model, float4(input.position, 1.0)).xyz;
8495

@@ -122,17 +133,19 @@ cbuffer Textures
122133
float4 FragmentMain(VertexOutput input) : SV_Target
123134
{
124135
#if defined(VERTEX_COLORS) || defined(PER_VERTEX_LIGHTING)
125-
float4 diffuse = input.color * diffuseColor;
136+
float4 diffuse = input.color;// * diffuseColor;
126137
#else
127-
float4 diffuse = diffuseTexture.Sample(input.coords) * diffuseColor;
138+
float4 diffuse = diffuseTexture.Sample(input.coords);// * diffuseColor;
128139
#endif
129-
140+
141+
/*
130142
#ifdef CUTOUT
131143
if(diffuse.a < alphaThreshold)
132144
{
133145
discard;
134146
}
135147
#endif
148+
*/
136149

137150
//TODO: handle light array
138151
/*

BuiltinResources/Hidden/Shaders/Sprite/Sprite.shader

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,20 @@ uniform texture mainTexture
99

1010
End Parameters
1111

12+
Begin Input
13+
POSITION
14+
TEXCOORD0
15+
End Input
16+
1217
Begin Common
1318

19+
/*
1420
[[vk::binding(1, StapleUniformBufferSet)]]
1521
cbuffer Uniforms
1622
{
1723
float4 mainColor;
1824
};
25+
*/
1926

2027
struct VertexOutput
2128
{
@@ -40,11 +47,11 @@ VertexOutput VertexMain(Input input)
4047
VertexOutput output;
4148

4249
float3 position = input.position;
43-
float4 color = mainColor;
50+
float4 color = float4(1, 1, 1, 1);//mainColor;
4451

4552
output.color = color;
4653
output.coord = input.coord;
47-
output.position = mul(mul(mul(projection, view), world), float4(position, 1.0));
54+
output.position = mul(ProjectionViewWorld(world), float4(position, 1.0));
4855

4956
return output;
5057
}

BuiltinResources/Hidden/Shaders/UI/imgui.shader

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@ uniform texture mainTexture
77

88
End Parameters
99

10+
Begin Input
11+
POSITION
12+
TEXCOORD0
13+
COLOR0
14+
End Input
15+
1016
Begin Common
1117

1218
struct VertexOutput
1319
{
1420
float4 position : SV_Position;
15-
float2 coord;
16-
float4 color;
21+
float2 coord : TEXCOORD0;
22+
float4 color : COLOR0;
1723
};
1824

1925
End Common
@@ -42,7 +48,7 @@ VertexOutput VertexMain(Input input)
4248
);
4349

4450
output.coord = input.coord;
45-
output.position = mul(mul(mul(projection, view), world), float4(position, 1.0));
51+
output.position = mul(ProjectionViewWorld(world), float4(position, 1.0));
4652

4753
return output;
4854
}

0 commit comments

Comments
 (0)