Jump to content

DirectionalLight and WORLDMONGER.GroundMaterial


JonathanRev
 Share

Recommended Posts

Hello guys ! i was working with groundmaterial several weeks already , but i recently noticed that  "DirectionalLight" is not a good friend of "WORLDMONGER.GroundMaterial" i hope i am wrong ,

but i was experimenting with endless landscapes and i noticed that when i go far from the point 0 , 0 , 0  of my scene the diarectionallight doesn't iluminate with the same intensity when i go far away from point 0 , 0, 0 when i use the GroundMaterial

i set the directional light this way :             var light = new BABYLON.DirectionalLight("dir01", new BABYLON.Vector3(0, -1, 0), scene);
                                                                         light.intensity = 1.0;

and i am using the groundmaterial as :     var groundMaterial = new WORLDMONGER.GroundMaterial("groundMaterials", scene, scene.getLightByName("dir01");

                                                               -----------------------------------------------------------------------------------------------------------------

Now when i use a the StandardMaterial :  var groundMaterial = new BABYLON.StandardMaterial("ground0", scene);

                                                                         groundMaterial.diffuseTexture = new BABYLON.Texture("shaders/Ground/grass.png", scene);

and i move far from the point 0, 0, 0  it works perfect and iluminates with the same intensity for example if i were some kilometers far away from the point 0,0 as it would be on the point 0,0 

is this really something related to groundmaterial? , or i should use some trick to have kilometers of my scene with the same intensity in light using directionallight and groundmaterial?

i have already tried using the scene.registerBeforeRender(function() to have the directionallight follow the camera but i don't think it is a good solution , i guess the DirectionalLight should iluminate the same ortogonal way even if i am far away from the initial location point of the directionallight.

Link to comment
Share on other sites

wow ! totally right , i guess i fixed it this way , i replaced : 

                                                                  // Light
                                                                  vec3 lightVectorW = normalize(vLightPosition - vPositionW);

by this :  

                                                                   // Light
                                                                  vec3 lightVectorW = normalize(vLightPosition);            

Not sure if this will have any effect in another part of the game, but now it iluminated perfect in all directions !

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...