[
Edit Forgot to refresh before posting - cat was sick on carpet while I was composing this
. Hence the delay.]
Your mirror is working well these days.
If I've understood you correctly you can simply change this bit
float4 Distort ( float2 texCoords : TEXCOORD0 ) : COLOR
{
float4 DP = tex2D(DM, texCoords);
texCoords += float2(DP.x - 0.5, DP.y - 0.5) * DP.z * 0.5;
return tex2D(s, texCoords);
}
to something like this:
float4 Distort ( float2 texCoords : TEXCOORD0 ) : COLOR
{
float4 DP = tex2D(DM, texCoords + seconds * uvScrollSpeed);
texCoords += float2(DP.x - 0.5, DP.y - 0.5) * DP.z * 0.5;
return tex2D(s, texCoords);
}
where you'll also need the following extra declarations among the declarations at the top of the shader code:
float seconds : Time;
float2 uvScrollSpeed = {0.0, 0.0}; // default = no scrolling
The distortion map sampler will also need to be changed to allow wrapping instead of clamping (was clamping really intended in the original shader?), i.e. change
Texture g_Map;
sampler2D DM = sampler_state {
Texture = <g_Map>;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = NONE;
AddressU = CLAMP;
AddressV = CLAMP;
};
to this
Texture g_Map;
sampler2D DM = sampler_state {
Texture = <g_Map>;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = NONE;
AddressU = WRAP;
AddressV = WRAP;
};
You'll need to experiment with the uvScrollSpeed values - values of 2, for example, will mean the distort texture scrolls twice per second. DBPro recognizes the Time semantic and passes elapsed time in seconds to the shader - in theory at least, i.e. it doesn't on my laptop for some obscure reason
.
Well, that was my first thought anyway.
A slightly more efficient solution might be to do the multiplication by time in DBPro itself and just use
float4 DP = tex2D(DM, texCoords + uvScrollSpeed);
I'm assuming you know how to change the "tweakables" via DBPro.
[Health warning: suggestions untested.
]