locked
Custom Effect, Cant Find Shader File RRS feed

  • Question

  •  Hey,

    Im just writing a simple custom shader and whenever i try to run it it just keeps spitting out an error saying it cant find my .ps file.

    The project layout is:

    - EffectLib (Project)

       - Effects (Folder)

          - *.cs

       - Shaders (Folder)

          - *.ps

          - *.fx

     

    Then the line used within the effects cs file is:

    EffectLib;Shaders/TestShader.ps

     

    Do i need to compile the ps as an embedded resource or something? and is there any issues with loading them as external resources? i.e having them all stored on a website and get them loaded at runtime?

    Sunday, August 9, 2009 3:34 AM

Answers

  • Try this for your path...

    /EffectLib;/component/Shaders/TestShader.ps

    Oops meant this...

    /EffectLib;component/Shaders/TestShader.ps

    Sunday, August 9, 2009 8:58 AM

All replies

  • Try this for your path...

    /EffectLib;/component/Shaders/TestShader.ps

    Oops meant this...

    /EffectLib;component/Shaders/TestShader.ps

    Sunday, August 9, 2009 8:58 AM
  •  Same thing, ive tried doing every file combination i can think of, so i was thinking that it must be some sort of issue with how im referencing or linking the file to the project... like embedding it in the build or something...

    Sunday, August 9, 2009 9:48 AM
  • Ok I'm doing this successfully in my SilverSprite project, and this is what I have...

    Uri u = new Uri(@"/SilverArcade.SilverSprite;component/Shaders/ssdrawcolor.ps", UriKind.Relative);
    PixelShader = new PixelShader() { UriSource = u };

    The ps file is of content type "Resource". Make sure all of the slashes are in the appropriate places. You need one at the beginning and I accidentally had one before component but fixed that above.

    Sunday, August 9, 2009 10:09 AM
  •  Hey,

    Tried the above but still no luck... not sure if this would affect it but i have my effects and shaders in my EffectLib project, but these are being referenced and used in another project. Am i meant to make sure those shaders have the same structure within the same folder as the compiled silverlight app?

     

    I was hoping they would just be included within the projects dll as otherwise it would be a right pain to try and distribute...

    Sunday, August 9, 2009 1:46 PM
  •  I'm having a very similar issue. Bumping this up to see if anyone has any ideas. My Shader file is set to a Resource and this is how i have it setup in the project:

    Namespace for the shadereffect.cs file is :
    Game.Graphics

    Does the directory structure matter? Coz i have all the files something like this:
    Game/Graphics/Tiling/Shaders/shadereffect.cs
    and
    Game/Graphics/Tiling/Shaders/shader.ps

    Using in the shadereffect file like this:

       Uri u = new Uri(@"/Game;component/Graphics/Tiling/Shaders/LayerBlendingShader.ps", UriKind.RelativeOrAbsolute);
                pixelShader = new PixelShader();

                pixelShader.UriSource = u;

     

    I've tried various combinations to no avail. Any idea on what could be wrong? 

     

    Thanks

    Wednesday, September 16, 2009 5:30 AM
  •  Oh hey! i sorted this in the end... forgot to update the post... it was down to the contents of my string when i was trying to load the shader file, it was REALLY picky... anyway will check it when i get home and post on here for you...

    Wednesday, September 16, 2009 11:03 AM
  • 1. Set the ps file to Resource

    2. Load the file:

    pixelShader = new PixelShader();
    pixelShader.UriSource = new Uri("/PROJECTNAME;component/RELATIVEPATH/Grayscale.ps", UriKind.Relative);

     

     

    Wednesday, September 16, 2009 11:30 AM