Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Reflections

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2000
    Posts
    29

    Reflections

    Ok, there are 2 questions I want to ask about reflections:

    1) What is a sphere map. I looked at all the tutorials and from what I here it can only reflect bitmap images but not any rendered scenes such as rendered quads, polygons etc.. Please explain in detail if possible. Other tutorials seem to give me misconceptions.

    2) Is there any way to just have a relective material that relects everything in the scene (ex. the way Pov-Ray does it) without the planar reflection techniques. It seems to make programming a little more hectic if I have to do that for every object and every plane .

    Thanks
    cwhite40

  2. #2
    Guest

    Re: Reflections

    No, OpenGL cannot "automatically" create
    reflections for you. OpenGL just draws the
    one triangle (or quad, or strip) that you
    ask it to, with exactly the texture, color
    and lighting you ask it to. OpenGL only
    uses information knowable to it in that
    instance.

    Yes, you have to do all the extra
    calculations and multiple render passes to
    get reflection into your engine. What's
    worse, OpenGL doesn't (yet?) support the
    cubic environment mapping way of doing
    reflections, which is easier to set up and
    create using hardware rendering (basically
    you render from the point-of-view of the
    reflective "thing" into an area which you
    then turn around and use as a texture).

    Good luck! As you say, it can become
    "hectic".

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2000
    Posts
    9

    Re: Reflections

    OpenGL support cubic environment mapping with GL_ARB_texture_cube_map.
    The core(without extensions) OpenGL supports SPHERE_MAP texture generation (predominantly used for environment mapping and not actual reflections).There is extensions like GL_NV_texgen_reflection which make the life easier ,but doing your own math is (almost always ) faster in current hardware.
    The most optimal way to get a reflection-mirror is to draw your geometry, flip an axis and redraw the geometry (with optional stencil testing for optimal performance ).
    Forget what you have learned from Pov-Ray

  4. #4
    Junior Member Newbie
    Join Date
    Jul 2000
    Posts
    29

    Re: Reflections

    Yes I know that method but it seems to be limiting. For example, what if say you wanted to put a reflection of the scene onto a cylinder, sphere, or torus. Do you have any code ( please any ) that could clarify this?

    cwhite40

  5. #5
    Junior Member Newbie
    Join Date
    Aug 2000
    Posts
    9

    Re: Reflections

    My method works only with planes .If you want reflection on a arbitrary shape ,then you have to render your scene(from the point-of-view of the
    reflective "thing" as bgl said) to a texture(read the color buffer and store it as a texture) and map that texture to the sphere(here is the SPHERE_MAP texgen mod ) or the other shape. But this is very slow because each frame you upload a new texture to the hardware.

  6. #6
    Junior Member Newbie
    Join Date
    Jul 2000
    Posts
    29

    Re: Reflections

    Any code/websites for that?

    cwhite40
    coffee

  7. #7
    Junior Member Newbie
    Join Date
    Aug 2000
    Location
    New Orleans, La, USA
    Posts
    14

    Re: Reflections

    I just figured out a pretty crap way to make a reflection. I had a 3D cube with a reflection off of a floor. First I rendered the cube then I made the floor using GL_QUADS and I added some blending to make it transparent and then I rendered the same exact 3D cube except that i put directly under the original cube and the floor, to make a "reflection." Oh yeah I used blending for the second square too.

    Hope this helps somebody

  8. #8
    Junior Member Newbie
    Join Date
    Aug 2000
    Posts
    9

    Re: Reflections

    The Nvidia site(http://www.nvidia.com/Developer.nsf) have a heavy load of examples .
    Keep in mind that the reflections around spheres, cylinders etc are called environment mapping .The reflection term is used for planar reflections.
    I’m clearing that to help you find the right document.

  9. #9
    Junior Member Newbie
    Join Date
    Jul 2000
    Posts
    29

    Re: Reflections

    Ok about the above messages... I used a program called blender which uses the above methods for "reflections". I know what you mean but does anyone have code to make a rendered scene a texture? Also as a second question related to that does anyone also have an OpenGL scene to Bitmap/tga/whatever code? For instance rendering a scene to a bitmap/tga/whatever?

    cwhite40

  10. #10
    Junior Member Newbie
    Join Date
    Aug 2000
    Location
    New Orleans, La, USA
    Posts
    14

    Re: Reflections

    I haven't tried it with a texture yet. Nehe has a tutorial about loading tga files. the url is http://nehe.gamedev.net

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •