Rauy wrote:
You just answered your second question with your first. As Horde3D does not use the builtin gl_ModelView... but its own ones, you need to use these.
Thanks - that was it. Got my billboard shader to work (even though it is not perfect). For some reason though I had to interchange the z- and the x-axis between OpenGL and Horde3D.
Code:
[[FX]]
sampler2D albedoMap;
context AMBIENT {
VertexShader = compile GLSL VS_GENERAL;
PixelShader = compile GLSL FS_GENERAL;
}
[[VS_GENERAL]]
uniform mat4 viewProjMat; // gl_ModelViewProjectionMatrix
uniform vec3 viewerPos; // ?
attribute vec2 texCoords0; // gl_MultiTexCoord0
attribute vec3 vertPos; // gl_Vertex
varying vec4 pos; // ?
varying vec4 vsPos; // ?
varying vec2 texCoords; // gl_TexCoord[0]
uniform mat4 viewMat;
uniform mat4 worldMat;
uniform mat3 worldNormalMat;
void main(void) {
// GL2: gl_TexCoord[0] = gl_MultiTexCoord0;
texCoords = texCoords0;
// GL2: gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
pos = worldMat * vec4(vertPos, 1.0);
vsPos = viewMat * pos;
//gl_Position = viewProjMat * pos;
// Billboard the model instead
gl_Position = viewProjMat*vec4(
pos.z*vec3( viewProjMat[0][0],
viewProjMat[1][0],
viewProjMat[2][0]) +
pos.y*vec3( viewProjMat[0][1],
viewProjMat[1][1],
viewProjMat[2][1]),
1.0);
}
[[FS_GENERAL]]
uniform sampler2D albedoMap;
varying vec2 texCoords;
void main(void) {
vec3 newCoords = vec3( texCoords, 0 );
newCoords.t *= -1.0; // HACK flip the texture orientation
vec4 albedo = texture2D( albedoMap, newCoords.st );
gl_FragColor.rgb = albedo.rgb;
}
Rauy wrote:
To the first: All these user-defined uniforms and attributes are just a bit more forward compatible, as they removed all the deprecated stuff (including builtin uniforms and attributes) from the core in GL3/4 (although with GL2 it would still be fine, but this way Horde is more future ready).
Aha!
But a google search for e.g. "viewProjMat glsl" only returns 7 hits and no hints about OpenGL3/4 - so the naming is Horde3D arbitrary? But why is it different from the old names? And why is "gl_FragColor" still intact?
I wish there was a translation table for these names in the documentation so I can apply my new shaders to Horde3D. The only shader sample on the whole net that works with Horde3D is "model.shader" - and that is actually 5 shaders in one and has few comments. :/
Rauy wrote:
The ATTRIBPASS is there for rendering the models attributes into the G-buffer in the deferred pipeline. Consult a tutorial on deferred rendering for more insight.
Again, a search for ATTRIBPASS returned only Horde3D related sourcecode. I guess I just wish there were more examples that came with Horde3D so I could understand better what was going on.
[Edit]
Thanks a lot for the help MistaED! I saw your post when I clicked "submit". I am a slow writer.
Your version is nicer than mine and your comments help. Thank you!