Open wareya opened 1 year ago
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.
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.