Jump to content

Which light types can a shadow generator be used?


JCPalmer
 Share

Recommended Posts

In shadowGenerator.getTransformMatrix(), the light specified in the constructor has the method _computeTransformedPosition() called. 

 

The only light class that has this method is BABYLON.DirectionalLight (Sun in Blender terminology).  All light classes inherit from BABYLON.Light.  Might this getTransformMatrix() function only be called based on shadow map type(std or variance)?

 

I specified the following BABYLON.SpotLight to have a shadow generator:

 

function defineLights(scene){

    var light = new BABYLON.SpotLight("Lamp", new BABYLON.Vector3(-9,7,-10), new BABYLON.Vector3(0.5934,-0.4616,0.6594), 0.0175, 2, scene);
    light.id = "Lamp";
    light.intensity = 1;
    light.diffuse = new BABYLON.Color3(1,1,0.9);
    light.specular = new BABYLON.Color3(1,1,0.9);
}

 

The generator is specified after the mesh in the renderlist is also instanced here:

function defineShadowGen(scene){
    var light;
    var shadowGenerator;
    var renderList;
    light = scene.getLightByID("Lamp");

    shadowGenerator = new BABYLON.ShadowGenerator(512, light);
    shadowGenerator.useVarianceShadowMap = false;
    renderList = shadowGenerator.getShadowMap().renderList;
    renderList.push(scene.getMeshByID("myMesh"));
}

 

I get:

TypeError: this._light._computeTransformedPosition is not a function

 

SpotLights have both position and direction.  Am I missing something?  Thanks

 

Jeff

Link to comment
Share on other sites

Ok I switched to Directional (sun) and no error.  Still no shadow yet, but I need to double check the recievers.

 

function defineLights(scene){
    var  light = new BABYLON.DirectionalLight("Lamp", new BABYLON.Vector3(0.5934,-0.4616,0.6594), scene);
    light.position = new BABYLON.Vector3(-9,7,-10);
    light.id = "Lamp";
    light.intensity = 1;
    light.diffuse = new BABYLON.Color3(1,1,0.9);
    light.specular = new BABYLON.Color3(1,1,0.9);
}

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