This project is read-only.
Project Description
ShaderPad is a application like XamlPad / LinqPad , it is meant to server as WPF ShaderEffects Workbench. The ShaderEffect is a PixelShader based Effect that an be applied to any UIElement in WPF. This feature is available only in .NET 3.5 SP1 .
ShaderPad_release080811_sc2.png
Pre Requisites
.NET 3.5 SP1 : Download.
Direct X SDK : Download June 2008.

More information
blog articles
ShaderEffect Basics

 Random Bits News Feed 
Tuesday, August 12, 2008  |  From Random Bits

With the RTM of .NET 3.5 SP1 , we can now create hardware accelerated layer blending effects in WPF like those available in Image Editing tools & Photoshop & GIMP

some of the common blending modes are

Darken, Darker Colors preferred.
darken

sampler2D input : register(s0);
sampler2D tex1 : register(s1);

float4 main(float2 uv : TEXCOORD) : COLOR
{
float4 clr1;
clr1= tex2D(tex1, uv.xy);

float4 Color;
Color= tex2D( input , uv.xy);

if (Color.r>clr1.r) Color.r=clr1.r;
if (Color.g>clr1.g) Color.g=clr1.g;
if (Color.b>clr1.b) Color.b=clr1.b;

return Color;
}

Lighten, Lighter Colors preferred.
Lighten

sampler2D input : register(s0);
sampler2D tex1 : register(s1);


float4 main(float2 uv : TEXCOORD) : COLOR
{
float4 clr1;
clr1= tex2D(tex1, uv.xy);

float4 Color;
Color= tex2D( input , uv.xy);

if (Color.r<clr1.r) Color.r=clr1.r;
if (Color.g<clr1.g) Color.g=clr1.g;
if (Color.b<clr1.b) Color.b=clr1.b;

return Color;
}

Difference, Simple Arithmetic difference on color components.
Difference

sampler2D input : register(s0);
sampler2D tex1 : register(s1);

float4 main(float2 uv : TEXCOORD) : COLOR
{
float4 clr1;
clr1= tex2D(tex1, uv.xy);

float4 Color;
Color= tex2D( input , uv.xy);

Color.r=clr1.r - Color.r;
Color.g=clr1.g - Color.g;
Color.b=clr1.b - Color.b;

return Color;
}

Multiply, Simple Arithmetic Multiplication on color components.
Multiply

sampler2D input : register(s0);
sampler2D tex1 : register(s1);
float4 main(float2 uv : TEXCOORD) : COLOR
{
float4 clr1;
clr1= tex2D(tex1, uv.xy);

float4 Color;
Color= tex2D( input , uv.xy);

Color.r=clr1.r * Color.r;
Color.g=clr1.g * Color.g;
Color.b=clr1.b * Color.b;

return Color;
}

NegationDifference, opposite or negative of difference
NegationDifference

sampler2D input : register(s0);
sampler2D tex1 : register(s1);

float4 main(float2 uv : TEXCOORD) : COLOR
{
float4 clr1;
clr1= tex2D(tex1, uv.xy);

float4 Color;
Color= tex2D( input , uv.xy);

Color.r=1-(1-clr1.r - Color.r);
Color.g=1-(1-clr1.g - Color.g);
Color.b=1-(1-clr1.b - Color.b);

return Color;
}

Overlay Hardlight, Combination of Multiply for darer colors and NegationDifference for Lighter colors.
overlayHard

sampler2D input : register(s0);
sampler2D tex1 : register(s1);

float4 main(float2 uv : TEXCOORD) : COLOR
{
float4 clr1;
clr1= tex2D(tex1, uv.xy);

float4 Color;
Color= tex2D( input , uv.xy);
if (Color.r<0.5)
Color.r=clr1.r * Color.r;
else
Color.r=1-((1-Color.r)*(1-clr1.r));

if (Color.g<0.5)
Color.g=clr1.g * Color.g;
else
Color.g=1-((1-Color.g)*(1-clr1.g));

if (Color.b<0.5)
Color.b=clr1.b * Color.b;
else
Color.b=1-((1-Color.b)*(1-clr1.b));

return Color;
}

Overlay SoftLight, Variation on Overlay for Lighter colors.
overlaysoft

sampler2D input : register(s0);
sampler2D tex1 : register(s1);
float4 main(float2 uv : TEXCOORD) : COLOR
{
float c=0;
float4 clr1;
clr1= tex2D(tex1, uv.xy);

float4 Color;
Color= tex2D( input , uv.xy);
c=clr1.r * Color.r;
Color.r=c+Color.r*(1-((1-Color.r)*(1-clr1.r)-c));

c=clr1.g * Color.g;
Color.g=c+Color.g*(1-((1-Color.g)*(1-clr1.g)-c));

c=clr1.b * Color.b;
Color.b=c+Color.b*(1-((1-Color.b)*(1-clr1.b)-c));

return Color;
}

Exclusion
Exclusion

sampler2D input : register(s0);
sampler2D tex1 : register(s1);

float4 main(float2 uv : TEXCOORD) : COLOR
{
float4 clr1;
clr1= tex2D(tex1, uv.xy);

float4 Color;
Color= tex2D( input , uv.xy);

Color.r+=clr1.r-clr1.r * Color.r;
Color.g+=clr1.g-clr1.g * Color.g;
Color.b+=clr1.b-clr1.b * Color.b;

return Color;
}



Download ShaderPad and play with these effects..

Tuesday, August 12, 2008  |  From Random Bits

With .NET 3.5 RTM release today, I see that there are following new properties added to the ShaderEffect class.

for setting the register index that contains the size of the image to which the effect is being applied to. documentation on web is complete with examples on this.

  • int DdxUvDdyUvRegisterIndex

For specifying the boundaries of the effect, this can be used to create glow like effects when so that the platform knows that the effect can determine output color outside the bounds of the UIElement. No Samples in the documentation.

  • double PaddingBottom
  • double PaddingLeft
  • double PaddingRight
  • double PaddingTop
  • ShaderRenderMode property on PixelShader

I shall be adding support for these in the ShaderPad shortly.

Monday, August 11, 2008  |  From Random Bits

splogox ShaderPad is a application like XamlPad / LinqPad , it is meant to server as WPF ShaderEffect Workbench. The ShaderEffect is a PixelShader based Effect that an be applied to any UIElement in WPF. This feature is available only in WPF 3.5 SP1

ShaderPad_release080811_sc1

This release also includes the ability to animate the input variables that are passed to the ShaderEffect.

In next release will add the ability to load effects from a common location on web, and save to web, this allow people to more freely share their effects.


Pre Requisites
.NET 3.5 SP1 : Download.
Direct X SDK : Download June 2008.

Download Download the Releases and source code at CodePlex.

Lookout for Effects releases soon....

 Random Bits News Feed 

Last edited Aug 12, 2008 at 1:39 AM by rravuri, version 13