Skip to content

Commit bbcc0be

Browse files
committed
Define explicit template tint color shader
1 parent f30eb88 commit bbcc0be

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Sources/GateEngine/System/Rendering/Drawables/Scene.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ import Shaders
9393
transforms: transforms,
9494
material: material,
9595
vsh: (material.channels.first?.texture != nil) ? .standard : material.channels.first?.color == .vertexColors ? .vertexColors : .standard,
96-
fsh: (material.channels.first?.texture != nil) ? .textureSample : material.channels.first?.color == .vertexColors ? .vertexColor : .materialColor,
96+
fsh: (material.channels.first?.texture != nil) ? .textureSampleTintColor : material.channels.first?.color == .vertexColors ? .vertexColor : .materialColor,
9797
flags: flags.drawCommandFlags(withPrimitive: .triangle, blendMode: blendMode)
9898
)
9999
self.insert(command)

Sources/GateEngine/System/Rendering/SystemShaders.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,15 @@ extension FragmentShader {
136136
}()
137137
/// Uses material.channel(0).texture to shade objects
138138
public static let textureSampleTintColor: FragmentShader = {
139+
let fsh = FragmentShader()
140+
let sample = fsh.channel(0).texture.sample(
141+
at: fsh.input["texCoord0"]
142+
)
143+
fsh.output.color = Vec4(sample.rgb * fsh.channel(0).color.rgb, sample.a)
144+
return fsh
145+
}()
146+
/// Uses material.channel(0).texture to shade objects
147+
public static let textureSampleTemplateTintColor: FragmentShader = {
139148
let fsh = FragmentShader()
140149
let sample = fsh.channel(0).texture.sample(
141150
at: fsh.input["texCoord0"]

0 commit comments

Comments
 (0)