-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use texture matrix for heightmap transformation
Finally found the bug in my transformation code, I was multiplying the texture matrix and the texture coordinates in the wrong order.
- Loading branch information
Showing
3 changed files
with
33 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
#version 120 | ||
|
||
uniform sampler2D tex0; | ||
uniform mat4 texTransform; | ||
uniform float zoom; | ||
|
||
void main() | ||
{ | ||
gl_TexCoord[0] = gl_MultiTexCoord0; | ||
vec4 heightCoord = gl_TexCoord[0] * texTransform; | ||
vec4 heightColor = texture2D( tex0, heightCoord.st); | ||
gl_FrontColor = gl_Color; | ||
gl_Position = ftransform(); // gl_ModelViewProjectionMatrix * gl_Vertex; | ||
gl_Position.y += heightColor.r * 20.0 * (1.0 - zoom); | ||
vec4 heightCoord = gl_TextureMatrix[0] * gl_TexCoord[0]; | ||
vec4 heightColor = texture2D( tex0, heightCoord.st ); | ||
gl_FrontColor = gl_Color; // try: heightColor; | ||
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; | ||
gl_Position.y += heightColor.r * 20.0 * ( 1.0 - zoom ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters