Jump to content

  • Log In with Google      Sign In   
  • Create Account

VTF with GLSL 1.2


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 MARS_999   Members   -  Reputation: 1297

Like
0Likes
Like

Posted 10 January 2014 - 07:53 PM

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;
}


Sponsor:

#2 MARS_999   Members   -  Reputation: 1297

Like
1Likes
Like

Posted 10 January 2014 - 08:21 PM

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;
}





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS