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

Possible specularity issues #35

Open
wareya opened this issue Jan 27, 2023 · 1 comment
Open

Possible specularity issues #35

wareya opened this issue Jan 27, 2023 · 1 comment

Comments

@wareya
Copy link

wareya commented Jan 27, 2023

I think getLightPbr is receiving point light vectors unnormalized, so specular reflections for highly reflective flat surfaces are in the wrong place as you move around relative to them.

Also, I think the light attenuation (from lcalcIllumination) is only supposed to apply to the diffuse component, but right now it affects both, so the reflective sheen of lights against near-parallel-to-view surfaces is basically cut off in a radius around them.

Also, I'm not sure where the fresnel term is used; I don't know what I'm doing, but poking around on google and trying to make sense of getPbr, I think it should be fed into kSpec and the default base reflectance should be 0.04? Doing that as-is, since the pbr shader currently operates in sRGB, doesn't look right, but if I make the shaders do everything in linear light, then a base reflectance of 0.04 and feeding the fresnel term into kSpec looks somewhat vaguely like what I would expect from having messed around in godot. (And making kDiff exactly 1.0-kSpec, because I think that's how energy conservation works? Not sure.)

Also, not specularity-specific, but everything is done in gamma-compressed sRGB right now (as opposed to linear sRGB), which is probably where all the problems in the comments about lights getting overblown are coming from.

@wareya
Copy link
Author

wareya commented Feb 16, 2023

Also, I think the light attenuation (from lcalcIllumination) is only supposed to apply to the diffuse component

Okay, it should apply to the specular component, but it needs to be precisely and exactly quadratic falloff to look right (because the purpose of falloff for specularity is energy conservation), not the adjusted linear or adjusted quadratic falloff that you normally get with morrowind.ini-style light settings. It might be worth calculating quadratic attenuation independently of diffuse light attenuation.

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

No branches or pull requests

1 participant