Jump to content

Self shadowing 1 Mesh (with submeshes)


KevinBLT
 Share

Recommended Posts

Hello there,

 

sorry I didn't find any topic (or searched with the wrong words) related to this.

 

So look at the screenshot attached.

I have this simple scene with just one mesh.

This mesh has submeshes.

I also have two hemispheric lights and one directional light.

The ground receives shadow. Ok.

But the mesh itself always gets black when "receiveShadow" is set to true.

 

I tried bias value, every filter. Other light conditions. Nothing helped.

So I always can't figure out what the shadowgenerator wants. 

How can I achieve that the desk throws shadows on itself?

 

Thanks everyone for help!

 

Kevin

post-14468-0-86195200-1436444954_thumb.j

Link to comment
Share on other sites

Using useBlurVarianceShadowMap, eh? I ran into that, too and had to accept that it's just not possible at the moment to use useBlurVarianceShadowMap, receiveShadows and cast Shadows at the same time. At least that's how I remember how it went. That was a big bummer. :( Maybe anybody got a fix this time! :D

 

Here a little playground to show the problem (I hope I got it right and that's really waht you are talking about ;) )

http://www.babylonjs-playground.com/#VCXGW

 

PS: Remove shadowGenerator.useBlurVarianceShadowMap = true; OR sphere.receiveShadows = true; to make it work.

Link to comment
Share on other sites

haha, Ice, you're the fastest gun this side of the Pecos!  :)

http://playground.babylonjs.com/#PRPAS

Mine is fancier... and I used a real subMeshed mesh.   neener.  :)

But yep, activate line 110 in my demo, and the box darkens.  I wonder what is casting a shadow over the box.  Surely, it is some evil, dark, sinister entity. 

(Friggin' quickdraws, pft.)  ;)

Link to comment
Share on other sites

My code:

var MeshBoundBox = cMesh.getBoundingInfo().boundingBox;var Width        = MeshBoundBox.maximumWorld.x - MeshBoundBox.minimumWorld.x;var Depth        = MeshBoundBox.maximumWorld.z - MeshBoundBox.minimumWorld.z;var CenterX      = MeshBoundBox.maximumWorld.x + Width/2;var CenterZ      = MeshBoundBox.maximumWorld.z + Depth/2;var GroundSize   = Math.max(Width,Depth) * 6;          light3           = new BABYLON.DirectionalLight("dir01", new BABYLON.Vector3(0, 0, 0), scene);light3.position  = new BABYLON.Vector3(CenterX + 5, MeshBoundBox.maximumWorld.y + 10, CenterZ + 5);light3.intensity = parseFloat(document.getElementById("BrightnessSlider").value);light3.setDirectionToTarget(new BABYLON.Vector3(0,0,0));          ground = BABYLON.Mesh.CreateGround("ground", GroundSize, GroundSize, 2, scene);ground.position.y = MeshBoundBox.minimumWorld.y;ground.receiveShadows = true;ground.material = new BABYLON.StandardMaterial("texture1", scene);ground.material.specularColor.r = ground.material.specularColor.g = ground.material.specularColor.b = 0;          shadowGenerator = new BABYLON.ShadowGenerator(1024, light3);shadowGenerator.getShadowMap().renderList.push(cMesh);//shadowGenerator.usePoissonSampling = true;shadowGenerator.useVarianceShadowMap = true;//shadowGenerator.useBlurVarianceShadowMap = true;       cMesh.receiveShadows = true;light1.intensity = light2.intensity = 0.8;

 

results in this (1) and (2) is what I want to receive. Hmmmmm :-/

post-14468-0-27931200-1436513709.jpg

post-14468-0-87723900-1436513709.jpg

Link to comment
Share on other sites

Poisonsampling seems to not producing any shadow at all :-(

 

Or is there something completly wrong?

 

This function activates the shadow (Checkbox), where "cMesh" is the current loaded mesh (the desk in this case)

function onShowDropShadowCheckBoxChanged() {  if (!cMesh) this.checked = false;          if (this.checked) {    var MeshBoundBox = cMesh.getBoundingInfo().boundingBox;    var Width        = MeshBoundBox.maximumWorld.x - MeshBoundBox.minimumWorld.x;    var Depth        = MeshBoundBox.maximumWorld.z - MeshBoundBox.minimumWorld.z;    var CenterX      = MeshBoundBox.maximumWorld.x + Width/2;    var CenterZ      = MeshBoundBox.maximumWorld.z + Depth/2;    var GroundSize   = Math.max(Width,Depth) * 6;              light3           = new BABYLON.DirectionalLight("dir01", new BABYLON.Vector3(0, 0, 0), scene);    light3.position  = new BABYLON.Vector3(CenterX + 5, MeshBoundBox.maximumWorld.y + 10, CenterZ + 5);    light3.intensity = parseFloat(document.getElementById("BrightnessSlider").value);    light3.setDirectionToTarget(new BABYLON.Vector3(0,0,0));              ground = BABYLON.Mesh.CreateGround("ground", GroundSize, GroundSize, 2, scene);    ground.position.y = MeshBoundBox.minimumWorld.y;    ground.receiveShadows = true;    ground.material = new BABYLON.StandardMaterial("texture1", scene);    ground.material.specularColor.r = ground.material.specularColor.g = ground.material.specularColor.b = 0;              shadowGenerator = new BABYLON.ShadowGenerator(1024, light3);    shadowGenerator.getShadowMap().renderList.push(cMesh);    shadowGenerator.usePoissonSampling = true;    //shadowGenerator.useVarianceShadowMap = true;    //shadowGenerator.useBlurVarianceShadowMap = true;	            cMesh.receiveShadows = true;    light1.intensity = light2.intensity = 0.6;  } else {    if (light3 && ground && shadowGenerator) {       light3.dispose();       ground.dispose();       shadowGenerator.dispose();                   light3          = false;       ground          = false;       shadowGenerator = false;                   light1.intensity = light2.intensity = parseFloat(document.getElementById("BrightnessSlider").value);     }   }}

post-14468-0-80039500-1436778735.jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...