Pixel shader
From FusionWiki
(Redirected from Pixel shaders)
Pixel shaders (often referred to as simply "shaders") are part of Direct3D and can be used in HWA. They are pieces of code written in High Level Shader Language that are executed on one's graphics card and are mainly used to change the final appearance of a source texture (e.g. an Active Object) using mathematical calculations.
In MMF2, a pixel shader combined with an XML configuration file is referred to as effect. Effects basically replace ink effects, adding more functionality and does not lower the frame rate as much as ink effects on modern computers.
To install a pixel shader, copy the .fx and .xml files into Multimedia Fusion's /Effects folder. You can create sub-folders to organize them.
Examples of achievable effects
- Brightening
- Stretching
- Rotating
- Blurring
- Generating fractals
Pixel shader example
//The source image
sampler2D source;
//This function will be called for each pixel in our texture and returns the new color
float4 ps_main(in float2 In : TEXCOORD0) : COLOR0
{
//Read the color of the source texture at the current position (In)
float4 color = tex2D(source,In);
//Set the red component of the color to 0
color.r = 0.0f;
//Output the color
return color;
}
//Use ps_main() as entry point for the shader, compile as pixel shader 2.0
technique tech_main
{
pass P0
{
PixelShader = compile ps_2_0 ps_main();
}
}
