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

    --
    "Back in my day, we didn't have Wiis. The best we had were chunky, irregularly shaped systems that were named after their processors or whether they had color or not. You could only play them if you had three hands, the joysticks only lasted 2 weeks before falling out, and they used cartridges (those are like DS Cards, only way bigger, and they run on dust and spit), but most kids played ‘em anyway. The best games were about a little boy in a green skirt that killed an old puke-brown-skinned red-haired organ-playing dinosaur-man, kept a boomerang, a slingshot, a bow, and bombs in his pocketless tights, and befriended a cross-dressing princess that stalked him. There was also the one game about a short Italian plumber that ate wild mushrooms, jumped off walls, slaughtered cute little turtles just because they were in his way, and killed the last of the dinosaurs, a dragon named Bowser. Those were the days..."
    --Michael Hoffmann
  • 8/7/2009 6:34 PM In reply to
    • (242)
    • premium membership Team XNA
    • Posts 201

    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