Skip to main content

Microsoft Silverlight

Answered Question Catastrophic failure when accessing a shaderRSS Feed

(0)

TomGiam
TomGiam

Participant

Participant

788 points

220 Posts

Catastrophic failure when accessing a shader

 I have one pixel shader working fine from SL, but my second one is giving me this error: 

Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

I can't seem to find any problems with the file:

namespace Silver123 {

using System.Windows;

using System.Windows.Media;

using System.Windows.Media.Effects;

using System;

public class OpacityEdge : ShaderEffect

{

public static DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(OpacityEdge), 0);public static DependencyProperty OffProperty = DependencyProperty.Register("Off", typeof(double), typeof(OpacityEdge), new System.Windows.PropertyMetadata(0.0, PixelShaderConstantCallback(0)));

 

public OpacityEdge()

{

Uri u = new Uri("ImageEffects/OpacityEdge.ps", UriKind.RelativeOrAbsolute);

PixelShader = new PixelShader() { UriSource = u };

this.UpdateShaderValue(InputProperty);

this.UpdateShaderValue(OffProperty);

}

public virtual System.Windows.Media.Brush Input

{

get

{

return ((System.Windows.Media.Brush)(GetValue(InputProperty)));

}

set

{

SetValue(InputProperty,
value);

}

}

public virtual double Off

{

get

{

return ((double)(GetValue(OffProperty)));

}

set

{

SetValue(OffProperty,
value);

}

}

}

}

 

The OpacityEdge.ps file is in the ImageEffects folder.

 I use it like this:

OpacityEdge oe = new OpacityEdge();

oe.Off = 0.025;

photo.Effect = oe;  //Error occurs here

 

Thanks

Tom

 

ksleung
ksleung

Contributor

Contributor

5366 points

1,028 Posts

Answered Question

Re: Catastrophic failure when accessing a shader

From the look of it I didn't see anything wrong, so just some generic suggestions...

Did you try to see if your shader compiles and runs in Shazzem?  If it does, maybe you want to compare the difference between your C# code and Shazzem's auto-generated one.  Also, take a look to see whether the .ps file is really accessible (i.e. try to read it into a stream to see whether you succeed).

TomGiam
TomGiam

Participant

Participant

788 points

220 Posts

Re: Catastrophic failure when accessing a shader

Yes, I use Shazzam to compile and run all of my shaders.  The C# output from Shazzam is:

//------------------------------------------------------------------------------

// <auto-generated>

// This code was generated by a tool.

// Runtime Version:2.0.50727.3053

//

// Changes to this file may cause incorrect behavior and will be lost if

// the code is regenerated.

// </auto-generated>

//------------------------------------------------------------------------------

namespace
Shazzam.Shaders {

using System.Windows;

using System.Windows.Media;using System.Windows.Media.Effects;

 

 

public class AutoGenShaderEffect : ShaderEffect {

 

public static DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(AutoGenShaderEffect), 0);

 

public static DependencyProperty OffProperty = DependencyProperty.Register("Off", typeof(double), typeof(AutoGenShaderEffect), new System.Windows.UIPropertyMetadata(new double(), PixelShaderConstantCallback(0)));

 

public AutoGenShaderEffect(PixelShader shader) {// Note: for your project you must decide how to use the generated ShaderEffect class (Choose A or B below).

// A: Comment out the following line if you are not passing in the shader and remove the shader parameter from the constructor

PixelShader = shader;

// B: Uncomment the following two lines - which load the *.ps file

// Uri u = new Uri(@"pack://application:,,,/bandedswirl.ps");

// PixelShader = new PixelShader() { UriSource = u };

// Must initialize each DependencyProperty that's affliated with a shader register

// Ensures the shader initializes to the proper default value.

this.UpdateShaderValue(InputProperty);this.UpdateShaderValue(OffProperty);

}

 

public virtual System.Windows.Media.Brush Input {

get {

return ((System.Windows.Media.Brush)(GetValue(InputProperty)));

}

set {SetValue(InputProperty, value);

}

}

 

public virtual double Off {

get {

return ((double)(GetValue(OffProperty)));

}

set {SetValue(OffProperty, value);

}

}

}

}

 

You are right about suspecting the access to the .ps file.  I got the same error in my first shader when I gave it the wrong path to the .ps file.

However, this one looks correct... so I'm still looking into it.  I'll need to implement a read to make sure.

 

Thanks

Tom

 

TomGiam
TomGiam

Participant

Participant

788 points

220 Posts

Re: Catastrophic failure when accessing a shader

I found the problem...

I had forgotten to set the build action to "Content" for the .ps file.

 

Thanks

Tom

 

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities