Since I’ve asked a lot in the past weeks I thought I would have to give something back to the community,
here is the realtime refraction system I have developed, if you like it I will also release my realtime procedural grass script and the realtime terrain deformation…
So I am not 100% sure wether I am the first one to have found that way for refractions, but I did not see anything similar so far.
The refractions are based on a texture that is rendered from the current cameras perspective, but the texture is rendered without the refractive objects (objects with a “renderCulling” will be culled).
All refractive objects have material with projects that texture to it based on view coordinates.
That’s it basically!
Here are examples of what this can be used for:
Water
Glass
Heat hazes
Check out this .blend and let me know about how you like it and what you don’t like!
This is quite simple, just append the render plane (the one under the room), the refraction_camera and an refraction object with the material you need to your scene!
If you want your own objects to be refractive, apply a refraction material to it and add a game property called “renderCulling” to it.
I’ve been searching for heat haze for so long, I even tried it myself using code snippets of already working refraction scripts and failing hard. I also tried to recreate it the way you did (camera to texture without the objects in view - but again failed hard ! T_T) thank you very much. I’ll try to combine that with my realtime fire. Will be a great outcome I hope.
Lukas, that’s a great contribution and the demo blend really shows it off well. Thanks for sharing your hard work dude, it’s really appreciated! I’m looking forward to seeing what others do with this method particularly fire/heat haze combo sounds like an obvious next step.
I’ll no doubt be using this myself (or a variation of it) on my current projects if the resource hit is manageable.
Looks so good! The way you make the glass is very effective, but, the reflection is strange- whan I look up I don’t see any sky, but I see it in reflection(I would reccomend to bake reflection texture in render and than use that image in game).
Refraction camera must be attached to the object. But here, it is attached to the player. Due to this refraction works on all sites but there is this problem.
Excellent, I am pretty sure that I understand the script pretty well but I have one confusion…why can’t you use the same camera for both the view and as the refraction camera? I mean I know it doesn’t work but for what reason?
It’s a limitation of BGE. At the moment (for no particularly good reason) you can’t use bge.texture.ImageRender on the active camera. Yes, it bothers me.
Thanks for the quick reply…also one more thing, the objects are being made invisible and then visible in the same script, then why don’t they flicker? or is it happening REALLY fast?