Hi,
Is there a way to turn off perspective correction to have a linear interpolation for UV mapping like the following OGL line would do but using only Irrlicht lib ?
=> glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
I'm doing some kind of postprocess on a 3D model render and I would like to work in screen space.
Thanks.
[solved] Turn off perspective correction, OGL
[solved] Turn off perspective correction, OGL
Last edited by stefbuet on Sun Sep 09, 2012 4:58 pm, edited 1 time in total.
CuteAlien wrote:coders are well-known creatures of the night
Re: Turn off perspective correction, OGL
Use a shader?
(I seem to write this a lot lately...)
(I seem to write this a lot lately...)
Re: Turn off perspective correction, OGL
I'm already using a shader...
Instead of rendering my post process with a screen quad, I'm rendering it with a 3D model to cover less pixels for a particular application.
For each vertex I'm sending the screen space coordinate to the pixel shader in gl_TexCoord data. For each pixel I need this interpolated coord in the pixel shader to be the real one on the screen, and perspective correction doesn't allow this.
I just need to turn off the perspective correction like the previous GL instruction.
Instead of rendering my post process with a screen quad, I'm rendering it with a 3D model to cover less pixels for a particular application.
For each vertex I'm sending the screen space coordinate to the pixel shader in gl_TexCoord data. For each pixel I need this interpolated coord in the pixel shader to be the real one on the screen, and perspective correction doesn't allow this.
I just need to turn off the perspective correction like the previous GL instruction.
Last edited by stefbuet on Sun Sep 09, 2012 1:29 am, edited 1 time in total.
CuteAlien wrote:coders are well-known creatures of the night
Re: Turn off perspective correction, OGL
maybe using the instruction texture2Dproj? it is what performs the perspective corrected texture sampling. though, i don't know how can you tweak the variables to achieve the proper effect
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Re: Turn off perspective correction, OGL
You can get the pixel-wise coordinate from gl_FragCoord.xy. Divide that by the screen resolution to get it in 0-1 range.
http://www.opengl.org/sdk/docs/manglsl/ ... gCoord.xml
BTW, sounds like light volumes?
http://www.opengl.org/sdk/docs/manglsl/ ... gCoord.xml
BTW, sounds like light volumes?
Re: Turn off perspective correction, OGL
Thanks a lot. gl_FragCoord was pretty usefull ^^
Yep Hendu that's for light volumes. With the sphere I didn't notice the distortion but for spot lights the cone meshes had pretty tall polygons. It's ok now
Yep Hendu that's for light volumes. With the sphere I didn't notice the distortion but for spot lights the cone meshes had pretty tall polygons. It's ok now
CuteAlien wrote:coders are well-known creatures of the night
Re: [solved] Turn off perspective correction, OGL
excuse me, light volumes? how?
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Re: [solved] Turn off perspective correction, OGL
I'm doing them too, pretty simple What do you want to know?
Re: [solved] Turn off perspective correction, OGL
@Mel
That's light volumes for deferred lighting: Instead of computing the whole lighting on a quad as a post process effect, we use spheres or cones to avoid computing too much pixels. You can use the stencil buffer to computer (in 2 pass) only pixels inside of the light volume, but I'm doing it in 1 pass with frontface culling enabled and Ztest set to greater. I saw that using the stencil to compute inside only pixels is not worth it.
That's light volumes for deferred lighting: Instead of computing the whole lighting on a quad as a post process effect, we use spheres or cones to avoid computing too much pixels. You can use the stencil buffer to computer (in 2 pass) only pixels inside of the light volume, but I'm doing it in 1 pass with frontface culling enabled and Ztest set to greater. I saw that using the stencil to compute inside only pixels is not worth it.
CuteAlien wrote:coders are well-known creatures of the night
Re: [solved] Turn off perspective correction, OGL
I thought you were speaking of some sort of volumetric light scattering, sometimes i've called that "volume lights" that is why i didn't understood it at the beginning ^^U my bad, thanks.
If i am not mistaken (or gl works other way) you can get the pixel position by dividing the result of the glTransform() by the w component. (i.e. the result is a 4 component vector, x/w, y/w is the normalized device position of the vertex) dividing it by 2 and adding 0.5 should provide the correct coordinates in the 0-1 range. the good thing is that these values have the projection taken into consideration, so they should become the correct screen coordinates, in the worst case, maybe the y coordinate should be inverted, but i think it is a correct result.
If i am not mistaken (or gl works other way) you can get the pixel position by dividing the result of the glTransform() by the w component. (i.e. the result is a 4 component vector, x/w, y/w is the normalized device position of the vertex) dividing it by 2 and adding 0.5 should provide the correct coordinates in the 0-1 range. the good thing is that these values have the projection taken into consideration, so they should become the correct screen coordinates, in the worst case, maybe the y coordinate should be inverted, but i think it is a correct result.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt