Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / How Are 3D Reflections Done Without Ray Tracing?

Author
Message
Dark Java Dude 64
Community Leader
14
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 12th Jul 2011 04:42
I have looked all over but the reflections i see on a lot of newer games i can t figure out. Everywhere i have seen online talks about reflections with ray tracing but none have talked about how it is done with polygon graphics.



Wolf
17
Years of Service
User Offline
Joined: 8th Nov 2007
Location: Luxemburg
Posted: 12th Jul 2011 05:05
Hmm...maybe an additional camera that renders the reflections ore a simple shader texture that gives you the illusion of a reflection.

I make serious coffee - so strong it wakes up the neighbors.
http://serygalacaffeine.deviantart.com/
Twitter:@Serygala
Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Dr Tank
16
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 12th Jul 2011 05:23
With a flat, or nearly flat object, you can do it with an extra camera.

Using the assumption that the shiny object is much smaller than the distance to the things reflected in it, you can do it with a cube map.

I guess for a large convex object you could maybe get a good approximation by moving the vertices of the reflected scene around, maybe using a vertex shader, but really you don't need that kind of accuracy.
Dark Java Dude 64
Community Leader
14
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 12th Jul 2011 06:18
Ahh, so cube mapping! It makes sense! But how much more computationally expensive is it to essentially 'take' six pictures around each object from it's viewpoint for each object for each frame so objects reflect other objects as well? I know having a static cube map for a room is computationally cheap, but moving objects cant reflect other objects. In other words, could each object get its own constantly updating cube map and still remain computationally cheap?



Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 12th Jul 2011 12:47
There's no way to do that in real time - maybe if each object uses 6 camera locations, then render 1 of those per loop - and as long as the frame rate is decent, you'd have a reasonable update. Usually there would only be a handful of reflective objects, so if there were 5 environment mapped objects, then that's 30 camera renders, a 60fps game would have all the environment maps done in half a second.

Health, Ammo, and bacon and eggs!
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th Jul 2011 13:15
The other thing to remember is that reflections don't usually need to be very accurate so relatively small cube map resolutions could be used.
Quik
16
Years of Service
User Offline
Joined: 3rd Jul 2008
Location: Equestria!
Posted: 12th Jul 2011 13:31
more accurate the closer the object is to it atleast

and for the record, I am a man.

CoffeeGrunt
17
Years of Service
User Offline
Joined: 5th Oct 2007
Location: England
Posted: 12th Jul 2011 13:37
UDK has a specialist reflection actor that's essentially a plane. It renders based on viewpoint and displays the texture on itself in editor, while streaming it to a file in game. You then use the streamed texture file in your material shader, and all the reflection vector calculations are done by the actor.

It looks amazing, but I haven't a scobby about the nitty-gritty of it's function.

Diggsey
19
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 12th Jul 2011 13:45
Also, you need only ever update three sides of the cube texture, as the other sides will be invisible, and you don't need to update them every loop.

[b]
Dark Java Dude 64
Community Leader
14
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 12th Jul 2011 20:38
Ahh, i see. So that means that if the maps were updating only every quarter to a half of second, reflections of things moving in the background would be choppy perhaps?



CoffeeGrunt
17
Years of Service
User Offline
Joined: 5th Oct 2007
Location: England
Posted: 12th Jul 2011 20:44
Well you could program the update rate based on distance, or size on screen would probably be better if zooming in is a capability.

There are many ways to cut back on this, e.g., if a cubemap object is off-screen or blocked by another object, don't update, etc, etc.

Dr Tank
16
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 12th Jul 2011 21:19
Quote: "Also, you need only ever update three sides of the cube texture,"

I disagree.
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 12th Jul 2011 21:22
Quote: "I disagree."


Why?

Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th Jul 2011 21:35
Quote: "Quote: "Also, you need only ever update three sides of the cube texture,"
I disagree."


So do I.

Quote: "Quote: "I disagree."

Why?"


Think about it.
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 12th Jul 2011 21:57
Quote: "Think about it."


I have been. I can't think of any way you could see more than 3 sides at once. D:

Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 12th Jul 2011 22:11
Only if your rendering cubes, otherwise you wouldn't know what sides are displayed on a 3D object. A sphere for example would need 5 sides to cover any viewing angle.

Health, Ammo, and bacon and eggs!
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th Jul 2011 22:14
Quote: "A sphere for example would need 5 sides to cover any viewing angle."


No. Six.

Which one do you think you don't need?

Quote: " I can't think of any way you could see more than 3 sides at once."


Keep thinking.
Dark Java Dude 64
Community Leader
14
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 12th Jul 2011 22:16
Lol take a pyramid with a flattened top and look at it from above-5 sides used.



Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 12th Jul 2011 22:22
Oh, I feel stupid now. I was thinking cube texture as in the texture of a cube, doh.

Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th Jul 2011 22:48 Edited at: 12th Jul 2011 23:08
Quote: "Lol take a pyramid with a flattened top and look at it from above-5 sides used"


Try Van B's sphere. You'll need six sides. Which don't you think you need?

Edit

Try this DBPro snippet:



IRMC.
Dark Java Dude 64
Community Leader
14
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 12th Jul 2011 23:08 Edited at: 12th Jul 2011 23:09
I see your point now, you do need 6 sides with a sphere!



A drew a little diagram, the red lines are the lines of sight. Is it what you meant? This represents four, the other side ones are easy to understand. xD



Attachments

Login to view attachments
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th Jul 2011 23:09
Quote: "Is it what you meant?"


Yes.
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 12th Jul 2011 23:28
OHH I wasn't aware THAT was how cube mapping worked. Although it makes very good sense. I guess I just wasn't really thinking about it


Why does blue text appear every time you are near?
Dark Java Dude 64
Community Leader
14
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 12th Jul 2011 23:34
Indeed it does make very good sense.



MrValentine
AGK Backer
14
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 31st Jul 2011 17:51
Shader no?

Dark Java Dude 64
Community Leader
14
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 1st Aug 2011 22:50
Yah, it likely is a shader to do all that, in fact yah, that would be way more efficient than my method; i would have the CPU handle getting different camera shots of the surroundings to make the cube map.


MrValentine
AGK Backer
14
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 1st Aug 2011 23:02
Speaking of cube maps, I tried using them with DarkCLOUDS and to be honest never got anywhere... I might search for DCForemans tutorials I think he did cover it once. if not could someone please fill the gap here? (for both DarkCLOUDS and general DBPro usage thanks)

Ocho Geek
17
Years of Service
User Offline
Joined: 16th Aug 2007
Location: Manchester, UK
Posted: 2nd Aug 2011 01:08 Edited at: 2nd Aug 2011 01:08

Goin' for the record are you?


Not Spanish, Not Eight, Just Ocho

MrValentine
AGK Backer
14
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 2nd Aug 2011 01:18
hehe i like you too Ocho

Speaking of Ray Tracing... is it possible inside DBPro? has anyone made anything for it before? (I suppose someone used DGDK)

Dark Java Dude 64
Community Leader
14
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 2nd Aug 2011 01:32
I dont think there are any functions or commands for ray tracing, however, if you would like to spend the rest of your life coding the very complex algorithms then i guess it would be possible.


Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 2nd Aug 2011 01:43
Most of the raytracers I've seen have been things people coded from scratch, not using any big fancy external library. So yeah, I'd say it would probably be as easy to write a raytracer in DBPro as in any other language.


Why does blue text appear every time you are near?
MrValentine
AGK Backer
14
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 2nd Aug 2011 01:47
thanks to both of you DBD and Neuro

I think I might at some point read into how raytracers work... I think its a nifty thing for reflections... must be an interesting idea if you could base an entire game on raytracing maybe?

I have a question on reflections... you know how you can have a characer in a game and parts of their armour for example is shiny... how? been pondering this one for a few months now...

Dark Java Dude 64
Community Leader
14
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 2nd Aug 2011 01:52
Makes sense.


Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 2nd Aug 2011 03:41
Raytracers aren't really practical for 3d game usage.

2d game usage though... (I'm still planning to do this, I just need to become a better programmer first xD)


Why does blue text appear every time you are near?
Dark Java Dude 64
Community Leader
14
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 2nd Aug 2011 04:14
Yes, VERY impractical for 3D stuff... Too bad the only good way to render picture perfect 3D scenes cant be used real time... Oh murphy's law!


Login to post a reply

Server time is: 2025-05-24 03:49:53
Your offset time is: 2025-05-24 03:49:53