I am following this thread:
topic393.html
(Various questions about shaders)
It’s quite helpful.
But now I have my own questions.
I am literally just copying thier example. Where i find my self stuck, is the actual glsl shader.
The given code, is missing a little bit. I got it semi-working, but just adding that to the PS part of the terrain, shader, while leaving everything.
But that doesnt mean i understand it.
I tried to trim it way down, since i assume it is only doing one task
glsl:
[code]#include “Uniforms.glsl”
#include “Samplers.glsl”
#include “Transform.glsl”
varying vec2 vTexCoord;
varying vec4 vWorldPos;
void VS()
{
mat4 modelMatrix = iModelMatrix;
vec3 worldPos = GetWorldPos(modelMatrix);
gl_Position = GetClipPos(worldPos);
vTexCoord = vec3(GetTexCoord(iTexCoord), GetDepth(gl_Position));
vWorldPos = vec4(worldPos, GetDepth(gl_Position));
}
void PS()
{
float cx = mod(vWorldPos.x,10);
float cz = mod(vWorldPos.z,10);
float e = 0.5;
if(!((cx > 10.0-e && cx < 10.0+e) || (cz > 10.0-e && cz < 10.0+e)) ) {//inside a square
float dist = max(abs(cx-5.0), abs(cz-5.0)) / 10.0;
if(dist > 0.8) dist * 0.5;
gl_FragColor = vec4(0.0, 0.0, 0.0, dist);
}else{ //outside a square
gl_FragColor = normalize(vec4(1.0, 1.0, 1.0, 0.0));
}
}[/code]
material xml:
<material>
<technique name="Techniques/TerrainBlend_B.xml" />
</material>
The errors i get the most are:
“unexpected NEW_IDENTIFIER, expecting $end” or
"unexpected ‘}’, expecting $end"
Just guessing, in all the shaders i notice a lot of ifthen blocks, but i have no idea what that is doing really
[code] #ifdef PERPIXEL
#ifdef SHADOW
…
#endif
#ifdef SPOTLIGHT
…
#endif
#ifdef POINTLIGHT
...
#endif
#else
#if defined(LIGHTMAP) || defined(AO)
...
#else
...
#endif
#ifdef NUMVERTEXLIGHTS
...
#endif
#ifdef ENVCUBEMAP
...
#endif
#endif[/code]
They dont seem to correlate to the technique or the material or render paths xmls.
Thanks everyone.