XNA Creators Club Online
Page 1 of 1 (2 items)
Sort Posts: Previous Next

Problem binding directional light to XSISASContainer

Last post 8/30/2008 2:50 PM by HappyHombre. 1 replies.
  • 8/30/2008 1:46 PM

    Problem binding directional light to XSISASContainer

    My effect shader contains this SAS binding for the directional light:

    float4 lightDir
    <
    string SasBindAddress = "SAS.DIRECTIONALLIGHT[0].DIRECTION";
    >;

    float4 lightColor
    <
    string SasBindAddress = "SAS.DIRECTIONALLIGHT[0].COLOR";
    >;

    I'm setting up the directional light in my code like this:

    sasContainer = new XSISASContainer();
    sasContainer.DirectionalLights.Add(new XSISASDirectionalLight());
    sasContainer.DirectionalLights[0].Color = Color.White.ToVector4();
    sasContainer.DirectionalLights[0].Direction = new Vector4(Vector3.Forward, 0.0f);

    When I run my application the scene is all black.

    However, if I explicity bind the lightDir and lightColor effect parameters like this:

    effect.Parameters["lightDir"].SetValue(sasContainer.DirectionalLights[0].Direction);
    effect.Parameters["lightColor"].SetValue(sasContainer.DirectionalLights[0].Color);

    Then everything works as expected. Has anyone else encountered anything similar?
  • 8/30/2008 2:50 PM In reply to

    Re: Problem binding directional light to XSISASContainer

    Ok I think I've solved this one.

    Changing the SasBindAddress for the directional light annotations to:

    float4 lightDir
    <
    string SasBindAddress = "SAS.DIRECTIONALLIGHTS[0].DIRECTION";
    >;

    float4 lightColor
    <
    string SasBindAddress = "SAS.DIRECTIONALLIGHTS[0].COLOR";
    >;

    Seems to fix everything.

    According to the DXSAS standard effect include file and the DXSAS documentation in the DXSDK the bind address should be SAS.DIRECTIONALLIGHT not SAS.DIRECTIONALLIGHTS. The source code to the XSI XNA Runtime library does include hardcoded string literals for SAS.DIRECTIONALLIGHTS.COLOR and SAS.DIRECTIONALLIGHTS.DIRECTION.
Page 1 of 1 (2 items) Previous Next