I’ve had a user (on I believe an old system requiring GLSL100) report the following error with my shader:
RendererException: compile error in: ShaderSource[name=MatDefs/repeatingFrag.frag, defines, type=Fragment, language=GLSL100]
ERROR: 0:68: No matching function for call to mod(float, int)
ERROR: 0:69: No matching function for call to mod(float, int)
ERROR: 0:71: Use of undeclared identifier ‘progression’
ERROR: 0:71: Use of undeclared identifier ‘progression’
ERROR: 0:75: Use of undeclared identifier ‘calculatedTexCoord’
I believe because I’ve accidentally written my shader to be only GLSL150 compatible not GLSL100
-
Those errors I know look relatively self explanatory but other variables (e.g. color) look to be declared in the same way without recieving this error, what exactly is meant by “Use of undeclared identifier”?
-
I’ve also looked up the mod function and it appears available in all versions of openGl: mod - OpenGL 4 Reference Pages. Is there something else I need to do to make this GLSL100 compatible?
This is my fragment shader
#import "Common/ShaderLib/GLSLCompat.glsllib"
#if defined(HAS_GLOWMAP) || defined(HAS_COLORMAP) || (defined(HAS_LIGHTMAP) && !defined(SEPARATE_TEXCOORD))
#define NEED_TEXCOORD1
#endif
#if defined(DISCARD_ALPHA)
uniform float m_AlphaDiscardThreshold;
#endif
uniform float m_SunlightIntensity;
uniform vec4 m_Color;
uniform sampler2D m_ColorMap;
uniform sampler2D m_LightMap;
const vec2 unit = vec2(1,1);
varying vec2 texCoord1; //starts
varying vec2 texCoord2;
varying vec2 texCoord3; //ends
varying vec2 texCoord4; //0 to noOfRepeats over the quad
varying vec4 texCoord5; //this is the night (or source) color
varying vec4 vertColor;
void main(){
vec4 color = vec4(1,1,1,1);
vec2 progression = vec2 (mod (texCoord4.x, 1),
mod (texCoord4.y, 1));
vec2 calculatedTexCoord = progression * texCoord3 + ( unit - progression ) * texCoord1 ;
#ifdef HAS_COLORMAP
color *= texture2D(m_ColorMap, calculatedTexCoord);
#endif
color.x *= max(vertColor.x * m_SunlightIntensity,texCoord5.x);
color.y *= max(vertColor.y * m_SunlightIntensity,texCoord5.y);
color.z *= max(vertColor.z * m_SunlightIntensity,texCoord5.z);
color.a *= vertColor.a;
#ifdef HAS_COLOR
color *= m_Color;
#endif
#ifdef HAS_LIGHTMAP
#ifdef SEPARATE_TEXCOORD
color.rgb *= texture2D(m_LightMap, texCoord2).rgb;
#else
color.rgb *= texture2D(m_LightMap, texCoord1).rgb;
#endif
#endif
#if defined(DISCARD_ALPHA)
if(color.a < m_AlphaDiscardThreshold){
discard;
}
#endif
gl_FragColor = color;
}
Edit, the user reported their system as:
AMD Radeon R9 M370X
2048 MB
Intel Iris Pro 1536 MB
Which I think is an OpenGl2.1 system according to http://feedback.wildfiregames.com/report/opengl/device/Radeon%20R9%20M370X