Hello World ;-) ,
I have a problem with accessing textures in my fragment shader program.
I want to access the texture, but not at the fragment's current
position. Normally, the program looks up the texture at the specified
fragment texture coordinates stored in gl_TexCoords[0]. But I want to
get texture values from other coordinates.
Example:
Normal you do:
vec4 myFragColor = texture2D (myTexture, vec2 (gl_TexCoords[0]));
gl_FragColor = myFragColor;
But I want to do:
float texSize = 256.0;
float x = xpos / texSize;
float y = ypos / texSize;
vec4 myFragColor = texture2D (myTexture, vec2 (x, y));
gl_FragColor = myFragColor;
Now my Problem:
When I choose xpos and ypos as fixed values (e.g. xpos = 50.0, ypos =
100.0), I have no problem. I get exactly the color at the specified
coordinates (50,100) in the texture.
But when I choose xpos and ypos to be variable (what I want to achieve),
I get everytime, when I start my application, different color values.
The funny thing is, that I have everytime the same (correct) texture
coordinates. Sometimes I get the correct color values, but mostly I get
the wrong values.
I tested it with the following code (I can take x and y as color values):
gl_FragColor = vec4 (myFragColor.x, x, y, 1.0);
Has anyone an idea?
Oliver
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users