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

HLSL distance function

Last post 8/7/2009 6:34 PM by Dean. 1 replies.
  • 6/26/2009 8:59 PM

    HLSL distance function

    Hi, I'm a long time reader, first time poster in these forums so please forgive me if this post is in the wrong section.

    I've been having a problem with the HLSL distance function in my pixel shader.

    Here is my code:

    float3 Dist = distance(LightSource.xyz, In.AimDirection.xyz);
    And here's my exception message:


    Error 1 Errors compiling C:\Users\Public\Michael's Projects\XNA\Game\Game\Content\SkyBox.fx:
    C:\Users\Public\Michael's Projects\XNA\Game\Game\Content\SkyBox.fx(35): warning X4707: texcoord inputs used directly (that is, other than sampling from textures) in shader body in ps_1_1 are always clamped from 0 to 1
    C:\Users\Public\Michael's Projects\XNA\Game\Game\Content\SkyBox.fx(35): error X4532: cannot map expression to pixel shader instruction set
    C:\Users\Public\Michael's Projects\XNA\Game\Game\Content\SkyBox.fx(46): ID3DXEffectCompiler::CompileEffect: There was an error compiling expression
    ID3DXEffectCompiler: Compilation failed C:\Users\Public\Michael's Projects\XNA\Game\Game\Content\SkyBox.fx 35 1


    I have no idea what that whole texcoord stuff is about...
    Thanks in advance for any help.

    --Michael

    "It's pure sawesome!"
    http://hr.michaelgh.com/
  • 8/7/2009 6:34 PM In reply to
    • (258)
    • premium membership Team XNA
    • Posts 209

    Re: HLSL distance function

    Not sure if you are still having issues. But from the looks of your code you are expecting the distance function to return a float3 when it only returns a float for the distance. http://msdn.microsoft.com/en-us/library/bb509592(VS.85).aspx
    Dean Johnson, XNA Framework Developer - Blog: Nerd Herder
Page 1 of 1 (2 items) Previous Next