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

PBR spotlight falloff #31

Closed
wants to merge 1 commit into from
Closed

Conversation

kukulski
Copy link
Contributor

implements spotlight falloff as defined at pbr-book.org. It's juuust slightly dirty in that it's smuggling the falloff angle (ok. the cos of the falloff angle) in by way of the existing panda3d spotlight exponent property, which... wasn't supported by simplePBR anyway.

Screen Shot 2021-07-22 at 4 39 49 PM

Copy link
Owner

@Moguri Moguri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, if I understand this correctly, spotExponent is just used as a way to pipe data in and no attempt is made to convert exponent values so a user can get reasonable responses to adjusting this value? I would prefer to avoid simplepbr-specifc trickery so it remains working as a drop-in replacement for Panda's auto shader.

float shadowSpot = smoothstep(spotcutoff-SPOTSMOOTH, spotcutoff+SPOTSMOOTH, spotcos);

// https://www.pbr-book.org/3ed-2018/Light_Sources/Point_Lights#SpotLight::Falloff
float cosTheta = dot(normalize(p3d_LightSource[i].spotDirection), -l);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer that these didn't get renamed.

@rdb
Copy link
Contributor

rdb commented Aug 6, 2021

Also see Moguri/panda3d-gltf#85 for how the glTF converter converts the outer distance into an exponent. If you're going to use a linear falloff instead of an exponent, it should probably use the inverse of that calculation.

That said, is there a good reason not to just apply the exponent the way Panda does it here?

@kukulski
Copy link
Contributor Author

The awkward answer is "the systems I'm using Panda3d to prototype for all use inner-angle"

Longer answer: before switching to simplePBR, I'd done similar not-entirely-right work to set an exponent to approximate inner-angle. Later I accidentally discovered a side-effect where, in the regular pipeline, setting the scale of a spotlight had an influence on the inner angle scale = 1/math.cos(math.radians(self.state.inner_angle)), though setting exponent was still super wonky. Later, while poking around to see if there was any chance of making area lights work, I found the place where I could make simplePBR do PBR-spec inner-angle, so that's what I did here.

Is there a way to add uniforms to a light instance? If so, I can dispense with the dirty hack and make pbr-inner-angle cleanly opt-in. (and maybe even figure out how to do area lights)

@Moguri
Copy link
Owner

Moguri commented May 8, 2023

Closing due to inactivity

@Moguri Moguri closed this May 8, 2023
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.

None yet

3 participants