question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Per-material shadow bias

See original GitHub issue

It currently sits in the light, but as it happens the same value of bias would fix one object in the scene while causing problems for another. How hard would it be to add an optional bias to the material, and will this work for e g #12919

Looking at the code, it is just passed as the uniform parameter, so altering it should not be a problem? Screen Shot 2020-04-09 at 19 54 39

Ok no, looks like those are some different uniforms, for shadow pass or something. It is not on material uniforms in onBeforeCompile 😦

It is actually in param.uniforms.directionalLights.value[0]

Ok, so I was able to do this hack:

material.onBeforeCompile = function(stuff) {
	var chunk = THREE.ShaderChunk.shadowmap_pars_fragment
		.split ('z += shadowBias')
		.join ('z += shadowBias - 0.001');
	stuff.fragmentShader = stuff.fragmentShader
		.split ('#include <shadowmap_pars_fragment>')
		.join (chunk);
};

so this is definitely possible.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Mugen87commented, Mar 4, 2021

Instead of moving shadow properties to materials, it’s better to focus on #13108. Meaning investigating and introducing new shadow approaches for tweaking shadows (like normalBias).

1reaction
mrdoobcommented, Jul 27, 2020

I don’t think so. It’s a new property in the shadow.

You can try it in the editor:

shadow.normalBias = 0:

Screen Shot 2020-07-27 at 6 40 47 PM

shadow.normalBias = 0.05:

Screen Shot 2020-07-27 at 6 41 11 PM
Read more comments on GitHub >

github_iconTop Results From Across the Web

6.1 - Shadow Bias | Unreal Engine 4.27 Documentation
This example shows off the Shadow Bias. This property exists primarily to help objects feel more grounded along a surface. There is a...
Read more >
Shadows | Babylon.js Documentation
Bias. Normal Bias (Since 3.2). Soft Shadows. Custom shadow map shaders. Global custom shadow map shader. Per-material shadow depth map shader. Basic usage....
Read more >
Directional Shadows - Catlike Coding
Render and sample shadow maps. Support multiple shadowed directional lights. Use cascaded shadow maps. Blend, fade, and filter shadows.
Read more >
[2.2] Self Shadowing errors - Ogre Forums
Hi, just wondering if there is a solution to fix the self shadowing artefacts that run on the pcf based shadows.
Read more >
will it be improved? Will we ever get better soft shadows?
@PutridEx The receive shadow setting is now per material so that you can ... Bias improvements need to be done in major release...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found