PDA

View Full Version : 3 spheres on a checkered plane causing me pain



MMMovania
04-26-2005, 05:08 AM
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

CrazyButcher
04-26-2005, 06:34 AM
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

dvm
04-26-2005, 06:35 AM
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.

MMMovania
04-26-2005, 06:48 PM
Originally posted by CrazyButcher:
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 planeThanx 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

CrazyButcher
04-26-2005, 09:56 PM
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

MMMovania
04-27-2005, 12:25 AM
Originally posted by CrazyButcher:
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 sectionThanx CrazButcher for that.
MMM

jide
04-27-2005, 01:06 AM
glu quadrics (gluSphere) should help you for texturing spheres.

MMMovania
04-27-2005, 03:26 AM
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?

jide
04-27-2005, 06:50 AM
Originally posted by MMMovania:

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?This seems another topic ;)

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

MMMovania
04-27-2005, 07:38 AM
Originally posted by jide:

Originally posted by MMMovania:

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?This seems another topic ;)

Generally, you'll need to use the stencil buffer. It's very closed from projective shadow with stencil.Roger that dude.
MMM

jide
04-27-2005, 10:20 AM
but you might adopt an environment map instead. What I said above might not be easily doable. Never done that thought.

dorbie
04-27-2005, 02:18 PM
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.

MMMovania
04-27-2005, 07:41 PM
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.
http://www.geocities.com/mobeen211/openGL/sample.jpg
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.

CrazyButcher
04-27-2005, 11:30 PM
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.

MMMovania
04-28-2005, 01:37 AM
Originally posted by CrazyButcher:
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.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

ZbuffeR
04-28-2005, 02:33 AM
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 (http://ee.1asphost.com/vmelkon/glsl_raytracing.html)
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.

MMMovania
04-28-2005, 04:19 AM
Originally posted by ZbuffeR:
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 (http://ee.1asphost.com/vmelkon/glsl_raytracing.html)
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.Thanx ZBuffer for the wonderful information.
MMM