Simulating reflections

A forum to store posts deemed exceptionally wise and useful
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

NOTE: The demo requires PS2.0. I'm afraid PS1.x can't handle the shader code. :cry:

The demo's done. I'm cleaning up the code before posting it.
omaremad
Competition winner
Posts: 1027
Joined: Fri Jul 15, 2005 11:30 pm
Location: Cairo,Egypt

Post by omaremad »

Nice work sio, unlucky about that opengl annoyances (im still working with .09 i think ....or version .14)

The ony bad thing i see compared to other method is aliasing, maybe a guassian filter might hide it, or if thats too slow, buffer the last frame's texture too, then multiply that with the current frames's texture but each frame sort of "wiggle" the fov or the rotation of the camera, this way you sort of have a free antialiasing on your reflection texture.

looking forward to the demo :)
"Irrlicht is obese"

If you want modern rendering techniques learn how to make them or go to the engine next door =p
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

sio2 wrote:NOTE: The demo requires PS2.0. I'm afraid PS1.x can't handle the shader code. :cry:

The demo's done. I'm cleaning up the code before posting it.
Doh! Forgot to add the lighmap to the mix. Just adding some code to blend the lightmap with the floor and reflection textures. 8)
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

Added the lightmap. The floor now has the wood texture, reflection texture and lightmap texture all blended together.

I'd post a screenshot, but I'm afraid that someone might die from excitement upon viewing it; it looks that cool. 8)

:mrgreen:
omaremad
Competition winner
Posts: 1027
Joined: Fri Jul 15, 2005 11:30 pm
Location: Cairo,Egypt

Post by omaremad »

Show the pic, it was a bit weird since your first pic didnt look like afcielies's one even though it should yeild the same results.

Btw how did you apply the shader to the floor only? is it in a sperate meshbuffer or saved as a diffrent mesh? or is the whole thing "shadded" with some flag telling it to go into floor mode
"Irrlicht is obese"

If you want modern rendering techniques learn how to make them or go to the engine next door =p
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

aaaaaaaarrrrrrrrrrrrrrrrrrrrrrgggggggggggggggghhhhhhhhhhhhhhhhhh!!!!
show me the piiiiiiiiiiiiicccccccccccccccccccccccc!!!! :twisted: :twisted: :twisted:
or take me to a cliniiiiiiiiiiiiiiiiiiiiiiiiiiiccccccccccccccccccccccccccc!!!!

heheheheh :wink:
Omar and Sio, I bet you guys are having fun , huh? ;)
omaremad
Competition winner
Posts: 1027
Joined: Fri Jul 15, 2005 11:30 pm
Location: Cairo,Egypt

Post by omaremad »

Hehe, i love these threads ; the ones where we discus diffrent techniques for effects .

It is also cool how artists can make effects in ways coders never think of.

I hope sio sends the morphine before we all go mad.
"Irrlicht is obese"

If you want modern rendering techniques learn how to make them or go to the engine next door =p
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

Here's the demo and the source code. The shader file is an external file (floorReflect.hlsl) for easy playing with.

This is a first step, not production code. There are some issues that need looking at, but take a look first and play around at will - all the source is there.

Do not forget to read the "readme.txt" file"!

http://www.sio2.g0dsoft.com/giroom.zip

Note: A big thanks to Afecelis for the room mesh. It's the only reason my demo looks any good. :wink:
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

yaaaaaaaaaaaaaay! me happy! thanks to you and Omaremad for getting interested and involved with the project! ;) Omaremad is my Shader Idol, and now you...too....hehehehhee. But now I'm too excited to keep on flattering your work, I GOTTA SEE THE DEMO NOW!!! hehehehhe.

Thanks Sio, hope to see you around.
Ps. Is the hlsl easily convertible con Glsl? I think there's a converter, right?

[nervous mode]checking the demo...checking the demo..now..now...more caffeine please...[/nervous mode]
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

afecelis wrote: Ps. Is the hlsl easily convertible con Glsl? I think there's a converter, right?
I converted the shader code from GLSL to HLSL, so you could just grab the original GLSL source from my Code Snippet. I had trouble with Irrlicht/GLSL so I ditched OpenGL for D3D9. :wink:

Note: I'm posting all my Irrlicht code/demos to my new website hosted by g0dsoft. I've posted four - another four demos to go.

http://sio2.g0dsoft.com - see my Download section
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

beautiful! amazing! superb! outstanding! I could kiss you! heheheheheh, kidding! :wink: But I'm all happiness now!

When I ran it directly from your bin folder I was getting some missing functions from the dll and I got sad and though it was my video card (a Geforce FX 5900 Ultra 256mb, which is DX9 compliant) so then I ran it on my other PC with a 6800 GT (also DX9) and same error! I thought: "man! my pcs are outdated!" hehehe, but then I thought you used your own dll, so I used your source and recompiled and it ran beautifully!! :D :D :D I still gotta get a newer PC, but I knew for sure this stuff should still run on my cards :D

It looks great! Only notice 1 thing as weird: Things that are reflected at the level of the floor like this:
Image
show up ok, but if I then rotate my camera up/down around the X axis they get separated:
Image

I'm sure you're aware of this, but I'm curious to know why it happens. Besides that, it's perfect!!!

One quick last question; should I have a sphere, suspended right in the middle of the gallery, with your shader applied to it, would it reflect the environment? (as in cubemapping) check this small screenie:
http://www.blitzbase.de/grafik2/gfx_cubemapping.jpg
or better said: is there liek a super chromed shader that reflects 100%?

regards and a million thanks!
Alvaro
ps. BTW, very cool site! nice apps! The giroom is a nice addition there! ;) Do all of them contain their sources? Downloading now.
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

:mrgreen:

Strange. What were the errors? Did you install the VS2005 Redist from my site (as I mention in the readme)?

As I mention in the readme, the reflections are out a bit. The shader is converted from GLSL but the reflections looks the same in OpenGL (before I ditched OpenGL). The GLSL shader is used in two other Code Snippet demos for reflective water.

The reflections are done in a different way to how I usually do them. In this method the camera is moved to the reflecting plane when drawing to the rendertexture. I usually use the viewing camera to generate an inverted scene for reflections; I may try that when I have time.

The other issue is that Irrlicht doesn't currently have user-clip-planes. When drawing the reflections it would be nice to clip all geometry. Something else to add to Irrlicht...

How to integrate this (or just plain use with) Irrlicht is the next question. I modified your room mesh to split the floor into a separate mesh for easy manipulation. The source is with the demo so anyone who wants to play around can do so.

All the current demos on my site have source except the Doom3 loader. Still working on this. :wink:
mandrav
Posts: 117
Joined: Sat Aug 27, 2005 8:29 pm
Contact:

Post by mandrav »

sio2 wrote: The other issue is that Irrlicht doesn't currently have user-clip-planes. When drawing the reflections it would be nice to clip all geometry. Something else to add to Irrlicht...
Right there, sitting...
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

mandrav wrote:
sio2 wrote: The other issue is that Irrlicht doesn't currently have user-clip-planes. When drawing the reflections it would be nice to clip all geometry. Something else to add to Irrlicht...
Right there, sitting...
Great stuff. Thanks for the "heads up". Pity this hasn't been integrated into svn yet, though (but don't hold your breath).

There is one issue with user clip planes, in that on some hardware each clipplane enabled reduces the texture units by one. This is because it does one of the various "cheats". :wink:

I'll take a look at your patch.
mandrav
Posts: 117
Joined: Sat Aug 27, 2005 8:29 pm
Contact:

Post by mandrav »

sio2 wrote:(but don't hold your breath).
Oh, don't worry, I stopped doing that a while ago :).
I just thought I should point you to the already submitted patch so that you don't have to re-discover the wheel ;).
Post Reply