Add texture ID to shaders

This commit is contained in:
Richard Davey 2020-07-14 17:43:29 +01:00
parent 43beca7bab
commit 76689942c0
4 changed files with 19 additions and 5 deletions

View file

@ -3,15 +3,19 @@ module.exports = [
'',
'precision mediump float;',
'',
'uniform sampler2D uMainSampler;',
'uniform sampler2D uMainSampler[%count%];',
'',
'varying vec2 outTexCoord;',
'varying float outTexId;',
'varying float outTintEffect;',
'varying vec4 outTint;',
'',
'void main()',
'{',
' vec4 texture = texture2D(uMainSampler, outTexCoord);',
' vec4 texture;',
'',
' %forloop%',
'',
' vec4 texel = vec4(outTint.rgb * outTint.a, outTint.a);',
' vec4 color = texture;',
'',

View file

@ -9,10 +9,12 @@ module.exports = [
'',
'attribute vec2 inPosition;',
'attribute vec2 inTexCoord;',
'attribute float inTexId;',
'attribute float inTintEffect;',
'attribute vec4 inTint;',
'',
'varying vec2 outTexCoord;',
'varying float outTexId;',
'varying float outTintEffect;',
'varying vec4 outTint;',
'',
@ -21,6 +23,7 @@ module.exports = [
' gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);',
'',
' outTexCoord = inTexCoord;',
' outTexId = inTexId;',
' outTint = inTint;',
' outTintEffect = inTintEffect;',
'}',

View file

@ -2,15 +2,19 @@
precision mediump float;
uniform sampler2D uMainSampler;
uniform sampler2D uMainSampler[%count%];
varying vec2 outTexCoord;
varying float outTexId;
varying float outTintEffect;
varying vec4 outTint;
void main()
{
vec4 texture = texture2D(uMainSampler, outTexCoord);
vec4 texture;
%forloop%
vec4 texel = vec4(outTint.rgb * outTint.a, outTint.a);
vec4 color = texture;

View file

@ -8,18 +8,21 @@ uniform mat4 uModelMatrix;
attribute vec2 inPosition;
attribute vec2 inTexCoord;
attribute float inTexId;
attribute float inTintEffect;
attribute vec4 inTint;
varying vec2 outTexCoord;
varying float outTexId;
varying float outTintEffect;
varying vec4 outTint;
void main ()
void main ()
{
gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);
outTexCoord = inTexCoord;
outTexId = inTexId;
outTint = inTint;
outTintEffect = inTintEffect;
}