2 uniform int uTDInstanceIDOffset;
\r
3 uniform int uTDNumInstances;
\r
4 uniform float uTDAlphaTestVal;
\r
5 #define TD_NUM_COLOR_BUFFERS 1
\r
6 #define TD_NUM_LIGHTS 0
\r
7 #define TD_NUM_SHADOWED_LIGHTS 0
\r
8 #define TD_NUM_ENV_LIGHTS 0
\r
9 #define TD_LIGHTS_ARRAY_SIZE 1
\r
10 #define TD_ENV_LIGHTS_ARRAY_SIZE 1
\r
11 #define TD_NUM_CAMERAS 1
\r
12 struct TDPhongResult
\r
17 float shadowStrength;
\r
23 float shadowStrength;
\r
30 mat4 worldCamInverse;
\r
34 mat4 camProjInverse;
\r
38 mat4 worldCamProjInverse;
\r
40 mat3 worldForNormals;
\r
42 mat3 worldCamForNormals;
\r
44 layout(std140) uniform TDMatricesBlock {
\r
45 TDMatrix uTDMats[TD_NUM_CAMERAS];
\r
52 int renderTOPCameraIndex;
\r
54 layout(std140) uniform TDCameraInfoBlock {
\r
55 TDCameraInfo uTDCamInfos[TD_NUM_CAMERAS];
\r
66 layout(std140) uniform TDGeneralBlock {
\r
67 TDGeneral uTDGeneral;
\r
70 void TDAlphaTest(float alpha);
\r
71 vec4 TDDither(vec4 color);
\r
72 vec4 TDOutputSwizzle(vec4 v);
\r
73 uvec4 TDOutputSwizzle(uvec4 v);
\r
74 void TDCheckOrderIndTrans();
\r
75 void TDCheckDiscard();
\r
76 uniform vec3 uConstant;
\r
77 uniform float uShadowStrength;
\r
78 uniform vec3 uShadowColor;
\r
79 uniform vec4 uDiffuseColor;
\r
80 uniform vec4 uAmbientColor;
\r
82 uniform sampler2DArray sColorMap;
\r
89 flat int cameraIndex;
\r
93 // Output variable for the color
\r
94 layout(location = 0) out vec4 oFragColor[TD_NUM_COLOR_BUFFERS];
\r
97 // This allows things such as order independent transparency
\r
98 // and Dual-Paraboloid rendering to work properly
\r
101 vec4 outcol = vec4(0.0, 0.0, 0.0, 0.0);
\r
103 vec3 texCoord0 = iVert.texCoord0.stp;
\r
104 float actualTexZ = mod(int(texCoord0.z),2048);
\r
105 float instanceLoop = floor(int(texCoord0.z)/2048);
\r
106 texCoord0.z = actualTexZ;
\r
107 vec4 colorMapColor = texture(sColorMap, texCoord0.stp);
\r
109 float red = colorMapColor[int(instanceLoop)];
\r
110 colorMapColor = vec4(red);
\r
111 // Constant Light Contribution
\r
112 outcol.rgb += uConstant * iVert.color.rgb;
\r
114 outcol *= colorMapColor;
\r
116 // Alpha Calculation
\r
117 float alpha = iVert.color.a * colorMapColor.a ;
\r
119 // Dithering, does nothing if dithering is disabled
\r
120 outcol = TDDither(outcol);
\r
122 outcol.rgb *= alpha;
\r
124 // Modern GL removed the implicit alpha test, so we need to apply
\r
125 // it manually here. This function does nothing if alpha test is disabled.
\r
126 TDAlphaTest(alpha);
\r
129 oFragColor[0] = TDOutputSwizzle(outcol);
\r
132 // TD_NUM_COLOR_BUFFERS will be set to the number of color buffers
\r
133 // active in the render. By default we want to output zero to every
\r
134 // buffer except the first one.
\r
135 for (int i = 1; i < TD_NUM_COLOR_BUFFERS; i++)
\r
137 oFragColor[i] = vec4(0.0);
\r