efxlab

Shadow caster and model proportion in babylon scene unit

Recommended Posts

I have a glTF model imported, but I have no success to get shadow caster visible on ground from model, (my code work from regular GitHub model), I think mine has big proportion. Iam playing with groundShadowLevel but I dont found the good value to have shadow visible on this model, I think it may too soft/big or too small. is a way to get the good value visually with the scene proportion ?

Should setup my model size to any babylon unit ?

thanks

Share this post


Link to post
Share on other sites

I just tested out, The mesh disapear from screen, I think it become very very tiny invisible :)

my camera is:

camera = new BABYLON.ArcRotateCamera("Cam_config", 0, 0, 0, new BABYLON.Vector3(0,5,0), scene);
camera.setPosition(new BABYLON.Vector3(-4,10,14));
camera.fov=0.8;

I don't know what to do to point camera to this resized model ?

Share this post


Link to post
Share on other sites

Hi efxlab !

You may use camera.setTarget(yourMesh.getBoundingInfo().boudingBox.centerWorld) or camera.lockedTarget = yourMesh; 
If your mesh is still not visible, perhaps is your camera.maxZ too small, then try to increase it.

PS : Depending on the transformations you applied, you might need to use the method refreshBoudingInfo() to update the bounding info and to avoid your mesh being considered out of the frustum and therefore not drawn !

Share this post


Link to post
Share on other sites

Hi !

Your shadows are here. But because of the camera direction you don't see them.
Using an arc rotate with control, you can see your shadows are projected, but outside of your original camera view.
https://www.babylonjs-playground.com/indexstable#10D6YT#93

You will see that the shadow is not natural.. it is because your character is litteraly flying. There is 2 babylon units between him and the ground (Y componant). Try working on their position
https://www.babylonjs-playground.com/indexstable#10D6YT#95

By the way, don't forget to set sizeAuto to false when you create your default environment, otherwise your skyboxSize and groundSize are not taken.

Share this post


Link to post
Share on other sites

Thanks for your advices @Amarth2Estel I got you from playground, but I can't reproduce in my project with the same value. I dont understand I test with the same model etc ...
I set scene.createDefaultEnvironment sizeAuto to false too and My model is well positioned on the ground... no luck, maybe playground have some tips I have not ?  Iam Investigating more again... 

Share this post


Link to post
Share on other sites

Hey, yeah you are right, but Iam working on another work now.

I will test it out soon with a new model replacement for debug (I can't actually share my project for copyright) and I'll post feedbacks here.

in No working I was meaning that there is no shadow cast, its very strange.

see you

Share this post


Link to post
Share on other sites

Hello,

ok Guys, Iam back from my shadowCaster issue, I converted the sculpture to something awfull for copyright :)

Shadow works only in playground, here my code:
https://playground.babylonjs.com/#T68535

but with the same setting in my code (except the camera setting), shadow are no working:
https://bin.fuelphp.com/snippet/view/OW

thank you to assist me Guys

see you

Share this post


Link to post
Share on other sites

I see difference with light position and direction.

Also your code to add to shadow map and to normalize is not called after loading the gltf but before

Also you can use Spector.js to see the content of your shadow maps (really helpful to see if light is misplaced)

Share this post


Link to post
Share on other sites

great its a good indication for me to understand the BJS workflow.

Where do you think I can add the shadowCaster ? would like appropriate to put after the loader with:

loader.onComplete = function () {
           addShadowCaster();
};

It work now it was the order: called shadowCaster on the loader complete. Thanks @Deltakosh et tous les BJS users :)

Edited by efxlab
Just tested

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.