Lighting issues

recently I've changed lighting in my scene from LightingVisual3D to single ambient light and headlight. Now I see a weirdness in textured objects. It seems like the UVs are somehow messed up. I've played with different light setups and this is what I found out.

When using an ambient light and one directional (up to 3 directional lights), the scene looks like this:

Now when I add a point light, or a spot light, or 4 directional lights the texture and the normal map is correctly used:

From the DXEngine deep dive, I've found out that there might be an optimization in shaders:
Quote:What is more, when a simple 3D object is rendered (with standard material and no instancing or any other advanced effect) and when there are only three or less directional lights, then DXEngine can use a higher performance directional light shader. When more directional lights, a point light or a spot light are used, then a more complex shader needs to be used. All the created lights are added to the DXScene.Lights list.

I've observed this with single viewport and also with multiple viewports on version 4.4.7874 and 4.2.7655. However I did not manage to reproduce it on the samples.

I've attached a full scene dump from version 4.2.7655 with ambient and directional light (the first image). Would you happen to know what might cause this?

Best regards,
Janovsky Roman

Attached Files
.txt   DXEngineDump_4.2.7655.txt (Size: 90.57 KB / Downloads: 1)
When using up to 3 directional lights (+ optional ambient light) then an optimized version of shader is used. When using more than 3 directional lights or a point light or a spotlight, then a more complex shader is used.

The optimized version of the shader also does not support normal and specular maps.

When trying to reproduce your issue I was not able to get the strange results that you had. But I have found out that in the case when 3 or fewer directional lights are used, the DXEngin does not use the complex version of the shader and therefore renders the objects with only diffuse texture (without normal and specular map).

I have fixed this issue so in the next version this should work correctly. If you want I can send you a pre-release version with this fix.

As you have found out, the workaround for the current version is to add a point light with almost black color (black disables the light) and with Range set to 0 (to quickly discard using the color). For example:
<PointLight Position="0 0 0" Color="#010101" Range="0" />

You can also add additional directional lights with almost black color so that you will have 4 directional lights.

This will require that the shader will need to process additional lights but in almost all cases this should not be noticeable and hardly measurable.
Andrej Benedik
I see why I couldn't reproduce it, I have wrongly chosen an object with only diffuse texture.

Thank you for the investigation. Right now, the workaround will be enough for me since I need it to work in older version as well.

Forum Jump:

Users browsing this thread:
1 Guest(s)