Sunday, April 8, 2018

shaders - Glass Material for Unity 5


Anyone know how to make a glass material in Unity 5?


I can do metal and image textures, but not sure how to create a glass material.


A search on Google would not get me anything for Unity 5 so it must be fairly easy to do.


It's for a shower door and plane glass like this:


glass



Answer



Here's few things i could gather up, hope this helps you. There's multiple ways to get this done. You can write shaders or if you don't mind about having very simple glass, you can use default shaders and some PNG magic.



  1. Glass Shader made by Alastair Aitchison


  2. Reflective transparent "Glass shader" made by benoculus

  3. Unity asset store search: Glass

  4. Free asset - Breakable glass




EDIT: As this is getting some attention, i decided to add step by step tutorial for very basic window/transparency



  1. Create PNG image with transparency on places, where you need it.

  2. Drag and drop it to your assets inside Unity

  3. Drag it from assets to your gameObject, that you wanna use as glass


  4. Select shader -> Transparent -> Specular ( or any of the choices, i liked specular )

  5. Enjoy




I created simple 64x64 image with full background transparency and added black text on it Transparent PNG


Then i imported it to unity ( dragged it ) and then dragged it over the cube i had there. After that, i selected transparent shader for it. Step by step image


Results ( game is running ) Result cube


After this, you could easily create PNG that has some scratches on it or other similar effects to make it look more real. You can even create borders with some color, that could look like a wood or metal. Try the different transparent shaders to find what looks best.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...