Results 1 to 5 of 5

Thread: Faded reflection...

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2010

    Faded reflection...

    I have a cube that i have drawn a reflection for using the stencil buffer. I am using tutorial 26. The problem i have is that the reflection is a full length one. I am trying to create a reflection effect similar to ipod/apple coverflow thing. Anyone know how to achieve a faded out reflection? added an example below....faded refelection part is what i am looking for, i have got the reflection itself working.

  2. #2
    Super Moderator OpenGL Guru imported_dorbie's Avatar
    Join Date
    Jul 2000
    Bay Area, CA, USA

    Re: Faded reflection...

    Technically the reflection intensity is governed by Fresnel's law.

    For your scene you could render the reflective surface black with transparency as a function of View.Normal for the reflective surface and generate an effect similar to coverflow. Alternatively you could calculate what the modulation should be per vertex or pixel as you render the cube, that should be possible for a simple planar surface.

    Coverflow just draws quads with fixed black vertices so it's a trivial (and incorrect) hack.

    In the book "More OpenGL Game Programming" Chapter 8, I describe and implement the equations necessary to get the reflection (and refraction) coefficients correct to modulate reflective and refractive terms.

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2010

    Re: Faded reflection...

    Let me be sure i know what you mean...

    Your first method means the dot product between the reflective surface normal and the vector to the camera( normalised), the dot product is then passed to glColor4f(0.0f,0.0f,0.0f,fDotProductHere); of the reflective surface?

    Your second method is the code below, where when i render the cube to the stencil buffer i apply a color per vertex with an alpha value, thus allowing me to fade out the cube reflection. for the normal render pass of the cube, i disable the color values. Will glColor4f() alpha value work on textures?

    Code :
    glBegin(GL_TRIANGLES);						glColor4f(1.0f,0.0f,0.0f,1.0f);			
    glVertex3f( 0.0f, 1.0f, 0.0f);					glColor4f(0.0f,1.0f,0.0f,1.0f);			
    glVertex3f(-1.0f,-1.0f, 0.0f);			glColor4f(0.0f,0.0f,1.0f,1.0f);			
    glVertex3f( 1.0f,-1.0f, 0.0f);			

  4. #4
    Senior Member Regular Contributor
    Join Date
    Feb 2004

    Re: Faded reflection...

    For your example without using shaders and a black background you can simply set the vertex color of your top vertices to black (in your stencil pass).
    The interpolated vertex colors will be multiplied by your texture color, giving you a linear blend to black.

  5. #5
    Junior Member Newbie
    Join Date
    Jan 2010

    Re: Faded reflection...

    Thanks for the reply, will try that.

Similar Threads

  1. Reflection Problem
    By Asura in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 04-21-2006, 03:18 PM
  2. Reflection vector
    By SeskaPeel in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 10-06-2003, 08:32 AM
  3. I want to add reflection but need an advice
    By Leyder Dylan in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-28-2003, 08:50 AM
  4. -> Reflection
    By Erakis in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-16-2002, 02:48 AM
  5. Opengl faded with lines problem
    By in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 06-18-2001, 04:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean