3 spheres on a checkered plane causing me pain

Hello all,
I am trying to make a scene with three reflective spheres on a reflective checkered plane. I have setup the geometry using glut.

How i am going about it:

  1. Made the spheres usin glutSolidSphere and the plane with the simple quad. Geometry is shown ok.
  2. I am using color materials for the spheres and doing texturing for the plane.

Problems at hand:

  1. When i turn the texturing on, the plane is textured nicely however the spheres turn black.

Thing that is causing me pain:

  1. How would i make nice refletive colored spheres,textured reflective spheres and reflective plane using glut? Or is it impossible to do in glut?
    Would i have to write my own sphere routine?
  2. Can the spheres created with glutSolidSphere be textured?
    Thanx in advance
    MMM

while it says that glu (glu quadrics) spheres are texturable, I couldnt get it to work either.

they probably turn black because they dont have texcoords and you still have the texture from the plane bound when rendering the spheres.

reflection for the plane would be easier, there is a nvidia demo (really old) about using the stencil buffer to do flat reflections.
basically you render your objects from “below the plane” which is your reflection view, and then again from “normal view”
search thru developer.nvidia.com in their old gl sections you should find something
or just google for stencil buffer reflections or so.

making the spheres reflective will be trickier. basically requires you to render the scene in a cubemap from each sphere’s center.
ie 6 renders per sphere (up,down, left, right…)
and then you can use texgen reflectionmap.
to do all this you need to use the GL_ARB_texture_cube_map extension.

but since this isnt that easy, it’s likely better for the start to do just the reflective plane

Do you disable texturing once you finish off with the floor? You should. Enable texturing, draw floor, disable texturing. Post back if you still get black spheres.

Originally posted by CrazyButcher:
[b]while it says that glu (glu quadrics) spheres are texturable, I couldnt get it to work either.

they probably turn black because they dont have texcoords and you still have the texture from the plane bound when rendering the spheres.

reflection for the plane would be easier, there is a nvidia demo (really old) about using the stencil buffer to do flat reflections.
basically you render your objects from “below the plane” which is your reflection view, and then again from “normal view”
search thru developer.nvidia.com in their old gl sections you should find something
or just google for stencil buffer reflections or so.

making the spheres reflective will be trickier. basically requires you to render the scene in a cubemap from each sphere’s center.
ie 6 renders per sphere (up,down, left, right…)
and then you can use texgen reflectionmap.
to do all this you need to use the GL_ARB_texture_cube_map extension.

but since this isnt that easy, it’s likely better for the start to do just the reflective plane[/b]
Thanx CrazyButcher and dvm for the reply. yeah i have not assigned any texture coordinates nor do i turn it off after drawing the plane. Let me try it out again and i ll let you know.
One more thing is it possible to combine screen to world methoid within a world to screen method. I mean that the default manner is the projction style (world to screen) but is it possible for me t do screen to world for the three spheres to get nice raytraced reflection. If its pssible how?
Thanx
MMM

no unless you want to fully dive into programmable pipeline (glsl/cg) you wont be able to do raytracing.

the best you can do is create those cubemaps, and that is also what is normally done in most games you see (think of racing games…)

the curvature of the sphere is what makes it basically impossible, if you have flat surfaces then you can flip your projection and render a “reflection pass”

there is quite some papers about reflections at both nvidia and ati’s developer section

Originally posted by CrazyButcher:
[b]no unless you want to fully dive into programmable pipeline (glsl/cg) you wont be able to do raytracing.

the best you can do is create those cubemaps, and that is also what is normally done in most games you see (think of racing games…)

the curvature of the sphere is what makes it basically impossible, if you have flat surfaces then you can flip your projection and render a “reflection pass”

there is quite some papers about reflections at both nvidia and ati’s developer section[/b]
Thanx CrazButcher for that.
MMM

glu quadrics (gluSphere) should help you for texturing spheres.

Originally posted by jide:
glu quadrics (gluSphere) should help you for texturing spheres.
Thanx jide for that help I will peek into quadrics but can i make it reflective so that i see part of floor shinning on it? If so how?

Originally posted by MMMovania:
[quote]Originally posted by jide:
glu quadrics (gluSphere) should help you for texturing spheres.
Thanx jide for that help I will peek into quadrics but can i make it reflective so that i see part of floor shinning on it? If so how?
[/QUOTE]This seems another topic :wink:

Generally, you’ll need to use the stencil buffer. It’s very closed from projective shadow with stencil.

Originally posted by jide:
[b] [quote]Originally posted by MMMovania:
[quote]Originally posted by jide:
glu quadrics (gluSphere) should help you for texturing spheres.
Thanx jide for that help I will peek into quadrics but can i make it reflective so that i see part of floor shinning on it? If so how?
[/QUOTE]This seems another topic :wink:

Generally, you’ll need to use the stencil buffer. It’s very closed from projective shadow with stencil.[/b][/QUOTE]Roger that dude.
MMM

but you might adopt an environment map instead. What I said above might not be easily doable. Never done that thought.

When you draw the plane, do it after you’ve drawn the reflected spheres and add it with with glBlendFunc( GL_ONE, GL_ONE ), your reflections will not darken and it will look like more realistic reflections. You can then choose to darken the reflection using your choice of techniques.

Originally posted by dorbie:
When you draw the plane, do it after you’ve drawn the reflected spheres and add it with with glBlendFunc( GL_ONE, GL_ONE ), your reflections will not darken and it will look like more realistic reflections. You can then choose to darken the reflection using your choice of techniques.
Thanx dorbie for that. This is what i have done this far.
Created the reflective textured plane.
Crated the shiny spheres no reflections as yet cos i think its very difficult to do as pointed by some ppl.
Hey is there a good reference on reflective spheres? The type i am looking for is what you see in 3dsmax or other modelling programs having high specular and retraced reflections. Let me show you with the help of an image that i made in 3dsmax.

How does 3dsmax provide us with nice raytraced spheres while in a world to screen method? I am trying to figure this out but if someone has done this before you can share your experience here.

the renderer works a lot different in 3dsmax than what GL does

raytracing simply allows you to shoot rays thru the whole world, its really fairly easy method (harder to optimize so)

gl rendering doesnt do tracing alike, it “fills” transformed polygons. it doesnt send any rays.

if you do not take the “raytrace” material in 3dsmax but the “simple reflection maps” then you will see that max creates those cubemaps I talked about as well.

Originally posted by CrazyButcher:
[b]the renderer works a lot different in 3dsmax than what GL does

raytracing simply allows you to shoot rays thru the whole world, its really fairly easy method (harder to optimize so)

gl rendering doesnt do tracing alike, it “fills” transformed polygons. it doesnt send any rays.

if you do not take the “raytrace” material in 3dsmax but the “simple reflection maps” then you will see that max creates those cubemaps I talked about as well.[/b]
Roger that CrazyButcher, I got what you said.
But the thing that is still unclear is that how does 3dsmax combine raytraced reflections while doing projected polygons? I have written my raytracer very very simple one but it did reflections too. Can i combine it with opengl?
Sorry for bothering you but I am very interested in doing it.
Thanx
MMM

When it has to render a pixel which has a ‘raytrace’ material, 3dsmax traces the ray of this pixel to get its color (instead of filling polygon). Quite easy to switch render method on the fly because it is all done in software.

With OpenGL, I think there are 2 ways of doing this :

  1. for raytrace material use a GLSL shader able to do raytracing Example
    Beware, the inherent recursive nature of raytracing is very hard to do fully in current mainstream hardware pipeline.

  2. do the raytrace part in software with your own raytracer, then merge the raytraced part with OpenGL harware render. This project http://www.xl3d.com/xl3d/raytracing.htm seem to do this pretty well.

Originally posted by ZbuffeR:
[b]When it has to render a pixel which has a ‘raytrace’ material, 3dsmax traces the ray of this pixel to get its color (instead of filling polygon). Quite easy to switch render method on the fly because it is all done in software.

With OpenGL, I think there are 2 ways of doing this :

  1. for raytrace material use a GLSL shader able to do raytracing Example
    Beware, the inherent recursive nature of raytracing is very hard to do fully in current mainstream hardware pipeline.
  1. do the raytrace part in software with your own raytracer, then merge the raytraced part with OpenGL harware render. This project http://www.xl3d.com/xl3d/raytracing.htm seem to do this pretty well.[/b]
    Thanx ZBuffer for the wonderful information.
    MMM