It has been some time since I posted anything. This was due to work I had to do for clients, because - as some of you may have noticed - Serious Monk is not a fulltime-job... yet. It is rather the symbol of my wanting to do this full-time and hopefully will one day result in exactly that. Up until then, I will have to work for clients every once in a while to gain the money to have this thing up and running. 

Nevertheless we were quite productive the last weeks and I wanted to share a solution to a small, but significant problem we encountered: Transparency in Unity. As you already know (if you read the other articles) we 'fake' our 3-dimensional room, that is the characters are real 3D models, but the rest is plains with high-res-textures on them. For furniture like the table in the Refektorium or the oven in the kitchen, we use plains, with a .tga-file UV-mapped onto them. The *.tga-file has an alpha-channel, which allows us to see the background where the table or oven has ended. 

We do changes the same way in the scenes, for example when a character picks something up - we just fade in or fade out a plane with a corresponding texture. Of course, simple objects are not full-resolution, but the plains are modelled in the smallest possible size. We had a situation where a big plain (green border), simulating the changing of a door was behind a smaller plain (red border), simulating the change of a detail in the door.


Unity Transparency Tip

In unity, a shader with transparency will be sorted by distance to the camera: objects further away from the camera will get drawn first, then the objects closer to the camera. In blender, the smaller plain is in front of the bigger plain, but in unity it was quite the opposite. That has to do with the way unity calculates the distance, which is maybe not too obvious: Unity takes the center of the object - the center being the center of the bounding box, NOT the origin - and draws a line to the camera. The length of this line results in the distance, and thus in the order of drawing. 

In our case, the center of the smaller plain was further away from the camera because it is further down, resulting in a greater distance concerning the Top-Bottom-Axis.

Unity Transparency Tip 2

The solution is simple (if you know it): You just have to re-position the center of the bounding box (right arrow) by adding one extra vertex (left arrow) and placing it behind the plain. Like this, you can influence the distance to the camera while having the plain and textures stay on the exact same spot. Now unity draws our transparent plains nicely in the order we want it to... YEEHAW!



blog comments powered by Disqus
Serious Monk Serious Monk Serious Monk
Editor | COA | Admin


We are an independent gamedesign studio based in Cologne, Germany.

serious monk
Manuel Schmitt
Maybachstrasse 155
50670 Köln
+49 221 93825101
Write us an Email





About this Webpage:

This webpage is a developer-blog, providing information for the interested about the production of our computer-games. This shall not only serve as a product-show-off, but also as a platform for other developers to read about our problems, our solutions and thoughts during the development.

We will offer tutorials, tests, opinions related to indie-game-development and of course information about the games we are currently working on.

Stay tuned. Happy gaming.









IMPRESSUM | ADMIN