unlimited planar reflections & refraction (update)

(chäeMil) #61

the water shader looks the same as on the SolarLune’s screens on my Ubuntu 11.10 64bit with geforce gt220. the same artifacts. but beside it, its goergouse! still waiting for the floor reflection to work with the glass reflection and refraction. i would like to use it in my future railway station level in my project :stuck_out_tongue:

(Canadian Hoser) #62

This is gorgeous! It’s super helpful to have ready made GLSL stuff like this that we can just stick in our games, I recently used your fire shader in a mine cart racing game I’m making. Thanks a ton!

(Ace Dragon) #63

Okay, the report I gave about the file crashing when restarting the scene seemed to be overlooked. What I was saying is that there’s currently a showstopping bug where Blender crashes when restarting the scene.

You can get it to crash right away when in fullscreen mode, however, you can get it to not crash at first when you have a smaller window displaying the shader, but then you get this.

Restarting the scene again won’t fix it, restarting twice after that will crash Blender.

Also, I have tried making it to the scripts aren’t running on restart or using delSource() to remove the shaders before restart, but restarting still either gave a bugged result or a crash.

(The Red Hand) #64

SolarLune: The same thing happens to me.

But it’s great. Even with your “slower” version, I still get a solid 60fps at fullscreen. Fantastic work!

(A'nW) #65

Wow! This is great. I have always liked your game engine filters and stuff and this is no different. Thanks for releasing your work. Both of the latest blends work perfectly on my computer. At an easy 60 fps too. Awesome.

Just for kicks, I thought some geometry deforming would be cool. I used a python game script I wrote a while back to “simulate” the ocean deforming with the no parallax mapping demo. Quite simple, just the composition of a couple of sine waves displacing the vertexes z position. I am running it on the plane subdivided to 2048 verts on a side. Pretty impractical, but I liked the effect so I made a quick video.

Edit: Just noticed that the video is slightly sped up for some reason. Oh well.

(SHABA1) #66

Well it worked on my machine but just barely. I got about 2.5-3 fps. Celeron 2200mhz w 2gig ram and 128mb integrated Intel video chip.

(martinsh) #67

chäeMil working on it :wink:

Canadian Hoser, yeah I noticed it already. I am very happy my resources proves to be useful.

Ace Dragon, yeah it is quite buggy right now. I am using bgl module (OpenGL wrapper) in a ways I thought it is not possible in BGE. I even managed to render depth buffer with videotexture (bge.texture) module. but as the OpenGL version varies on every computer, some of the features work, some does not. But I have high hopes for Harmony project - with FBO support and OpenGL update it should be possible to do magical things. So this is just a clumsy warmup :slight_smile:

A’nW, cool - though when you enabled the displacement, the logic went up crazy high, perhaps there is a nice way to optimize the system. Like subdividing the are near the viewer and making the water surface to follow camera in X&Y directions. Otherwise the displacement is calculated for the areas not seen by the camera…

(A'nW) #68

Yep, I know. Like I said, at the moment it is really impractical and very “brute force”. I was thinking of some ways to optimize it, but don’t have time to mess with it right now. I didn’t think of making the ocean follow the camera in the X and Y directions though. Might try that.

(Yoda Almighty) #69


one question though, why is it so dark under the player perspective?

(MouseDroid) #70

Love it, but due to a bug in 2.6 blender will not let me see ANYTHING with a texture (???), But I’m VERY sure that this will work fine in 2.62.

(martinsh) #71

It is called the fresnel reflection. It is an equation that based on view angle and water surface normal estimates how much light gets reflected and how much transmitted. Basically water gets more transparent when view angle to surface is getting more perpendicular. The darkness of the water depends on many things - water depth, density, substance color… In this case it simulates deep sea, where ocean water color is blueish/almost black.

MouseDroid, thanks.
what do you mean “ANYTHING” like only the water or completely anything?

(AleX-3D) #72

Awesome work as always.
And gives hope to see the BGE to its rightful place.
Thank you from a ghost.

Works very well for me, 60fps(i7, gtx 260) but I don’t know why, the logic is very high 80~90%

(TonyPowell) #73

Yo yo bro any chance u’d release the underwater version of ur demo?

(leonnn) #74

Martinsh this is really great, I m amased with what we can do with it!
But I tried to use it on my scene and I got 75% of use of the logic and I couldnt use the camera, I m using the 2.57 version of the blender but if I just open the file in other blend file it works fine. There is any kind of special configuration in order to the refraction to work?
Sorry about bother with this but I think that this would look great the way Im trying to use it. Other problem is when I open in not full screen it runs at 10 Fps and on full screen at 60 fps.

Thanks and sorry about bother you!

(Chishado) #75

@leonnn : the blend file only worked in blender 2.6 versions for me. I tried in 2.59 and it didn’t work right.

Also I tried to mess around with it in my blender game and it’s kinda difficult to set it up from the original file. It’s amazing water shader too ; I wounder if he could make water collisions effects with the player properties.

(martinsh) #76

leonn - the camera setup is very tricky because of the 1 frame lag. The textures are rendered 1 frame after the scene rendering, so in the scene there is a temporary camera and the offset camera which copies the location and rotation of the temporary camera. So the offset camera which player looks through matches the reflection. :slight_smile:
About the framerate and viewport - try to keep the screen at original aspect ratio or close to 1:1, then everything should work well even in windowed mode.

chäeMil , I updated the mirror shaders demo file. now the stained glass scene is together with reflective floor.

Tony, yeah I am still working on it :slight_smile:

(chedurek) #77

Very cool perfect!

(leonnn) #78

This is amazing martinsh, I was really hopping that this would work but I think that I ll let it more simple, my idea was to create some kind of brushed strokes effect on the 3D object, that way it would look like a painting while it was just an usual 3D object, my idea is more or less like on the image bellow.
Its very simple but I think that the effect could be done with a little more work

But I realised that it would increase considerably the weight of the scene on the GPU and that is something that I cant have on the gallery where you dont have any control of the graphics. Aniway as aways the filters and all the rest of amazing things that you share with us improve a lot the quality of our games and that is awesome, and Im very happy that you shared that with us, you coud simply keep it all for yourself but you shared, and believe me when I say that Im your fan and Im thankfull for all, I hope someday I could pay you back! Even if my game dont end up well your name ll be on the credits with your websites!

Thank you man!

(kevincorrigan) #79

Does this method use GLSL?

(Ace Dragon) #80

To revive this thread a bit, I just found an article that talks about a new method of creating reflections in screen-space.

The one comment on this is that it is a slow method, but I wonder if some of the ideas here can be used to improve the reflection examples in this thread as well as fix the various issues like the shader not surviving intact or Blender crashing when the scene restarts.