Skip to content

Commit b818867

Browse files
[Rendering] Updated most default shaders to Slang standards;
1 parent 7379bc3 commit b818867

File tree

9 files changed

+150
-161
lines changed

9 files changed

+150
-161
lines changed
Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,49 @@
11
Begin Parameters
22

3-
varying vec3 a_position : POSITION
4-
varying vec3 a_normal : NORMAL
5-
varying vec3 v_normal : NORMAL
6-
73
End Parameters
84

95
Begin Instancing
106
End Instancing
117

12-
Begin Vertex
8+
Begin Common
9+
10+
struct VertexOutput
11+
{
12+
float4 position : SV_Position;
13+
float3 normal;
14+
};
1315

14-
$input a_position, a_normal
15-
$output v_normal
16+
End Common
1617

17-
void main()
18+
Begin Vertex
19+
20+
struct Input
1821
{
19-
mat4 model = StapleModelMatrix;
22+
float3 position : POSITION;
23+
float3 normal : NORMAL;
24+
};
2025

21-
#ifdef SKINNING
22-
model = StapleGetSkinningMatrix(model, a_indices, a_weight);
23-
#endif
26+
[shader("vertex")]
27+
VertexOutput VertexMain(Input input)
28+
{
29+
VertexOutput output;
2430

25-
mat4 projViewWorld = mul(mul(u_proj, u_view), model);
26-
vec4 v_pos = mul(projViewWorld, vec4(a_position, 1.0));
31+
float3 position = input.position;
2732

28-
v_normal = a_normal;
33+
output.normal = input.normal;
34+
output.position = mul(mul(mul(projection, view), world), float4(position, 1.0));
2935

30-
gl_Position = v_pos;
36+
return output;
3137
}
3238

3339
End Vertex
3440

3541
Begin Fragment
3642

37-
$input v_normal
38-
39-
void main()
43+
[shader("fragment")]
44+
float4 FragmentMain(VertexOutput input) : SV_Target
4045
{
41-
gl_FragColor = vec4(v_normal * 0.5 + 0.5, 1);
46+
return float4(normalize(input.normal) * 0.5 + 0.5, 1);
4247
}
4348

4449
End Fragment

BuiltinResources/Hidden/Shaders/Debug/TangentDebug.shader

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,50 @@ End Parameters
1212
Begin Instancing
1313
End Instancing
1414

15-
Begin Vertex
15+
Begin Common
16+
17+
struct VertexOutput
18+
{
19+
float4 position : SV_Position;
20+
float3 tangent;
21+
};
1622

17-
$input a_position, a_tangent, a_bitangent
18-
$output v_tangent, v_bitangent
23+
End Common
1924

20-
void main()
25+
Begin Vertex
26+
27+
struct Input
2128
{
22-
mat4 model = StapleModelMatrix;
29+
float3 position : POSITION;
30+
31+
#ifdef BITANGENT
32+
float3 tangent : BITANGENT;
33+
#else
34+
float3 tangent : TANGENT;
35+
#endif
36+
};
2337

24-
#ifdef SKINNING
25-
model = StapleGetSkinningMatrix(model, a_indices, a_weight);
26-
#endif
38+
[shader("vertex")]
39+
VertexOutput VertexMain(Input input)
40+
{
41+
VertexOutput output;
2742

28-
mat4 projViewWorld = mul(mul(u_proj, u_view), model);
29-
vec4 v_pos = mul(projViewWorld, vec4(a_position, 1.0));
43+
float3 position = input.position;
3044

31-
v_tangent = a_tangent;
32-
v_bitangent = a_bitangent;
45+
output.tangent = input.tangent;
46+
output.position = mul(mul(mul(projection, view), world), float4(position, 1.0));
3347

34-
gl_Position = v_pos;
48+
return output;
3549
}
3650

3751
End Vertex
3852

3953
Begin Fragment
4054

41-
$input v_tangent, v_bitangent
42-
43-
void main()
55+
[shader("fragment")]
56+
float4 FragmentMain(VertexOutput input) : SV_Target
4457
{
45-
#if BITANGENT
46-
vec3 color = v_bitangent;
47-
#else
48-
vec3 color = v_tangent;
49-
#endif
50-
51-
gl_FragColor = vec4(color * 0.5 + 0.5, 1);
58+
return float4(normalize(input.tangent) * 0.5 + 0.5, 1);
5259
}
5360

5461
End Fragment

BuiltinResources/Hidden/Shaders/Sprite/Sprite.shader

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,59 @@ Blend SrcAlpha OneMinusSrcAlpha
44

55
Begin Parameters
66

7-
varying vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0)
8-
varying vec3 a_position : POSITION
9-
varying vec2 a_texcoord0 : TEXCOORD0
10-
117
uniform color mainColor
128
uniform texture mainTexture
139

1410
End Parameters
1511

12+
Begin Common
13+
14+
cbuffer Uniforms
15+
{
16+
float4 mainColor;
17+
Sampler2D mainTexture;
18+
};
19+
20+
struct VertexOutput
21+
{
22+
float4 position : SV_Position;
23+
float2 coord;
24+
float4 color;
25+
};
26+
27+
End Common
28+
1629
Begin Vertex
1730

18-
$input a_position, a_texcoord0
19-
$output v_texcoord0
31+
struct Input
32+
{
33+
float3 position : POSITION;
34+
float2 coord : TEXCOORD0;
35+
};
2036

21-
void main()
37+
[shader("vertex")]
38+
VertexOutput VertexMain(Input input)
2239
{
23-
mat4 projViewWorld = mul(mul(u_proj, u_view), u_model[0]);
40+
VertexOutput output;
2441

25-
vec4 v_pos = mul(projViewWorld, vec4(a_position, 1.0));
42+
float3 position = input.position;
43+
float4 color = mainColor;
2644

27-
gl_Position = v_pos;
45+
output.color = color;
46+
output.coord = input.coord;
47+
output.position = mul(mul(mul(projection, view), world), float4(position, 1.0));
2848

29-
v_texcoord0 = a_texcoord0;
49+
return output;
3050
}
3151

3252
End Vertex
3353

3454
Begin Fragment
3555

36-
$input v_texcoord0
37-
38-
void main()
56+
[shader("fragment")]
57+
float4 FragmentMain(VertexOutput input) : SV_Target
3958
{
40-
gl_FragColor = texture2D(mainTexture, v_texcoord0) * mainColor;
59+
return mainTexture.Sample(input.coord) * input.color;
4160
}
4261

4362
End Fragment
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
Type VertexFragment
2+
Blend SrcAlpha OneMinusSrcAlpha
3+
4+
Begin Parameters
5+
6+
uniform texture mainTexture
7+
8+
End Parameters
9+
10+
Begin Common
11+
12+
cbuffer Uniforms
13+
{
14+
Sampler2D mainTexture;
15+
};
16+
17+
struct VertexOutput
18+
{
19+
float4 position : SV_Position;
20+
float2 coord;
21+
float4 color;
22+
};
23+
24+
End Common
25+
26+
Begin Vertex
27+
28+
struct Input
29+
{
30+
float3 position : POSITION;
31+
float2 coord : TEXCOORD0;
32+
float4 color : COLOR0;
33+
};
34+
35+
[shader("vertex")]
36+
VertexOutput VertexMain(Input input)
37+
{
38+
VertexOutput output;
39+
40+
float3 position = input.position;
41+
42+
output.color = input.color;
43+
output.coord = input.coord;
44+
output.position = mul(mul(mul(projection, view), world), float4(position, 1.0));
45+
46+
return output;
47+
}
48+
49+
End Vertex
50+
51+
Begin Fragment
52+
53+
[shader("fragment")]
54+
float4 FragmentMain(VertexOutput input) : SV_Target
55+
{
56+
return mainTexture.Sample(input.coord) * input.color;
57+
}
58+
59+
End Fragment

BuiltinResources/Hidden/Shaders/UI/imgui_image.shader.meta renamed to BuiltinResources/Hidden/Shaders/UI/imgui.shader.meta

File renamed without changes.

BuiltinResources/Hidden/Shaders/UI/imgui_image.shader

Lines changed: 0 additions & 51 deletions
This file was deleted.

BuiltinResources/Hidden/Shaders/UI/ocornut_imgui.shader

Lines changed: 0 additions & 41 deletions
This file was deleted.

BuiltinResources/Hidden/Shaders/UI/ocornut_imgui.shader.meta

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)