- Home /
Creating realistic glass
I know this has been asked many times before, but I can't actually get a simple answer that works for me.
How do I create glass for windows. I've had a go at cube maps which don't really produce good enough results, so I'd like real reflections if possible.
I'm also having trouble controlling transpareny of the reflective material.
Answer by BerggreenDK · Nov 29, 2010 at 03:53 AM
You didnt state if you are using the free or pro version of Unity. But as I've been told (currently using the free version only), certain features with shader and shadows has been removed from the free version - so you might have to "fake" some features.
One of the important features regarding your problem might be "real reflections" as thats something "raytracing" programs does, eg. real 3D rendering programs. Unity3D is a GAME-ENGINE, not a RAYTRACER.
You can get realtime shadows, because these can be calculated from vector-coords. If I was to produce eg. a mirror, I would use the PRO version, then map a "rendered texture" where the texture is comming from a secondary camera facing in the direction of the mirror. This is the closest possible way I think so far, unless I've misunderstod Unity3D engine.
With transparency, its a matter of "alpha transparency", but alpha does not "index" your view-rays, for this you also need the shaders to do the trick. So look at the water-materials and see if any of these does the trick. Again, I think you will need PRO license to use the shaders for something "really beautiful" but I might be wrong.
Hope you can use these advices.
Thank you. This makes things slightly clearer. I think the water-material are the way to start.
RAYTRACING is just a way of rendering a scene, I made one for Unity a while ago! a GA$$anonymous$$E-ENGINE is completely different from a RAYTRACER, but a GA$$anonymous$$E-ENGINE can contain a RAYTRACER. I'm sorry, but my OCD kicks in when people say "unity isn't a raytracer" ins$$anonymous$$d of "unity doesn't have a raytracer". :P
Answer by Monkey.du · Feb 12, 2011 at 07:55 PM
I don't understand why there is such a reluctance to writing such a shader that handles real-time reflections and transparency. What's the big deal?
Looks like many users here are asking for such a shader. What does it take? Days, weeks of work?
Looks like I'm going to pay someone to write this shader and then I'm going to share it for free.
Because the amount of CPU power needed to calculate real reflections is prohibitive in a realtime game. Reflections you see in games are almost always done through some trick.
I've also been searching for a glass shader with dynamic reflections. I eventually managed to make one, by modifying the $$anonymous$$irrorReflective shader/script to include transparency, a base texture, and tinting.
I made a page for it on the Wiki: http://wiki.unity3d.com/index.php/SurfaceReflection
It requires Unity Pro, though.
Answer by fherbst · Oct 29, 2010 at 07:42 PM
"True" reflections are possible - at least for planar objects like windows and water - but not easy, thus you can't get a "simple answer". You should prepare to learn how the rendering pipeline works, how render textures work (Unity Pro only)...
You could also take a look at http://www.unifycommunity.com/wiki/index.php?title=MirrorReflection2, there is a mirror shader which can quite sure be adapted for a "true reflection and transparency window shader". I do not know whether this shader works for Unity 3 (seems some have to be ported first). Another shader to look at is the water shader which ships with Unity Pro (especially for the setup script and stuff).
You see - another not-so-simple answer, because true reflections are quite a complex topic in real-time computer graphics (because real-time raytracing isn't possible - right now).
I see your point - that it's not simple. I can appreciate that. But surely someone must have cracked this. I'm really looking for someone that has solved this to give me specific advise - please!
I think it adds too less to the realism of a standard game scene to have true reflecting glass. $$anonymous$$irrors and water are another thing - maybe you have luck and find something for glass as well. You could also take a look at some of the refractive shaders in the unifycommunity.
Answer by Venryx · Mar 19, 2013 at 07:26 AM
I've also been searching for a glass shader with dynamic reflections. I eventually managed to make one, by modifying the MirrorReflective shader/script to include transparency, a base texture, and tinting.
I made a page for it on the Wiki: http://wiki.unity3d.com/index.php/SurfaceReflection
It requires Unity Pro, though.
Your answer
Follow this Question
Related Questions
Can I make a glass cube on iOS w/ Pro? 0 Answers
Semi Transparent Material on a plane. 2 Answers
Transparent material on iPhone Android 3 Answers
Iphone Shader Reflection Map 0 Answers
GameObject generated during runtime is not transparent on mobile device 0 Answers