regarding scrool the texture

prathap

04-12-2008 06:07:34

hi,
sorry for posting this again,iam not able to get the solution for applying the texture animation for ETTerrain.

iam using the ETTerrain and i need to apply the texture animation for a particular texture , for that i wrote scroll_anim 1 o in ETterrain materail script file for that particular textureUnitState. But iam not able to get that effect, i read through forum that it can be done using PSSplat2.cg and changing textureCoordinate caliculations in PSSplat2.cg,please some one guide me how can i get the solution for this problem
sorry for my english
thx in advance

billykater

04-12-2008 22:04:13

Method 1: Do it yourself
add time as input to the fragment program
ETTerrain.material
fragment_program_ref ET/Programs/PSSplat2
{
param_named_auto t time
....
}

Add
uniform float t
as input to the FragmentShader in PSSplat2.cg

use iTexCoord0 + t as input to the sampler for your particular texture
tex2D(splat1, iTexCoord0 + t )
scrolls it along both axes
use float2(iTexCoord0.x+t,iTexCoord0.y) for only u direction.

Method 2: Let Ogre do it for you and use scroll_anim
As I mentioned somewhere else param_named_auto texture_matrix is your friend.
Add as input to fragment program
param_named_auto texMat texture_matrix 0 //0 is the index of texture_unit
Add uniform float4x4 texMat as input to the FragmentShader
use

tex2D(splat1,
(mul(texMat,float4(iTexCoord0,0,1)).xy)
)

as sampler

Benefit of method 2 is that all anims from the corresponding texture_unit work as with the fixed function pipeline. Drawback would be some performance hit.

I didn't try all of this code but with ogre.log you should find any remaining errors.
I think that should be more than enough to get your own animation working.

prathap

09-12-2008 09:45:15

thx billykater for your valuable reply,i will try this and if i face any problem i will take your help

thx u very much