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

Omni shadows for clustered lights #3537

Merged
merged 8 commits into from
Oct 5, 2021

Conversation

mvaligursky
Copy link
Contributor

@mvaligursky mvaligursky commented Oct 5, 2021

Clustered omni lights now support shadows by rendering them to the shadow atlas (shared with the spot lights)

  • webgl1 encodes depth in color buffer and does manual PCF comparison
  • webgl2 uses depth shadows sampler and writes custom depth to the shadow map, and uses HW PCF
  • it uses PCF3x3 (the same as spot lights), but single sample version is implemented as well and will be exposed at a later stage.
  • omni light uses few pixel larger FOV than 90deg to avoid doing PCF filtering across multiple faces.
  • new example to demonstrate: clustered-omni-shadows.tsx

Screenshot 2021-10-05 at 12 15 47

@Maksims
Copy link
Contributor

Maksims commented Oct 5, 2021

This is amazing!

I've checked recently clustered for Omni lights and noticed it supports only linear falloff.
Also, I assume specularity is a bit more complicated, as it can extend outside of the light range?

@mvaligursky
Copy link
Contributor Author

Correct @Maksims , the lighting model is very limited at the moment, just a basic diffuse. This is what's still to do:
#3522

@@ -37,5 +37,5 @@ vec3 getCookie2DClustered(sampler2D tex, mat4 transform, float intensity, bool i
vec4 projPos = transform * vec4(vPositionW, 1.0);
projPos.xy /= projPos.w;
vec4 pixel = mix(vec4(1.0), texture2D(tex, projPos.xy), intensity);
return isRgb ? pixel.rgb : vec3(dot(pixel, cookieChannel));
return isRgb == true ? pixel.rgb : vec3(dot(pixel, cookieChannel));
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need to add the == true here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

to be honest, I'm not sure, but have noticed one branch was not taken correctly unless I added it. So I added it to all. I could not find a different workaround.

Copy link
Contributor

Choose a reason for hiding this comment

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

TBH, if I was refactoring this code, I would delete this. So if it's important, I would add a comment to say why it's there.

mvaligursky and others added 4 commits October 5, 2021 05:02
Co-authored-by: Will Eastcott <will@playcanvas.com>
Co-authored-by: Will Eastcott <will@playcanvas.com>
Co-authored-by: Will Eastcott <will@playcanvas.com>
@mvaligursky mvaligursky merged commit 767fa58 into master Oct 5, 2021
@mvaligursky mvaligursky deleted the mvaligursky-clustered-shadow-omni branch October 5, 2021 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants