Volumes Of Fun http://www.volumesoffun.com/phpBB3/ |
|
Texturing + OpenGL http://www.volumesoffun.com/phpBB3/viewtopic.php?f=2&t=87 |
Page 1 of 1 |
Author: | David Williams [ Thu Nov 11, 2010 9:34 pm ] |
Post subject: | Re: Texturing + OpenGL |
Well, you are one the right path. I'm assuming the back faces are also textured, so that you have 2 faces textured and 4 faces not textured? In order to texture all the faces you need to sample you texture map three times. That means you need three seperate calls to 'texture2D', and for each call you have to pass in a different set of texture coordinates. One set of coordinates is for XY, one is for XZ, and one is for YZ. Then you should have faces on all sides but they will be overlapping and mixing together. You need to use the surface normals to fix this. But get the first part working first... |
Author: | Metanoia [ Thu Nov 11, 2010 10:20 pm ] |
Post subject: | Re: Texturing + OpenGL |
Thanks David! Your answer put me in the right path and now I can texture all the faces switching between Code: gl_FragColor = texture2D(tex, gl_TexCoord[0].xy); Code: gl_FragColor = texture2D(tex, gl_TexCoord[0].xz); and Code: gl_FragColor = texture2D(tex, gl_TexCoord[0].yz); Now I only need to be able to determine which direction is facing each pixel in the fragment shader. I know how to do it using normals, but I can't get to work the normals generation code i saw in other post, since I am still a begginer at GLSL. I could switch to the CubicSurfaceExtractorWithNormals, but I really like the way the new CubicSurfaceExtractor works, so I would love to be able to calculate the normals in my shaders. Thanks you again for your time! |
Author: | David Williams [ Thu Nov 11, 2010 10:28 pm ] |
Post subject: | Re: Texturing + OpenGL |
The code fragment I posted was Cg, unfortunatly I don't know GLSL so I can't convert it. But I'm sure if you ask on an OpenGL forum then someone will be able to help you... In the mean time you should probably try the CubicSurfaceExtractorWithNormals, at least you can then makes sure the rest of your code works properly. |
Author: | David Williams [ Fri Nov 12, 2010 8:46 pm ] |
Post subject: | Re: Texturing + OpenGL |
Excellent, I'm glad you got it working ![]() |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |