Author Topic: Planar Reflection using reflection matrix  (Read 5768 times)

0 Members and 1 Guest are viewing this topic.

rrarunan

  • Associate
  • Posts: 6
Planar Reflection using reflection matrix
« on: March 05, 2006, 07:10:02 PM »
Hi guys

   I'm trying to do planar reflection on water and then projective texture the environment onto the water mesh. The tutorial on realistic water by Yann Lombard at gamedev.net was my reference. http://www.gamedev.net/columns/hardcore/rnerwater1/page3.asp .. I just want to know how exactly you bind your scene to the frame buffer..


 I have been using GenFramebuffersEXT and I'm getting segmentation fault errors.. I don't know why..  

Arunan

Groove

  • Soldier
  • **
  • Posts: 51
    • http://www.g-truc.net
Planar Reflection using reflection matrix
« Reply #1 on: March 06, 2006, 04:58:22 PM »
What kind of render to texture do you use ? Texture 2D ou texture rectangle ? On ATI and nVidia cards I got some problem with render texture rectangle. (Like computer reboot)

Have you tried using NPOT texture 2D ? It should work well but on GeForce 6*** and Radeon X*** at least.

PS: Why do you want to use render to texture for this ? Actually you don't really need it. (I haven't read your reference so maybe)

I have something like that:

Code: [Select]
       if(RenderWater)
        {
            m_Water->enable();
            m_SunLight->enable(AMBIENT | DIFFUSE | SPECULAR);
                m_ReflectRenderer->render(m_Geometry, m_Fog, terrain::RENDER_MODE_REFLECT);
            m_SunLight->disable();
            m_Water->disable();

            m_Water->render(m_Fog);
        }

         m_SunLight->enable(AMBIENT | DIFFUSE | SPECULAR);
            m_DefaultRenderer->render(m_Geometry, m_Fog, terrain::RENDER_MODE_TEXTURE);
        m_SunLight->disable();


I render first the terrain with the reflected matrix with front face culling.
Then I render the terrain with common model matrice with back face culling.

I did something wish render to texture for rendering fog and multi lights only.

rrarunan

  • Associate
  • Posts: 6
Planar Reflection using reflection matrix
« Reply #2 on: March 06, 2006, 11:30:57 PM »
I'm using Texture2D.. and I'm planning to project it on the surface of the water mesh.. that I'm perturbing, with sum of sin functions in the vertex shader..


That's why I need to render to texture for fragment shader processing..


and by the way, I am using OpenGL  + GLSL and SDL for the window...

 :o

rrarunan

  • Associate
  • Posts: 6
I got the rendered.. texture..
« Reply #3 on: March 06, 2006, 11:33:58 PM »
And.. I got the render to texture working..  Now, I'm having problems with projective texturing on the fragment shader..

Any body have any ideas.. on projective texuring my 2D texture on to a triangulated mesh.. (I use an object loader.. www.evl.uic.edu/rlk/obj/obj.html)..

 :?   :?:

JeGX

  • Global Moderator
  • Capo Crimine
  • *****
  • Posts: 2357
    • oZone3D.Net
Planar Reflection using reflection matrix
« Reply #4 on: March 07, 2006, 08:25:21 AM »
Just some questions/suggestions:
- do you use the texture matrix in your vertex shader to calculate the right per-vertex texture coordinates ?
- and in your pixel shader, do you call texture2DProj() ?

JeGX

  • Global Moderator
  • Capo Crimine
  • *****
  • Posts: 2357
    • oZone3D.Net
Planar Reflection using reflection matrix
« Reply #5 on: March 07, 2006, 08:47:53 AM »
You can also check the Static AO Tutorial.
There is a water shader with texture projection.