- Home /
Need help rendering beer glass in unity...
So I am making a simple game in which you control a beer glass sliding along a bar avoiding obstacles, and I am trying to come up with a way of rendering a realistic pint, preferably with refraction, bubbles, etc, but for now, I am just trying to use two transparent objects (the beer will eventually get a diffuse map applied too).
The problem at the moment is that I can't seem to control the render order of the objects so the beer always appears inside the glass, it only appears through the glass from a low angle, so it appears in the reflection, but not from the angle which the game will be played from. For the glass I am using one of the hard surface shaders from here: https://www.assetstore.unity3d.com/#/content/729 and for the beer I am using a default unity transparent material, although the issue also happens with any trans material.
Firstly, if someone can help me ensure this renders correctly from all angles, that would be great.
Second, if someone can come up with a better way to make a glass of beer in unity, that looks really, REALLY good, that would be so awesome you have no idea! ;P
Thanks for any and all help in advance!
-WBC
beer glass from top
from top without wood
beer glass from below
Hi, Creating Refraction in unity is quite complex you need to rotate the normal in accordance with view direction.You could download HardSurfaceShader Free version it does have refraction.Or you could create yuor own effect easily but you need Unity pro
Ps the game looks pretty good already
Transparency sorting is awkward, and Unity doesn't support anything other than per-object sorting for transparent objects. You can do it in other ways, but it is a lot more complex, and a lot slower. The trouble is, most objects are sorted using a z-buffer, which writes in the depth of each pixel, so it can ignore any pixels behind that point. However, transparent objects can't use this, because this would stop you being able to see through them (okay, technically you CAN use the z-buffer with transparent objects by using a different render queue, as Unity does, but it does mean you won't be able to see other transparent objects through it). To get this to work properly, I think you're going to have to look into more complex solutions, most of which will involve re-routing Unity's rendering pipeline. You may want to look into a raytracer, as they can give very realistic results, and handle reflection and refraction very easily, as well as being ideal for transparent surfaces. Alternatively, you could look into per-vertex transparency sorting, but keep in $$anonymous$$d that both of these methods can get very computationally expensive very quickly.
Your answer
Follow this Question
Related Questions
Refraction is also reflection? Or a bug? 0 Answers
Creating realistic glass 4 Answers
Creating realistic lantern (glass) 0 Answers