Skip to content

Commit e46a20c

Browse files
committed
Add vertex color tinting fragment shader
1 parent b661a98 commit e46a20c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Sources/GateEngine/System/Rendering/SystemShaders.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,17 @@ extension FragmentShader {
124124
fsh.output.color = color.discard(if: color.a <= 0)
125125
return fsh
126126
}()
127+
/// Uses material.channel(0).texture to shade objects
128+
public static let textureSample_TintVertexColor_DiscardZeroAlpha: FragmentShader = {
129+
let fsh = FragmentShader()
130+
let sample = fsh.channel(0).texture.sample(
131+
at: fsh.input["texCoord0"]
132+
)
133+
let vertexColor: Vec4 = fsh.input["color"]
134+
let color = Vec4(sample.rgb * vertexColor.rgb, sample.a * vertexColor.a)
135+
fsh.output.color = color.discard(if: color.a <= 0)
136+
return fsh
137+
}()
127138
/// Uses material.channel(0).color to shade objects
128139
public static let materialColor: FragmentShader = {
129140
let fsh = FragmentShader()

0 commit comments

Comments
 (0)