Skip to content

Commit bc70e9d

Browse files
committed
Address pull request feedback and cleanup
1 parent 8abac3d commit bc70e9d

File tree

9 files changed

+47
-51
lines changed

9 files changed

+47
-51
lines changed

shaders/fragment_shader_barycentric/slang/object.frag.slang

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#version 450
21
/* Copyright (c) 2023-2025, Mobica Limited
32
*
43
* SPDX-License-Identifier: Apache-2.0
@@ -32,44 +31,44 @@ float4 main(VSOutput input, float3 baryCoords: SV_Barycentrics, noperspective fl
3231
float3 vColor2 = GetAttributeAtVertex(input.Color, 2);
3332

3433
float4 outColor = 0.0;
35-
switch (type) {
36-
case 0:
34+
switch (type) {
35+
case 0:
3736
{
3837
outColor.rgb = vColor0 * baryCoords.x +
3938
vColor1 * baryCoords.y +
4039
vColor2 * baryCoords.z;
41-
outColor.a = 1.0;
42-
break;
43-
}
44-
case 1:
40+
outColor.a = 1.0;
41+
break;
42+
}
43+
case 1:
4544
{
4645
outColor.rgb = baryCoords - baryCoordsAffine;
47-
const float exposure = 10.f;
48-
outColor = float4(vec3(1.0) - exp(-outColor.rgb * exposure), 1.0);
49-
break;
50-
}
51-
case 2:
46+
const float exposure = 10.f;
47+
outColor = float4(float3(1.0) - exp(-outColor.rgb * exposure), 1.0);
48+
break;
49+
}
50+
case 2:
5251
{
5352
if (baryCoords.x < 0.01 || baryCoords.y < 0.01 || baryCoords.z < 0.01)
54-
outColor = float4(0.0, 0.0, 0.0, 1.0);
55-
else
56-
outColor = float4(0.5, 0.5, 0.5, 1.0);
57-
break;
58-
}
59-
case 3:
53+
outColor = float4(0.0, 0.0, 0.0, 1.0);
54+
else
55+
outColor = float4(0.5, 0.5, 0.5, 1.0);
56+
break;
57+
}
58+
case 3:
6059
{
6160
if (baryCoords.x <= baryCoords.y && baryCoords.x <= baryCoords.z)
6261
outColor = float4(vColor0.rgb * baryCoords.x, 1.0);
6362
else if (baryCoords.y < baryCoords.x && baryCoords.y <= baryCoords.z)
6463
outColor = float4(vColor1.rgb * baryCoords.y, 1.0);
6564
else
6665
outColor = float4(vColor2.rgb * baryCoords.z, 1.0);
67-
break;
68-
}
69-
case 4:
66+
break;
67+
}
68+
case 4:
7069
{
7170
outColor = samplerColorMap.Sample(float2(sin(baryCoords.x) + cos(2 * baryCoords.z), sin(baryCoords.x) + cos(2 * baryCoords.y)));
72-
}
71+
}
7372
}
7473
return outColor;
7574
}

shaders/fragment_shader_barycentric/slang/object.vert.slang

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ VSOutput main(VSInput input, uint VertexIndex: SV_VertexID)
4646
{
4747
VSOutput output;
4848
output.Pos = mul(ubo.projection, mul(ubo.modelview, float4(input.Pos.xyz, 1.0)));
49-
output.Color = triangleColors[VertexIndex % 6];
50-
return output;
49+
output.Color = triangleColors[VertexIndex % 6];
50+
return output;
5151
}

shaders/fragment_shader_barycentric/slang/skybox.vert.slang

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#version 450
21
/* Copyright (c) 2023-2025, Mobica Limited
32
*
43
* SPDX-License-Identifier: Apache-2.0
@@ -37,7 +36,7 @@ ConstantBuffer<UBO> ubo;
3736
VSOutput main(VSInput input)
3837
{
3938
VSOutput output;
40-
output.Pos = mul(ubo.projection, float4(mul((float3x3)ubo.modelview, input.Pos.xyz), 1.0));
39+
output.Pos = mul(ubo.projection, float4(mul((float3x3)ubo.modelview, input.Pos), 1.0));
4140
output.UVW = input.Pos;
4241
return output;
4342
}
-32 Bytes
Binary file not shown.

shaders/fragment_shading_rate/slang/scene.vert.slang

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct UBO
3636
float4x4 projection;
3737
float4x4 modelview;
3838
float4x4 skybox_modelview;
39-
int colorShadingRates;
39+
int color_shading_rates;
4040
};
4141
ConstantBuffer<UBO> ubo;
4242

0 Bytes
Binary file not shown.

shaders/gshader_to_mshader/slang/gshader_to_mshader.frag.slang

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ struct VSOutput
2727
[shader("fragment")]
2828
float4 main(VSOutput input)
2929
{
30-
float ambientStrength = 0.2;
31-
float3 ambient = ambientStrength * float3(1.0);
30+
float ambientStrength = 0.2;
31+
float3 ambient = ambientStrength * float3(1.0);
3232

3333
float3 N = normalize(input.Normal);
3434
float3 L = normalize(input.LightVec);
3535
float3 V = normalize(input.ViewVec);
36-
float3 R = reflect(-L, N);
36+
float3 R = reflect(-L, N);
3737

38-
float3 diffuse = max(dot(N,L), 0.0) * float3(1.0);
38+
float3 diffuse = max(dot(N,L), 0.0) * float3(1.0);
3939

40-
float3 specular = pow(max(dot(R, V), 0.0), 64.0) * float3(0.65);
40+
float3 specular = pow(max(dot(R, V), 0.0), 64.0) * float3(0.65);
4141

42-
float3 result = (ambient + diffuse) * input.Color + specular;
43-
44-
return float4(result, 1.0f);
42+
float3 result = (ambient + diffuse) * input.Color + specular;
43+
44+
return float4(result, 1.0f);
4545
}

shaders/gshader_to_mshader/slang/gshader_to_mshader.geom.slang

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct VSOutput
2424

2525
struct GSOutput
2626
{
27-
float4 Pos : SV_POSITION;
27+
float4 Pos : SV_Position;
2828
float3 Color;
2929
};
3030

@@ -40,23 +40,21 @@ struct UBO {
4040
void main(triangle VSOutput input[3], inout LineStream<GSOutput> outStream)
4141
{
4242
float normalLength = 0.1f;
43-
for (int i = 0; i < 3; i++)
44-
{
45-
// middle point of triangle
46-
float3 pos = (input[0].Pos.xyz + input[1].Pos.xyz + input[2].Pos.xyz) / 3.0;
47-
float3 normal = input[i].Normal.xyz;
4843

49-
GSOutput output;
44+
// middle point of triangle
45+
float3 pos = (input[0].Pos.xyz + input[1].Pos.xyz + input[2].Pos.xyz) / 3.0;
46+
float3 normal = input[0].Normal.xyz;
47+
48+
GSOutput output;
5049

51-
// line vertices
52-
output.Pos = mul(ubo.proj, mul(ubo.view, mul(ubo.model, float4(pos, 1.0))));
53-
output.Color = float3(1.0, 0.0, 0.0);
54-
outStream.Append(output);
50+
// line vertices
51+
output.Pos = mul(ubo.proj, mul(ubo.view, mul(ubo.model, float4(pos, 1.0))));
52+
output.Color = float3(1.0, 0.0, 0.0);
53+
outStream.Append(output);
5554

56-
output.Pos = mul(ubo.proj, mul(ubo.view, mul(ubo.model, float4(pos + normal * normalLength, 1.0))));
57-
output.Color = float3(0.0, 0.0, 1.0);
58-
outStream.Append(output);
55+
output.Pos = mul(ubo.proj, mul(ubo.view, mul(ubo.model, float4(pos + normal * normalLength, 1.0))));
56+
output.Color = float3(0.0, 0.0, 1.0);
57+
outStream.Append(output);
5958

60-
outStream.RestartStrip();
61-
}
59+
outStream.RestartStrip();
6260
}
-732 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)