Issue with lighting in DiffAlpha

Using a tree model where each bough is a simple billboard with a png texture of a bough. (DiffAlpha technique)
Specifically this free model.
The tree looks good from one side, but the other side is glowing. I could post my material, but it is very basic. What should I be looking for? (metallic = 0, setting cull to none glowed from all sides)

Link us to a model we can test, not a web reference to something requiring 30 bloody logins.

Probably caused by some directional light in your scene.
Decrease the “Brightness Multiplier” of your light to 0.5.

Sorry – I thought the link would allow an easy view of the model.

You’re right the light is involved, but I started with the Water sample, so the only light is the skybox light. If I reduce the brightness, the whole scene gets dark. I did more investigation. The tree is simple rects with a PNG texture of a bough. If I use Diff.xml technique then the rects are visible too (duh) but if I use DiffAlpha.xml then the texture is fully transparent everywhere. Is there a way to not add transparency beyond the texture? I’m fairly comfortable with shader code, but just don’t know passes, and the pass differences between Diff.xml and DiffAlpha.xml confuse me. Is there documentation about these details?

If you want your branches / leaves texture to be transparent try:

<shader psdefines="ALPHAMASK" />

in your material file and use an non alpha technology, in your case Diff .

It just discard’s all textureareas with alphachannel < 0.5 and is usually used for trees and plants

Alternatively you can adjust the

<parameter name="MatSpecColor" value="1 1 1 1" /> (For Lightning) at diffalpha tech. the last value is the “reflectstrength / shine”
<parameter name="MatDiffColor" value="1 1 1 1" /> (For Color)

Parameters of your model.

If you use alpha technologies you sometimes have to adjust these values to fit your modellook to the other non alpha models in your Scene


"but if I use DiffAlpha.xml then the texture is fully transparent everywhere. "

Alpha technologies in Uhro3D arent there to take one whole model and display one part of it solid and one part transparent (depending on the alphastrength of the Texture).

The “solid” part will always been a little transparent - you have to build your model with multiple materials in your design program if you want to have only parts of it transparent and use different technologies / materials.

So the thing you want to achieve you better make with ALPHAMASK

Thanks @Nerrik. That works the way I expected. Would love documentation about the various techniques, passes, materials, parameters, etc. Hard to find these kinds of details.

no problem, dont forget to set the cull value for leaves / plants to “none” so the plant can be seen from both sides and not only in the normal direction.

<cull value="none" />

Some kind of documentation about the materials / passes / parameters, could be more detailed but with a little practice you’ll learn it fast :wink:

As long as you don’t have the alpha for the MattDiffColor less than 1 (i.e. you only use the alpha channel of the texture, and transparency doesn’t bleed into the opaque regions in generating mipmaps) then where the texture is opaque the model should be opaque. Though there are differences in how the rendering is done (reverted after all of the non alpha materials with CPU side depth sorting of the models, etc.), the results should be the same, just slightly less efficient if the whole model is opaque.

Yeah, so long as BLEND_REPLACE is the blend mode. If there’s a case where that’s not true then it’s a bug.

1 Like