OpenArena Message Boards

OpenArena Contributions => Graphics => Topic started by: hermitian on July 19, 2012, 06:24:58 PM



Title: OpenGL, reflections, and shameless hacks
Post by: hermitian on July 19, 2012, 06:24:58 PM
Hi, I'm Hermitian, this is my first time posting here. 

I've been reading about 3D graphics lately, I've had some experience with OpenGL.  I have a very simple 3D FPS Engine that I've been writing lately.  One of the things that is most often quoted regarding OpenGL is that it doesn't handle reflections, however I've seen reflections done using OpenGL, so I wondered how THAT was done?  Well, after poking around I saw that the solution involved creating a stencil, and projecting the object you wish to reflect onto the surface of whatever you are reflecting onto and simply shading in the stencil with the shape of the object that you are reflecting.  That was discouraging... it's not a direct simulation of the light's behavior, it's just a 'shameless' hack. I assume this is probably done for efficiency reasons.  A true ray trace simulation would likely be more computationally expensive than what OpenGL does.  Does anyone here have experience with this?  Am I barking up the wrong tree?

(Note:  I thought this was pertinent to the Graphics portion of the forum because the id tech 3 engine used OpenGL) 


Title: Re: OpenGL, reflections, and shameless hacks
Post by: hermitian on July 19, 2012, 06:39:38 PM
Here I am posting all of this without references like some kind of a cave fungus (my bad), this is what I've been going on about:

(Example 1) 
http://www.swiftless.com/tutorials/opengl/basic_reflection.html

(Example 2)
http://www.videotutorialsrock.com/opengl_tutorial/reflections/home.php


Title: Re: OpenGL, reflections, and shameless hacks
Post by: Hitchhiker on July 20, 2012, 02:11:49 PM
Hi,

I'm not sure if this is the right place to post your question. Some internet forums specialized in opengl might be a better place to get an answer.

but if it can help (I'm no expert)...

reflections ... it is what a graphics engine needs to simulate (be it based on opengl, directx, ...). Even raytracing graphics engine would be doing the needed operations to calculate the reflected eye-ray and the final correct color of the pixel at certain screen location.

I'm not aware of any 'magic' solution for this unless you are using a ready-made graphics engine.. but this I think is not what you want to do.

There are different ways of having the reflections (stencil, cubemaps, ...) and you need to see where and what for you want to use the reflections to be able to pick the right method.

Try googling a bit more and have fun building your own solutions to these kind of problems.  :)



Title: Re: OpenGL, reflections, and shameless hacks
Post by: grey matter on July 21, 2012, 08:01:04 AM
I have no experience with OpenGL, but there are Raytracing projects on top of Quake 3.
Here's an old news post about Raytracing ioquake3 (http://ioquake3.org/2008/03/04/raytracing-ioquake3/).


Title: Re: OpenGL, reflections, and shameless hacks
Post by: fromhell on September 21, 2012, 07:50:10 PM
For a performance-demanding game I don't think raytracing would be appropriate.


Darkplaces gained support for cubemap reflections a couple years ago, peeking in there could be a good idea.


Title: Re: OpenGL, reflections, and shameless hacks
Post by: Suicizer on October 24, 2012, 11:23:06 AM
Wait wasn't Quake 3 already having relfections on default? What's the mirror-like ceiling on q3ctf2 at the MH then?

Well, I don't want to advertise actually, but Cube Engine 2 has a mod (called "tesseract") which has as the developer states "screen-space water reflections" (originally, Cube Engine 2 already had reflections in the water, but on a sort of cheaper way) . However, as far ad I know it's done all in glsl (in the mod). Maybe the source code could be usefull as it's ZLIB-licensed.


Title: Re: OpenGL, reflections, and shameless hacks
Post by: fromhell on October 24, 2012, 03:06:13 PM
The problem with Q3's reflections is that it requires camera entities, and it's another view, rather than a render-to-texture.  This limits things such as having translucent reflections