Hi,
One test of a "Post-Processing Pixel Shader"
Work well !!! ;-)
JP
The B3d test file
Graphics3D 800,600,32,2
Global hwnd = SystemProperty ("AppHWND")
Global context% = ifx_Create(hwnd, 800,600, "shock.fx")
If context = 0 Then End
; technic shader routine
ifx_SetTechnique context, "t0"
; set the texture file texture
ifx_SetTexture context, "diffuse", "test.bmp"
While Not KeyDown( 1 )
ifx_SetFloat context, "time", Rnd(0.1,0.2)
ifx_Render context
Flip
Wend
ifx_Destroy context
End
The DELC file
;
.lib "imagefx.dll"
ifx_Create%(hwnd%,Width%,Height%,fxname$):"ifx_Create"
ifx_Destroy(context%):"ifx_Destroy"
ifx_Render(context%):"ifx_Render"
ifx_PreRender(context%):"ifx_PreRender"
ifx_PreRenderViewport(context%,X%,Y%,Width%,Height%):"ifx_PreRenderViewport"
ifx_PostRender(context%):"ifx_PostRender"
ifx_DestroyTexture(context%,texname$):"ifx_DestroyTexture"
ifx_GetLastError(context%,buf$,size%):"ifx_GetLastError"
ifx_GetGlobalLastError(buf$,size%):"ifx_GetGlobalLastError"
ifx_SetTechnique(context%,Handle$):"ifx_SetTechnique"
ifx_SetString(context%,Handle$,value$):"ifx_SetString"
ifx_SetVector(context%,Handle$,X#,Y#,z#,w#):"ifx_SetVector"
ifx_SetFloat(context%,Handle$,value#):"ifx_SetFloat"
ifx_SetTexture(context%,Handle$,texname$):"ifx_SetTexture"
ifx_SetInteger(context%,Handle$,value%):"ifx_SetInteger"
ifx_SetColor(context%,Handle$,value%):"ifx_SetColor"
the Shader "shock.fx" file
texture diffuse;
float time;
sampler SamplerWaves = sampler_state
{ Texture = (diffuse);
MipFilter = NONE;
MinFilter = NONE;
MagFilter = NONE;
};
float4 pswaves(float2 inTexcoord : TEXCOORD0) : COLOR
{
float normtime = time * 0.2f;
return float4(tex2D(SamplerWaves, inTexcoord * 1.5f + float2(normtime*0.2f, normtime*0.13f) * 3.0f).rgb, 1.0f);
}
technique t0
{
pass P0
{
pixelshader = compile ps_1_4 pswaves();
}
}