X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=dev5%2Fpsychlops%2Fextension%2Fstandard%2Fshader.cs;fp=dev5%2Fpsychlops%2Fextension%2Fstandard%2Fshader.cs;h=7d5387a8b8cd543b40ccaeecd5be4074efddbe8e;hb=08bcb090f6a3e6ee38c712571f24b57a4dd32fb4;hp=0000000000000000000000000000000000000000;hpb=7fe25aa821826f09903fb14def74d6b0376e3b5a;p=psychlops%2Fsilverlight.git
diff --git a/dev5/psychlops/extension/standard/shader.cs b/dev5/psychlops/extension/standard/shader.cs
new file mode 100644
index 0000000..7d5387a
--- /dev/null
+++ b/dev5/psychlops/extension/standard/shader.cs
@@ -0,0 +1,845 @@
+//------------------------------------------------------------------------------
+//
+// ãã®ã³ã¼ãã¯ãã¼ã«ã«ãã£ã¦çæããã¾ããã
+// ã©ã³ã¿ã¤ã ãã¼ã¸ã§ã³:4.0.30319.1
+//
+// ãã®ãã¡ã¤ã«ã¸ã®å¤æ´ã¯ã以ä¸ã®ç¶æ³ä¸ã§ä¸æ£ãªåä½ã®åå ã«ãªã£ããã
+// ã³ã¼ããåçæãããã¨ãã«æ失ããããã¾ãã
+//
+//------------------------------------------------------------------------------
+
+using System;
+using System.Windows;
+using System.Windows.Media;
+using System.Windows.Media.Effects;
+using System.Windows.Media.Media3D;
+
+
+namespace Psychlops
+{
+
+
+ public static partial class Figures
+ {
+
+ public class ShaderGrating : ShaderField
+ {
+ protected Shader.GratingProgram ps = null;
+ public ShaderGrating()
+ {
+ initialize__ = initialize___;
+ setParameters = setParameters__;
+ }
+ internal void initialize()
+ {
+ if (!initialized)
+ {
+ Main.canvas.beginInvoke(initialize___);
+ initialized = true;
+ }
+ }
+ internal void initialize___()
+ {
+ if (!initialized)
+ {
+ if (ps == null)
+ {
+ ps = new Shader.GratingProgram();
+ initializeShader();
+ }
+ shader = ps;
+ initialized = true;
+ }
+ }
+
+ public double contrast = 1.0, wavelength = 20.0, phase = 0.0, orientation = 0.0;
+ public ShaderGrating setSize(double s) { set(s, s); return this; }
+ public ShaderGrating setSize(double h, double v) { set(h, v); return this; }
+
+ public void setParameters__()
+ {
+ ps.Contrast = contrast;
+ ps.WaveLength = wavelength;
+ ps.Phase = phase;
+ ps.Orientation = orientation;
+ ps.SizeH = width;
+ ps.SizeV = height;
+ ps.Update();
+ }
+
+
+ }
+
+
+ public class ShaderPlaid : ShaderField
+ {
+ protected Shader.PlaidProgram ps = null;
+ public ShaderPlaid()
+ {
+ initialize__ = initialize___;
+ setParameters = setParameters__;
+ }
+ internal void initialize()
+ {
+ if (!initialized)
+ {
+ Main.canvas.beginInvoke(initialize___);
+ initialized = true;
+ }
+ }
+ internal void initialize___()
+ {
+ if (!initialized)
+ {
+ if (ps == null)
+ {
+ ps = new Shader.PlaidProgram();
+ initializeShader();
+ }
+ shader = ps;
+ initialized = true;
+ }
+ }
+
+ public double contrast = 0.5, wavelength = 20.0, phase = 0.0, orientation = 0.0;
+ public double contrast2 = 0.5, wavelength2 = 20.0, phase2 = 0.0, orientation2 = Math.PI / 4;
+ public ShaderPlaid setSize(double s) { set(s, s); return this; }
+ public ShaderPlaid setSize(double h, double v) { set(h, v); return this; }
+
+ public void setParameters__()
+ {
+ ps.Contrast = contrast;
+ ps.WaveLength = wavelength;
+ ps.Phase = phase;
+ ps.Orientation = orientation;
+ ps.Size = width;
+ ps.Contrast2 = contrast;
+ ps.WaveLength2 = wavelength;
+ ps.Phase2 = phase;
+ ps.Orientation2 = orientation;
+ ps.SizeH = width;
+ ps.SizeV = height;
+ ps.Update();
+ }
+
+
+ }
+
+
+ public class ShaderGabor : ShaderField
+ {
+ protected Shader.GaborProgram ps = null;
+ public ShaderGabor()
+ {
+ initialize__ = initialize___;
+ setParameters = setParameters__;
+ }
+ internal void initialize()
+ {
+ if (!initialized)
+ {
+ Main.canvas.beginInvoke(initialize___);
+ initialized = true;
+ }
+ }
+ internal void initialize___()
+ {
+ if (!initialized)
+ {
+ if (ps == null)
+ {
+ ps = new Shader.GaborProgram();
+ initializeShader();
+ }
+ shader = ps;
+ initialized = true;
+ }
+ }
+
+ //public double contrast { get; set; }
+ //public double frequency { get; set; }
+ //public double phase { get; set; }
+ //public double orientation { get; set; }
+ public double contrast = 1.0, wavelength = 20.0, phase = 0.0, orientation = 0.0, alpha = 1.0;
+ public ShaderGabor setSigma(double s)
+ {
+ set(s*8, s*8);
+ return this;
+ }
+
+ public void setParameters__()
+ {
+ ps.Contrast = contrast;
+ ps.WaveLength = wavelength;
+ ps.Phase = phase;
+ ps.Orientation = orientation;
+ ps.Sigma = 4.0;
+ ps.Size = width;
+ ps.Alpha = alpha;
+ ps.Update();
+ }
+
+
+ }
+
+
+ public class ShaderGaborAlpha : ShaderField
+ {
+ protected Shader.GaborAlphaProgram ps = null;
+ public ShaderGaborAlpha()
+ {
+ initialize__ = initialize___;
+ setParameters = setParameters__;
+ }
+ internal void initialize()
+ {
+ if (!initialized)
+ {
+ Main.canvas.beginInvoke(initialize___);
+ initialized = true;
+ }
+ }
+ internal void initialize___()
+ {
+ if (!initialized)
+ {
+ if (ps == null)
+ {
+ ps = new Shader.GaborAlphaProgram();
+ initializeShader();
+ }
+ shader = ps;
+ initialized = true;
+ }
+ }
+
+ //public double contrast { get; set; }
+ //public double frequency { get; set; }
+ //public double phase { get; set; }
+ //public double orientation { get; set; }
+ public double contrast = 1.0, wavelength = 20.0, phase = 0.0, orientation = 0.0, alpha = 1.0;
+ public ShaderGaborAlpha setSigma(double s)
+ {
+ set(s * 8, s * 8);
+ return this;
+ }
+
+ public void setParameters__()
+ {
+ ps.Contrast = contrast;
+ ps.WaveLength = wavelength;
+ ps.Phase = phase;
+ ps.Orientation = orientation;
+ ps.Sigma = 4.0;
+ ps.Size = width;
+ ps.Alpha = alpha;
+ ps.Update();
+ }
+
+
+ }
+ }
+
+
+ namespace Shader
+ {
+ internal static partial class Connector
+ {
+ internal delegate void PixelShaderConnector(ShaderEffect q, Uri s);
+ }
+
+
+ public abstract class ShaderProgram : ShaderEffect
+ {
+ }
+
+ #region GratingProgram
+ public class GratingProgram : ShaderProgram
+ {
+ public static readonly Uri ps = new Uri(@"/PsychlopsSilverlight5;component/Shader/Grating.ps", UriKind.Relative);
+
+ public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(GratingProgram), 0);
+ public static readonly DependencyProperty ContrastProperty = DependencyProperty.Register("Contrast", typeof(double), typeof(GratingProgram), new PropertyMetadata(((double)(1D)), PixelShaderConstantCallback(1)));
+ public static readonly DependencyProperty FrequencyProperty = DependencyProperty.Register("Frequency", typeof(double), typeof(GratingProgram), new PropertyMetadata(((double)(100D)), PixelShaderConstantCallback(2)));
+ public static readonly DependencyProperty PhaseProperty = DependencyProperty.Register("Phase", typeof(double), typeof(GratingProgram), new PropertyMetadata(((double)(0D)), PixelShaderConstantCallback(3)));
+ public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register("Orientation", typeof(double), typeof(GratingProgram), new PropertyMetadata(((double)(0D)), PixelShaderConstantCallback(4)));
+ public static readonly DependencyProperty SizeHProperty = DependencyProperty.Register("SizeH", typeof(double), typeof(GratingProgram), new PropertyMetadata(((double)(32D)), PixelShaderConstantCallback(5)));
+ public static readonly DependencyProperty SizeVProperty = DependencyProperty.Register("SizeV", typeof(double), typeof(GratingProgram), new PropertyMetadata(((double)(32D)), PixelShaderConstantCallback(6)));
+ public GratingProgram()
+ {
+ PixelShader pixelShader = new PixelShader();
+ pixelShader.UriSource = ps;
+ this.PixelShader = pixelShader;
+
+ this.UpdateShaderValue(InputProperty);
+ this.UpdateShaderValue(ContrastProperty);
+ this.UpdateShaderValue(FrequencyProperty);
+ this.UpdateShaderValue(PhaseProperty);
+ this.UpdateShaderValue(OrientationProperty);
+ this.UpdateShaderValue(SizeHProperty);
+ this.UpdateShaderValue(SizeVProperty);
+
+ Size = 200;
+ Contrast = 1.0;
+ WaveLength = 100.0;
+ Orientation = 0.0;
+ SizeH = 32.0;
+ SizeV = 32.0;
+ }
+
+ public void Update()
+ {
+ this.UpdateShaderValue(InputProperty);
+ this.UpdateShaderValue(ContrastProperty);
+ this.UpdateShaderValue(FrequencyProperty);
+ this.UpdateShaderValue(PhaseProperty);
+ this.UpdateShaderValue(OrientationProperty);
+ this.UpdateShaderValue(SizeHProperty);
+ this.UpdateShaderValue(SizeVProperty);
+ }
+
+
+ private double size__, wavelength__;
+ public double Size { get { return size__; } set { size__ = value; setFrequency(); } }
+ private void setFrequency()
+ {
+ double freq = size__ * 2.0 * Math.PI / (wavelength__);
+ this.SetValue(FrequencyProperty, freq);
+ }
+
+ /// Amplitude of Grating
+ public double Contrast
+ {
+ get
+ {
+ return ((double)(this.GetValue(ContrastProperty))) * 2.0;
+ }
+ set
+ {
+ this.SetValue(ContrastProperty, value / 2.0);
+ }
+ }
+ /// Phase of Grating
+ public double WaveLength
+ {
+ get
+ {
+ return wavelength__;
+ }
+ set
+ {
+ wavelength__ = value;
+ setFrequency();
+ }
+ }
+ /// Phase of Grating
+ public double Phase
+ {
+ get
+ {
+ return ((double)(this.GetValue(PhaseProperty)));
+ }
+ set
+ {
+ this.SetValue(PhaseProperty, value);
+ }
+ }
+ /// Orientation of Grating
+ public double Orientation
+ {
+ get
+ {
+ return ((double)(this.GetValue(OrientationProperty)));
+ }
+ set
+ {
+ this.SetValue(OrientationProperty, value);
+ }
+ }
+ /// Width of envelope
+ public double SizeH
+ {
+ get
+ {
+ return ((double)(this.GetValue(SizeHProperty)));
+ }
+ set
+ {
+ this.SetValue(SizeHProperty, value);
+ }
+ }
+ /// Height of Figure
+ public double SizeV
+ {
+ get
+ {
+ return ((double)(this.GetValue(SizeVProperty)));
+ }
+ set
+ {
+ this.SetValue(SizeVProperty, value);
+ }
+ }
+ }
+ #endregion
+
+ #region PlaidProgram
+ public class PlaidProgram : ShaderProgram
+ {
+ public static readonly Uri ps = new Uri(@"/PsychlopsSilverlight5;component/Shader/Plaid.ps", UriKind.Relative);
+
+ public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(PlaidProgram), 0);
+ public static readonly DependencyProperty ContrastProperty = DependencyProperty.Register("Contrast", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(0.5D)), PixelShaderConstantCallback(1)));
+ public static readonly DependencyProperty FrequencyProperty = DependencyProperty.Register("Frequency", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(100D)), PixelShaderConstantCallback(2)));
+ public static readonly DependencyProperty PhaseProperty = DependencyProperty.Register("Phase", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(0D)), PixelShaderConstantCallback(3)));
+ public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register("Orientation", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(0D)), PixelShaderConstantCallback(4)));
+ public static readonly DependencyProperty Contrast2Property = DependencyProperty.Register("Contrast2", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(0.5D)), PixelShaderConstantCallback(5)));
+ public static readonly DependencyProperty Frequency2Property = DependencyProperty.Register("Frequency2", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(100D)), PixelShaderConstantCallback(6)));
+ public static readonly DependencyProperty Phase2Property = DependencyProperty.Register("Phase2", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(0D)), PixelShaderConstantCallback(7)));
+ public static readonly DependencyProperty Orientation2Property = DependencyProperty.Register("Orientation2", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(0.785398D)), PixelShaderConstantCallback(8)));
+ public static readonly DependencyProperty SizeHProperty = DependencyProperty.Register("SizeH", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(32D)), PixelShaderConstantCallback(9)));
+ public static readonly DependencyProperty SizeVProperty = DependencyProperty.Register("SizeV", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(32D)), PixelShaderConstantCallback(10)));
+ public PlaidProgram()
+ {
+ PixelShader pixelShader = new PixelShader();
+ pixelShader.UriSource = ps;
+ this.PixelShader = pixelShader;
+
+ this.UpdateShaderValue(InputProperty);
+ this.UpdateShaderValue(ContrastProperty);
+ this.UpdateShaderValue(FrequencyProperty);
+ this.UpdateShaderValue(PhaseProperty);
+ this.UpdateShaderValue(OrientationProperty);
+ this.UpdateShaderValue(Contrast2Property);
+ this.UpdateShaderValue(Frequency2Property);
+ this.UpdateShaderValue(Phase2Property);
+ this.UpdateShaderValue(Orientation2Property);
+ this.UpdateShaderValue(SizeHProperty);
+ this.UpdateShaderValue(SizeVProperty);
+
+ Size = 200;
+ Contrast = 0.5;
+ WaveLength = 100.0;
+ Phase = 0.0;
+ Orientation = 0.0;
+ Contrast2 = 0.5;
+ WaveLength2 = 100.0;
+ Phase2 = 0.0;
+ Orientation2 = Math.PI/4;
+ SizeH = 32.0;
+ SizeV = 32.0;
+ }
+
+ public void Update()
+ {
+ this.UpdateShaderValue(InputProperty);
+ this.UpdateShaderValue(ContrastProperty);
+ this.UpdateShaderValue(FrequencyProperty);
+ this.UpdateShaderValue(PhaseProperty);
+ this.UpdateShaderValue(OrientationProperty);
+ this.UpdateShaderValue(Contrast2Property);
+ this.UpdateShaderValue(Frequency2Property);
+ this.UpdateShaderValue(Phase2Property);
+ this.UpdateShaderValue(Orientation2Property);
+ this.UpdateShaderValue(SizeHProperty);
+ this.UpdateShaderValue(SizeVProperty);
+ }
+
+
+ private double size__, wavelength__, wavelength2__;
+ public double Size { get { return size__; } set { size__ = value; setFrequency(); } }
+ private void setFrequency()
+ {
+ double freq = size__ * 2.0 * Math.PI / (wavelength__);
+ this.SetValue(FrequencyProperty, freq);
+ double freq2 = size__ * 2.0 * Math.PI / (wavelength2__);
+ this.SetValue(Frequency2Property, freq);
+ }
+
+ /// Amplitude of Grating
+ public double Contrast
+ {
+ get
+ {
+ return ((double)(this.GetValue(ContrastProperty))) * 2.0;
+ }
+ set
+ {
+ this.SetValue(ContrastProperty, value / 2.0);
+ }
+ }
+ /// Phase of Grating
+ public double WaveLength
+ {
+ get
+ {
+ return wavelength__;
+ }
+ set
+ {
+ wavelength__ = value;
+ setFrequency();
+ }
+ }
+ /// Phase of Grating
+ public double Phase
+ {
+ get
+ {
+ return ((double)(this.GetValue(PhaseProperty)));
+ }
+ set
+ {
+ this.SetValue(PhaseProperty, value);
+ }
+ }
+ /// Orientation of Grating
+ public double Orientation
+ {
+ get
+ {
+ return ((double)(this.GetValue(OrientationProperty)));
+ }
+ set
+ {
+ this.SetValue(OrientationProperty, value);
+ }
+ }
+ /// Amplitude of Grating
+ public double Contrast2
+ {
+ get
+ {
+ return ((double)(this.GetValue(Contrast2Property))) * 2.0;
+ }
+ set
+ {
+ this.SetValue(Contrast2Property, value / 2.0);
+ }
+ }
+ /// Phase of Grating
+ public double WaveLength2
+ {
+ get
+ {
+ return wavelength2__;
+ }
+ set
+ {
+ wavelength2__ = value;
+ setFrequency();
+ }
+ }
+ /// Phase2 of Grating
+ public double Phase2
+ {
+ get
+ {
+ return ((double)(this.GetValue(Phase2Property)));
+ }
+ set
+ {
+ this.SetValue(Phase2Property, value);
+ }
+ }
+ /// Orientation2 of Grating
+ public double Orientation2
+ {
+ get
+ {
+ return ((double)(this.GetValue(Orientation2Property)));
+ }
+ set
+ {
+ this.SetValue(Orientation2Property, value);
+ }
+ }
+ /// Width of envelope
+ public double SizeH
+ {
+ get
+ {
+ return ((double)(this.GetValue(SizeHProperty)));
+ }
+ set
+ {
+ this.SetValue(SizeHProperty, value);
+ }
+ }
+ /// Height of Figure
+ public double SizeV
+ {
+ get
+ {
+ return ((double)(this.GetValue(SizeVProperty)));
+ }
+ set
+ {
+ this.SetValue(SizeVProperty, value);
+ }
+ }
+ }
+ #endregion
+
+ #region GaborProgram
+ public class GaborProgram : ShaderProgram
+ {
+ public static readonly Uri ps = new Uri(@"/PsychlopsSilverlight5;component/Shader/Gabor.ps", UriKind.Relative);
+
+ public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(GaborProgram), 0);
+ public static readonly DependencyProperty ContrastProperty = DependencyProperty.Register("Contrast", typeof(double), typeof(GaborProgram), new PropertyMetadata(((double)(1D)), PixelShaderConstantCallback(1)));
+ public static readonly DependencyProperty FrequencyProperty = DependencyProperty.Register("Frequency", typeof(double), typeof(GaborProgram), new PropertyMetadata(((double)(100D)), PixelShaderConstantCallback(2)));
+ public static readonly DependencyProperty PhaseProperty = DependencyProperty.Register("Phase", typeof(double), typeof(GaborProgram), new PropertyMetadata(((double)(0D)), PixelShaderConstantCallback(3)));
+ public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register("Orientation", typeof(double), typeof(GaborProgram), new PropertyMetadata(((double)(0D)), PixelShaderConstantCallback(4)));
+ public static readonly DependencyProperty SigmaProperty = DependencyProperty.Register("Sigma", typeof(double), typeof(GaborProgram), new PropertyMetadata(((double)(4D)), PixelShaderConstantCallback(5)));
+ public static readonly DependencyProperty AlphaProperty = DependencyProperty.Register("Alpha", typeof(double), typeof(GaborProgram), new PropertyMetadata(((double)(1D)), PixelShaderConstantCallback(6)));
+ public GaborProgram()
+ {
+ PixelShader pixelShader = new PixelShader();
+ pixelShader.UriSource = ps;
+ this.PixelShader = pixelShader;
+
+ this.UpdateShaderValue(InputProperty);
+ this.UpdateShaderValue(ContrastProperty);
+ this.UpdateShaderValue(FrequencyProperty);
+ this.UpdateShaderValue(PhaseProperty);
+ this.UpdateShaderValue(OrientationProperty);
+ this.UpdateShaderValue(SigmaProperty);
+ this.UpdateShaderValue(AlphaProperty);
+
+ Size = 200;
+ Contrast = 1.0;
+ WaveLength = 100.0;
+ Orientation = 0.0;
+ Sigma = 4.0;
+ Alpha = 1.0;
+ }
+
+ public void Update()
+ {
+ this.UpdateShaderValue(InputProperty);
+ this.UpdateShaderValue(ContrastProperty);
+ this.UpdateShaderValue(FrequencyProperty);
+ this.UpdateShaderValue(PhaseProperty);
+ this.UpdateShaderValue(OrientationProperty);
+ this.UpdateShaderValue(SigmaProperty);
+ this.UpdateShaderValue(AlphaProperty);
+ }
+
+
+ private double size__, wavelength__;
+ public double Size { get { return size__; } set { size__ = value; setFrequency(); } }
+ private void setFrequency()
+ {
+ double freq = size__ * 2.0 * Math.PI / (wavelength__);
+ this.SetValue(FrequencyProperty, freq);
+ }
+
+ /// Amplitude of Grating
+ public double Contrast
+ {
+ get
+ {
+ return ((double)(this.GetValue(ContrastProperty))) * 2.0;
+ }
+ set
+ {
+ this.SetValue(ContrastProperty, value / 2.0);
+ }
+ }
+ /// Phase of Grating
+ public double WaveLength
+ {
+ get
+ {
+ return wavelength__;
+ }
+ set
+ {
+ wavelength__ = value;
+ setFrequency();
+ }
+ }
+ /// Phase of Grating
+ public double Phase
+ {
+ get
+ {
+ return ((double)(this.GetValue(PhaseProperty)));
+ }
+ set
+ {
+ this.SetValue(PhaseProperty, value);
+ }
+ }
+ /// Orientation of Grating
+ public double Orientation
+ {
+ get
+ {
+ return ((double)(this.GetValue(OrientationProperty)));
+ }
+ set
+ {
+ this.SetValue(OrientationProperty, value);
+ }
+ }
+ /// Half bandwidth of envelope
+ public double Sigma
+ {
+ get
+ {
+ return ((double)(this.GetValue(SigmaProperty)));
+ }
+ set
+ {
+ this.SetValue(SigmaProperty, value);
+ }
+ }
+ /// Transparency of Figure
+ public double Alpha
+ {
+ get
+ {
+ return ((double)(this.GetValue(AlphaProperty)));
+ }
+ set
+ {
+ this.SetValue(AlphaProperty, value);
+ }
+ }
+ }
+ #endregion
+
+ #region GaborAlphaProgram
+ public class GaborAlphaProgram : ShaderProgram
+ {
+ public static readonly Uri ps = new Uri(@"/PsychlopsSilverlight5;component/Shader/GaborAlpha.ps", UriKind.Relative);
+
+ public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(GaborAlphaProgram), 0);
+ public static readonly DependencyProperty ContrastProperty = DependencyProperty.Register("Contrast", typeof(double), typeof(GaborAlphaProgram), new PropertyMetadata(((double)(1D)), PixelShaderConstantCallback(1)));
+ public static readonly DependencyProperty FrequencyProperty = DependencyProperty.Register("Frequency", typeof(double), typeof(GaborAlphaProgram), new PropertyMetadata(((double)(100D)), PixelShaderConstantCallback(2)));
+ public static readonly DependencyProperty PhaseProperty = DependencyProperty.Register("Phase", typeof(double), typeof(GaborAlphaProgram), new PropertyMetadata(((double)(0D)), PixelShaderConstantCallback(3)));
+ public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register("Orientation", typeof(double), typeof(GaborAlphaProgram), new PropertyMetadata(((double)(0D)), PixelShaderConstantCallback(4)));
+ public static readonly DependencyProperty SigmaProperty = DependencyProperty.Register("Sigma", typeof(double), typeof(GaborAlphaProgram), new PropertyMetadata(((double)(4D)), PixelShaderConstantCallback(5)));
+ public static readonly DependencyProperty AlphaProperty = DependencyProperty.Register("Alpha", typeof(double), typeof(GaborAlphaProgram), new PropertyMetadata(((double)(1D)), PixelShaderConstantCallback(6)));
+ public GaborAlphaProgram()
+ {
+ PixelShader pixelShader = new PixelShader();
+ pixelShader.UriSource = ps;
+ this.PixelShader = pixelShader;
+
+ this.UpdateShaderValue(InputProperty);
+ this.UpdateShaderValue(ContrastProperty);
+ this.UpdateShaderValue(FrequencyProperty);
+ this.UpdateShaderValue(PhaseProperty);
+ this.UpdateShaderValue(OrientationProperty);
+ this.UpdateShaderValue(SigmaProperty);
+ this.UpdateShaderValue(AlphaProperty);
+
+ Size = 200;
+ Contrast = 1.0;
+ WaveLength = 100.0;
+ Orientation = 0.0;
+ Sigma = 4.0;
+ Alpha = 1.0;
+ }
+
+ public void Update()
+ {
+ this.UpdateShaderValue(InputProperty);
+ this.UpdateShaderValue(ContrastProperty);
+ this.UpdateShaderValue(FrequencyProperty);
+ this.UpdateShaderValue(PhaseProperty);
+ this.UpdateShaderValue(OrientationProperty);
+ this.UpdateShaderValue(SigmaProperty);
+ this.UpdateShaderValue(AlphaProperty);
+ }
+
+
+ private double size__, wavelength__;
+ public double Size { get { return size__; } set { size__ = value; setFrequency(); } }
+ private void setFrequency()
+ {
+ double freq = size__ * 2.0 * Math.PI / (wavelength__);
+ this.SetValue(FrequencyProperty, freq);
+ }
+
+ /// Amplitude of Grating
+ public double Contrast
+ {
+ get
+ {
+ return ((double)(this.GetValue(ContrastProperty))) * 2.0;
+ }
+ set
+ {
+ this.SetValue(ContrastProperty, value / 2.0);
+ }
+ }
+ /// Phase of Grating
+ public double WaveLength
+ {
+ get
+ {
+ return wavelength__;
+ }
+ set
+ {
+ wavelength__ = value;
+ setFrequency();
+ }
+ }
+ /// Phase of Grating
+ public double Phase
+ {
+ get
+ {
+ return ((double)(this.GetValue(PhaseProperty)));
+ }
+ set
+ {
+ this.SetValue(PhaseProperty, value);
+ }
+ }
+ /// Orientation of Grating
+ public double Orientation
+ {
+ get
+ {
+ return ((double)(this.GetValue(OrientationProperty)));
+ }
+ set
+ {
+ this.SetValue(OrientationProperty, value);
+ }
+ }
+ /// Half bandwidth of envelope
+ public double Sigma
+ {
+ get
+ {
+ return ((double)(this.GetValue(SigmaProperty)));
+ }
+ set
+ {
+ this.SetValue(SigmaProperty, value);
+ }
+ }
+ /// Transparency of Figure
+ public double Alpha
+ {
+ get
+ {
+ return ((double)(this.GetValue(AlphaProperty)));
+ }
+ set
+ {
+ this.SetValue(AlphaProperty, value);
+ }
+ }
+ }
+ #endregion
+
+ }
+}
\ No newline at end of file