Pages: [1]
  Print  
Author Topic: OpenGL, reflections, and shameless hacks  (Read 15754 times)
hermitian
Ok i've posted twice!


Cakes 0
Posts: 2


« 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) 
Logged
hermitian
Ok i've posted twice!


Cakes 0
Posts: 2


« Reply #1 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
Logged
Hitchhiker
Member


Cakes 11
Posts: 181


« Reply #2 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.  Smiley

Logged
grey matter
Member


Cakes 8
Posts: 381

>9k


« Reply #3 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.
Logged

This space is for rent.
fromhell
Administrator
GET A LIFE!
**********

Cakes 35
Posts: 14520



WWW
« Reply #4 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.
Logged

asking when OA3 will be done won't get OA3 done.
Progress of OA3 currently occurs behind closed doors alone

I do not provide technical support either.

new code development on github
Suicizer
Member
Member
*

Cakes 2
Posts: 402


WWW
« Reply #5 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.
« Last Edit: October 24, 2012, 11:48:23 AM by Suicizer » Logged

I'm good at everything but can't do anything...
fromhell
Administrator
GET A LIFE!
**********

Cakes 35
Posts: 14520



WWW
« Reply #6 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
Logged

asking when OA3 will be done won't get OA3 done.
Progress of OA3 currently occurs behind closed doors alone

I do not provide technical support either.

new code development on github
Pages: [1]
  Print  
 
Jump to: