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

Shadow mapping vs scissor test #3532

Closed
Borisss opened this issue May 31, 2013 · 12 comments
Closed

Shadow mapping vs scissor test #3532

Borisss opened this issue May 31, 2013 · 12 comments
Labels

Comments

@Borisss
Copy link

Borisss commented May 31, 2013

Hi!

I've run into issue when trying to use shadows in my scene that is rendered into two separate viewports (separate scenes, based on http://mrdoob.github.io/three.js/examples/webgl_multiple_views.html). The moment I enable shadowing, shadow map (used only in one scene, one viewport) is corrupted. Please see the image attached. There is only one shadow receiver in the screenshot and no object casting shadows, yet, parts of the ground are suggested as in shadow. When I remove renderer.enableScissorTest(true), shadows are ok (but I lose my other viewport rendering of course).

Can this be done with some workaround?

three.js r58, win7, latest google chrome, latest firefox

Great library btw! Keep up the good work and thanks for any advice!
Regards,
Boris Zapotocky

bug_shadow

bug_shadow_noscissor

@Borisss
Copy link
Author

Borisss commented Jun 6, 2013

anyone?

@Borisss
Copy link
Author

Borisss commented Jun 6, 2013

ok, I've found a workaround:

  • enable shadows
  • render the scene with no clipping and scissor
  • disable shadows
  • do the normal viewports rendering

-> this works, yet problem is, I'm completely uselessly rendering also the normal scene into framebuffer in the first step, that is discarded afterwards (performance). I've not found any way to render shadows only (render.renderPlugins(ShadowMapPlugin,,,) method is not visible publicly), I'd like to avoid hacking into the three.js code

-> so a suggestion: some public method to enable shadow only rendering?

@arcanis
Copy link
Contributor

arcanis commented Sep 21, 2013

Exact same issue with r61. +1 for workaround :

renderer.setViewport( viewport.left, viewport.bottom, viewport.width, viewport.height );
renderer.setScissor( viewport.left, viewport.bottom, viewport.width, viewport.height );

renderer.shadowMapEnabled = true;
renderer.render( scene, viewport.camera );

renderer.shadowMapEnabled = false;
renderer.enableScissorTest( true );
renderer.render( scene, viewport.camera );

@insominx
Copy link
Contributor

Just encountered this same issue and verified the workaround but yea, it does waste an extra render. One piece that's missing above is to make sure to turn off the scissor test because it will be left on from the previous frame. Here's my version (based on yours):

  renderer.enableScissorTest ( false );
  renderer.setViewport( left, bottom, width, height );

  renderer.shadowMapEnabled = true;
  renderer.render( scene, camera );

  renderer.shadowMapEnabled = false;
  renderer.enableScissorTest ( true );
  renderer.setScissor( left, bottom, width, height );
  renderer.render( scene, camera );

@QuaziKb
Copy link

QuaziKb commented Nov 21, 2014

I'm running into the same issue, seems like shadow maps aren't playing nice with viewports/scissor test somehow, would be nice to see this fixed or even acknowledged, looks like the devs ignored it/didn't see it.

@mrdoob
Copy link
Owner

mrdoob commented Nov 22, 2014

It goes a bit over my head at the moment :)

@mrdoob
Copy link
Owner

mrdoob commented Nov 17, 2015

Fixed! (2 years later... 😇)

@mrdoob mrdoob closed this as completed Nov 17, 2015
@Borisss
Copy link
Author

Borisss commented Nov 17, 2015

great, thanks! 👍

@QuaziKb
Copy link

QuaziKb commented Dec 16, 2015

sure this is fixed? I'm still running into the problem (R73) or is it in the latest build

@mrdoob
Copy link
Owner

mrdoob commented Dec 16, 2015

Yes, it's in r74.

@unphased
Copy link
Contributor

Confirmed fixed in dev branch. Thanks for fixing this mere weeks before i needed to implement the feature (otherwise i'd have to duplicate the context to render two viewports or settle for shadowmap the same size as my viewport) 👍

@QuaziKb
Copy link

QuaziKb commented Dec 20, 2015

Ah okay great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants