ETM, Linux, Ogre 1.7.1, OpenGL

Teknoman117

15-07-2010 04:15:27

Well I am having some problems getting this working. Right off the bat I figured the Cg shaders would screw me over so I went and wrote some GLSL shaders to replace them. The one thing I couldn't find was the glsl companion for Cg's BLENDWEIGHT property. So here are the shaders I wrote. These should cover the more advanced functionality of ETM, but yet they still don't work. The screen is just blank with an Ogre head and an fps counter. Also another note, the saving files from the demo work. Everything except the ETterrain.png file looks correct.

PSLighting.glsl

uniform sampler2D lightMap;

void main (void) {
vec2 texcoord0;
texcoord0.x = gl_TexCoord[0].x;
texcoord0.y = gl_TexCoord[0].y;
gl_FragColor = texture2D(lightMap, texcoord0);
}


PSSplat.glsl

uniform sampler2D covMap1;
uniform sampler2D covMap2;
uniform sampler2D splat1;
uniform sampler2D splat2;
uniform sampler2D splat3;
uniform sampler2D splat4;
uniform sampler2D splat5;
uniform sampler2D splat6;

uniform float splatScaleX;
uniform float splatScaleZ;

void main (void) {
vec2 texcoord0;
texcoord0.x = gl_TexCoord[0].x;
texcoord0.y = gl_TexCoord[0].y;
vec4 cov1 = texture2D(covMap1, texcoord0);
vec4 cov2 = texture2D(covMap2, texcoord0);
texcoord0.x = texcoord0.x * splatScaleX;
texcoord0.y = texcoord0.y * splatScaleZ;
gl_FragColor = (texture2D(splat1, texcoord0) * cov1.x) +
(texture2D(splat2, texcoord0) * cov1.y) +
(texture2D(splat3, texcoord0) * cov1.z) +
(texture2D(splat4, texcoord0) * cov2.x) +
(texture2D(splat5, texcoord0) * cov2.y) +
(texture2D(splat6, texcoord0) * cov2.z);
}


VSLodMorph.glsl

uniform float delta;
uniform float morphFactor;

void main(void) {
//gl_Position.y = gl_Position.y + (delta * morphFactor); //Here is what I couldn't get working because I don't know what BLENDWEIGHT is
gl_Position = gl_Position * gl_ProjectionMatrix;
gl_TexCoord[0] = gl_MultiTexCoord0;
}


ETTerrain.material

material ETTerrainMaterial

{
technique {

pass
{
// splatting pass

lighting off

vertex_program_ref ET/Programs/VSLodMorph
{
}

fragment_program_ref ET/Programs/PSSplat
{
param_named splatScaleX float 20
param_named splatScaleZ float 20
}

texture_unit
{
// first coverage map, dynamically managed
texture ETSplatting0
}
texture_unit
{
// second coverage map, dynamically managed
texture ETSplatting1
}

// splatting textures
texture_unit
{
texture splatting0.png
}
texture_unit
{
texture splatting1.png
}
texture_unit
{
texture splatting2.png
}
texture_unit
{
texture splatting3.png
}
texture_unit
{
texture splatting4.png
}
texture_unit
{
texture splatting5.png
}
}

pass
{
// lightmap texture pass

scene_blend modulate

vertex_program_ref ET/Programs/VSLodMorph
{
}

fragment_program_ref ET/Programs/PSLighting
{
}

texture_unit
{
// dynamically created
texture ETLightmap
}

}
}

}


ETShader.program

fragment_program ET/Programs/PSSplat glsl

{

source PSSplat.glsl

}



fragment_program ET/Programs/PSLighting glsl

{

source PSLighting.glsl

}



vertex_program ET/Programs/VSLodMorph glsl

{

source VSLodMorph.glsl



default_params

{

param_named_auto morphFactor custom 77

}

}


I say again the demo still doesn't work but maybe this can help someone help me. At least I am trying.