Replies: 2 comments 8 replies
-
|
Hi! This looks like in case of the builtin Phong you have the light positioned relative to the camera (and so when rotating the faces that are directly facing the camera look brightest), while with your custom shader you have the light positioned statically in the scene and so the lighting doesn't change when rotating. To convert a light position that's static in the scene to a camera-relative position, transform it with the camera matrix. I.e., something like |
Beta Was this translation helpful? Give feedback.
-
|
This is a clever solution, the color will still change with rotation, it's just not obvious, but it still solves the current problem. Let's do this for now, and we will try adjusting the position of the light source later. |
Beta Was this translation helpful? Give feedback.


Uh oh!
There was an error while loading. Please reload this page.
-
I am currently developing an editor and everything is going smoothly. However, I have encountered usage issues with lighting and would like to receive assistance. The specific description is as follows:
I want to implement a basic material function similar to MeshBasicMaterial in Threejs, which allows objects that are not affected by lighting to have their color or texture set regardless of lighting. I have already used a custom shader to implement this function, but there are still texture requirements in the future. Therefore, I want to use the system's built-in PhongGL to achieve it. However, not only how I set the color and light position, but I still cannot get the custom effect. Can you give me some ideas?
The following is my custom Sharder effect that is not affected by lighting and displays the object's own color.

This is the system's built-in rendering and key code. As the scene rotates, the color changes too much.

Hope to give some ideas, thank you.
Beta Was this translation helpful? Give feedback.
All reactions