• Advertisement
Sign in to follow this  

VTF with GLSL 1.2

This topic is 1469 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am having an issue with getting VTF to work... From what I can tell and been told if I see pick with this example code it works. I do see a pink image but I can't offset my height value on Y axis from a texture read? Not sure what I am doing wrong...

uniform sampler2D displacementMap;
void main()
{
vec4 dv = texture2DLod(displacementMap, vec2(0.0), 0.0);
gl_FrontColor = dv;
gl_Position = ftransform();
}

Here is the code I use to make the Y axis offset and doesn't work...

uniform mat4 mWorldViewProj;
uniform sampler2D displacementMap;
void main()
{
vec4 dv = texture2DLod(displacementMap, vec2(0.0), 0.0);
float df = 0.30*dv.x + 0.59*dv.y + 0.11*dv.z;
//vec4 newVertexPos = vec4(gl_Normal * df * 2.0, 0.0) + gl_Vertex;
//tried the newVertexPos above doesn't work either...
vec4 newVertexPos = gl_Vertex.y + dv.r;
gl_Position = mWorldViewProj * newVertexPos;
}

Share this post


Link to post
Share on other sites
Advertisement

Nevermind ugh been so dam long since I coded getting rusty... I was using the second texture unit and not selecting gl_MultiTexCoord1 vs. gl_MultiTexCoord0....

 

Updated code now it works!!!!

 
#version 120
uniform mat4 mWorldViewProj;
uniform mat4 mInvWorld;
uniform mat4 mTransWorld;
uniform vec3 mLightPos;
uniform vec4 mLightColor;
uniform sampler2D displacementMap;
 
void main()
{
vec4 dv = texture2DLod(displacementMap, vec2(gl_MultiTexCoord1), 0.0);
//float df = 0.30*dv.x + 0.59*dv.y + 0.11*dv.z;
//vec4 newVertexPos = vec4(gl_Normal * df * 2.0, 0.0) + gl_Vertex;
vec4 newVertexPos = gl_Vertex + vec4(0.0, dv.y, 0.0, 0.0);
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = mWorldViewProj * newVertexPos;
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement