I've added a wind vertex shader to my game for the grass and trees:
!!ARBvp1.0
PARAM mv[4] = { state.matrix.modelview };
PARAM mv2[4] = { state.matrix.projection };
TEMP pos,projpos;
TEMP a;
################################
# Apply modelview transformation
DP4 pos.x, mv[0], vertex.position;
DP4 pos.y, mv[1], vertex.position;
DP4 pos.z, mv[2], vertex.position;
DP4 pos.w, mv[3], vertex.position;
################################
# Add wind offset proportional to the texture height
MUL a, program.local[0], vertex.texcoord[0].yyyy;
ADD pos.xz, pos, a;
################################
# Apply projection matrix
DP4 projpos.x, mv2[0], pos;
DP4 projpos.y, mv2[1], pos;
DP4 projpos.z, mv2[2], pos;
DP4 projpos.w, mv2[3], pos;
MOV result.position, projpos;
MOV result.texcoord[0], vertex.texcoord[0];
MOV result.color, vertex.color;
MOV result.fogcoord, vertex.fogcoord;
END
This works fine, I've a sinusoid local parameter, grass and tree foliage quad moves cool..
I've also added fragment program to enable OPTION ARB_fog_linear too, because adding a vertex program makes the fogstate switched off by default:
!!ARBfp1.0
OPTION ARB_fog_linear;
TEMP finalColor;
TEMP diffuse;
TEX diffuse, fragment.texcoord[0], texture[0], 2D;
MUL finalColor, fragment.color, diffuse;
MUL result.color, finalColor, fragment.color.primary;
The problem is that I've set fog state on the mesh but with all these vertex/fragment program state put on the mesh it doesn't do anything at all.
AFAIK the fog calculated by the hardware will be calculated based on the FogState parameters set to that mesh...but it doesn't seem to work!
Without the VP / FP it works....
Anyone with advice, experience? Is this some JME/GL bug, the fog state values are not correctly set for use with the shaders? Any response welcome and appreciated! :)