Welcome to Windows Presentation Foundation (WPF)
Top Tasks :

WPF Team Bloggers

Thursday, May 15, 2008 - Posts

  • Writing custom Effects - adding parameters to Effects

    A couple of posts ago , I wrote about writing custom Effects.  The example that I dove into was ColorComplementEffect, an Effect that has no parameters other than the incoming "sampler" that it inverts the color on. This post is going to go into what it takes to add parameters to your Effects, which allows for much, much more powerful Effects. Shader Constants and Dependency Properties The first thing to understand is that HLSL shaders expose "shader constants" bound to "shader registers".  We saw a shader constant in the form of a "sampler2D" called "implicitInput" in the previous post on writing Effects: sampler2D implicitInput : register(s0); The parameters we discuss here will be shader constants of type float, float2, float3, or float4 in HLSL.  These shader constants maintain their value for an entire "frame" of the pixel shader executing across every pixel in the frame.  This is why they're called "shader Read More...

Copyright © 2006 Microsoft Corporation. All Rights Reserved. | Terms of Use | Privacy Statement | Contact Us