Skip to content

Commit 9d11b93

Browse files
committed
Updated shader
1 parent 4c25d12 commit 9d11b93

2 files changed

Lines changed: 28 additions & 12 deletions

File tree

src/renderer/webgl/shaders/TextureTint-frag.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,27 @@ module.exports = [
1111
'',
1212
'void main()',
1313
'{',
14+
' vec4 texture = texture2D(uMainSampler, outTexCoord);',
1415
' vec4 texel = vec4(outTint.rgb * outTint.a, outTint.a);',
16+
' vec4 color = texture;',
1517
'',
16-
' if (outTintEffect == 1.0)',
18+
' if (outTintEffect == 0.0)',
1719
' {',
18-
' texel = texture2D(uMainSampler, outTexCoord);',
19-
' texel.rgb = mix(texel.rgb, outTint.rgb, texel.a);',
20+
' // Multiply tint',
21+
' color = texture * texel;',
2022
' }',
21-
' else if (outTintEffect == 0.0)',
23+
' else if (outTintEffect == 1.0)',
2224
' {',
23-
' texel *= texture2D(uMainSampler, outTexCoord);',
25+
' // Solid texture-based tint',
26+
' color.rgb = mix(texture.rgb, outTint.rgb, texture.a);',
27+
' }',
28+
' else if (outTintEffect == 2.0)',
29+
' {',
30+
' // Solid color, no texture',
31+
' color = texel;',
2432
' }',
2533
'',
26-
' gl_FragColor = texel;',
34+
' gl_FragColor = color;',
2735
'}',
2836
''
2937
].join('\n');

src/renderer/webgl/shaders/src/TextureTint.frag

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,25 @@ varying vec4 outTint;
1010

1111
void main()
1212
{
13+
vec4 texture = texture2D(uMainSampler, outTexCoord);
1314
vec4 texel = vec4(outTint.rgb * outTint.a, outTint.a);
15+
vec4 color = texture;
1416

15-
if (outTintEffect == 1.0)
17+
if (outTintEffect == 0.0)
1618
{
17-
texel = texture2D(uMainSampler, outTexCoord);
18-
texel.rgb = mix(texel.rgb, outTint.rgb, texel.a);
19+
// Multiply texture tint
20+
color = texture * texel;
1921
}
20-
else if (outTintEffect == 0.0)
22+
else if (outTintEffect == 1.0)
2123
{
22-
texel *= texture2D(uMainSampler, outTexCoord);
24+
// Solid color + texture alpha
25+
color.rgb = mix(texture.rgb, outTint.rgb, texture.a);
26+
}
27+
else if (outTintEffect == 2.0)
28+
{
29+
// Solid color, no texture
30+
color = texel;
2331
}
2432

25-
gl_FragColor = texel;
33+
gl_FragColor = color;
2634
}

0 commit comments

Comments
 (0)