0
$\begingroup$

I’m trying to create a sun disk with a halo in the same shader. However, mixing the two shaders has been a failure. At the edge of the sun disk, where the opacity decreases gradually, we can see the background behind the sun halo in red. Yet, that part of the halo at that position is completely opaque. I know the cause of the problem, but I don’t figure out a solution to replace any transparent value from the sun disk by the value of the halo. It appears that blending the two shaders that way takes a part of the opacity from the sun disk and blends it with the background instead of replacing it with the other shader.

Here’s the shader below for the problematic version.

Problematic Shader

Here are two renders. The first one is the problematic version with the shader mentioned above. The second version is the desired result. I can get the desired result if I create two planes close to each other. I have to use the halo shader alone on the plane behind and the sun disk shader alone on the plane at the front.

The goal is to reproduce the same blending process with opacity, but in the same shader (or material).

I placed a checker board behind the sun in the render test to clarify the problem at the edge of the sun disk.

Problematic version: Render - Problematic version

Desired result: Render - Desired result

How would you mix the two shaders in one material to achieve the result of the second screenshot? In other words, to replicate the same result as the blend result of two planes with transparency.

$\endgroup$
1
$\begingroup$

You have to delete the last mix shader node and one of the transparent shader node, and feed that input with the output of the other shader, so that when the top "layer" is transparent you'll see the bottom "layer", and when also the bottom layer is transparent you'll see the background checker.

$\endgroup$
0
$\begingroup$

Thank you for the solution. I experimented with your solution. It’s not the exact solution I was looking for, but it still gives an interesting result for certain things.

At the moment, the best solution for me is to use two planes layered closely and have each shader on each plane. The difference is still relatively small. There are certain things that really need to be exact. The transparency aspect doesn’t appear exactly the same way, which creates an offset in the colors because of the background color replacing the transparency of the top shader. I also got this issue for the original project I was working on.

For everyone’s benefit, here’s the modified shader based on what I understood from your solution.

enter image description here

Here’s the rendered result.

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.