phaser
Version:
A fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers.
35 lines (34 loc) • 920 B
JavaScript
module.exports = [
'#define SHADER_NAME PHASER_SINGLE_FS',
'',
'precision mediump float;',
'',
'uniform sampler2D uMainSampler;',
'',
'varying vec2 outTexCoord;',
'varying float outTintEffect;',
'varying vec4 outTint;',
'',
'void main ()',
'{',
' vec4 texture = texture2D(uMainSampler, outTexCoord);',
' vec4 texel = vec4(outTint.bgr * outTint.a, outTint.a);',
'',
' // Multiply texture tint',
' vec4 color = texture * texel;',
'',
' if (outTintEffect == 1.0)',
' {',
' // Solid color + texture alpha',
' color.rgb = mix(texture.rgb, outTint.bgr * outTint.a, texture.a);',
' }',
' else if (outTintEffect == 2.0)',
' {',
' // Solid color, no texture',
' color = texel;',
' }',
'',
' gl_FragColor = color;',
'}',
''
].join('\n');