Help with lighting issue

I’ve been working on #13699 and have run into an issue with lighting. Since I don’t understand lighting at all, I’m hoping someone with a deeper knowledge of it can help find the issue. Please review the PR and failed visualization test reports for more details. Feel free to @me in the PR on GitHub.

Hello! Taking a look at the results, it looks like the directions of the lights have changed a lot, have you tried looking at a basic directional light example with the debug viewer to see if the directions are matching what’s passed?

It looks like the normal has been affected.
because in addition to several lighting directions look different.
There are several tests where the normal effect is directly lost
For example, this one

But I’m not a master in this area, I don’t know if I can help

@Vortex it is not as simple as any vector computation in the materials could lead to this.

You could check with Spector.js which value is different and walk back to the source. but at a first glance one of the computation on vectors/matrices/colors is not back compatible. Maybe setting up unit tests would help you here.

@carolhmj I haven’t. What exactly do you mean by the debug viewer?

@qq2315137135 Thank you for the observation. Perhaps it is something with direction computations (possibly with normalize?)

@sebavan Thanks for the reply. It is passing unit tests so we may not have code coverage for vectors.

The PR doesn’t affect matrices so I’m not sure there is an issue there. Expanding the idea behind standard vectors to include matrices would be awesome.

If I can figure out how to use the debug viewer I will take a look at this tomorrow.

If you open the inspector and select any light, you can click the “eye” button to view a gizmo that represents that kind of light. And lights that cast shadows also have an option on the bottom to display the shadow camera frustum:

1 Like


The Spector reports look the same to me – may there is something I’m missing. Also, could we get the ability to upload HTML files on the forum? I’d like to share the report but can’t since the form will only allow me to upload images.

@carolhmj I checked with the debug viewer and the directions look to be the same:

Thanks to @qq2315137135 Noticing it messed up normals I’ll try and see if it relates to normalize.

Once again, thank you for the help with debug tools and debugging.

You can zip the html and send it :smiley:

1 Like

I didn’t notice the zip format. Here are the reports: (37.2 KB)

Got it! It is definitely an issue with normals:

I may have found the issue, but this needs confirmation: (231.6 KB) (239.6 KB)

It doesn’t appear to be an issue with normalize:

The vector being used (scene.activeCamera.position) doesn’t matter, they are both (0, .25, -3.092).

Edit: here are the Spector reports in JSON: (203.3 KB)

Edit #2:
Light0.vLightData is different in Spector. It should be (0, 1, 0, 0) but is (0, 0, 0, 0)

so now you have 2 leads to follow to figure back why the data is all 0s in your update and normals being reversed

1 Like

This seems to have fixed the normal colors. I have no idea how since nothing should have changed…