Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specular lights #15

Merged
merged 4 commits into from
May 5, 2024
Merged

Specular lights #15

merged 4 commits into from
May 5, 2024

Conversation

mardy
Copy link
Collaborator

@mardy mardy commented May 4, 2024

As usual, better review commit by commit.

mardy added 2 commits May 4, 2024 16:59
This allows us to optimize the usage of GX lights, since we don't need
to always reserve a pair of lights for the ambient and diffuse
components, if only one of them is used.
@mardy mardy marked this pull request as draft May 4, 2024 14:06
@mardy mardy marked this pull request as ready for review May 4, 2024 19:12
We add the specular lights to the first channel, along with ambient
lights: ambient lights are not directional (they only depend on the
distance), so we can switch the angular attenuation function to
GX_AF_SPEC without affecting them.

Note that there's a difference between how GX and OpenGL compute
specular lights: in OpenGL, it is a combination that depends solely
on the GL_SPECULAR values set on the light and on the material; but in
GX, due to the fact that we have only two channels for mixing lights, we
pre-multiply the two GL_SPECULAR values of the light and of the
material, and then we have an additional factor which is the material
ambient color and which we cannot avoid. The reason is that GX computes
the resulting color of the specular light by mixing the color set on the
light with the object's material.
@mardy mardy marked this pull request as draft May 4, 2024 19:24
All these multiplications are already done by the TEV in
setup_render_scene(). The only exception to this is specular color, but
multiplying it with the light color is wrong anyway (we produce a weaker
light) and, most importantly, this light is already combined with the
material's ambient color by GX (see the previous commit's explanation).
@mardy mardy force-pushed the specular-light branch from 8a656f6 to 7b69b33 Compare May 4, 2024 20:15
@mardy mardy marked this pull request as ready for review May 4, 2024 20:16
@WinterMute WinterMute merged commit 3f4dafb into devkitPro:master May 5, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants