- Home /
How to change the transparency so that a set of objects display as one?
In a game I'm working on, multiple objects are placed next to each other that have a modifiable transparency. More specifically, I want one section of a scene to turn translucent when another is put into focus behind it.
I have a ceiling cuboid connected to a wall cuboid, but the side face of the ceiling is being rendered under the wall, creating a dark parallelogram depicted in the top image. Here is what the current problem looks like (above), and a manually corrected image of what the final effect should look like (below):
I've considered three solutions to the problem:
1) Use just one model
Create a new model that is both the ceiling, floor, and wall combined into one model. The problem itself is avoided, but creating a new model for every section of every scene would be tiresome.
2) Shader magic
Make a shader that corrects the problem. This probably requires an incredibly in-depth knowledge of shaders that I simply don't understand, and it may not even be possible.
3) ZWrite manipulation
This may be involved in solution 2, but it may also not be. A script would keep the different elements rendering properly.
Which of these solutions would be the most plausible / effective at resolving the issue, or would another solution I haven't thought of actually be best?
Well, a shader woule be the easiest solution I figure... If you already have some basic know-how. I kinda had to dive into that topic myself a while ago but after a few days I got the hang of it and now I am able to write custom shaders for my projects. It is a very nice set of skills to have and opens up a lot of possibilities so if you are willing to spend some time with the good amount of in-depth informationavailable online I'd say definitely go for it, you won't regret it. Unity's own shader tutorials in the User $$anonymous$$anual can be a viable starting point.
Answer by Fydar · Aug 24, 2017 at 03:00 PM
Make a shader that renders on the transparency pass that writes to the depth buffer to stop anything behind it that's transparent render. That means your transparent pass will have to be a forward render.
You could also create a script that dynamically joins the meshes together into one.
Your answer

Follow this Question
Related Questions
Visual Artifacts from my Custom Transparent Shader 0 Answers
Shader that renders pixel with highest alpha value? 0 Answers
Silhouette overlay shader 0 Answers
Shader to turn materials transparent based on y axis 0 Answers
Help Adding Transparency to Shader 1 Answer