Jump to content

shader issue


Xwad

Recommended Posts

Hello, is there anybody who's good with shaders? I have this UV scroll shader code that is scrolling a texture, but i have no clue how to create parameters for mta lua. I want to create a parameter to set the speed of the texture scrolling.

 

float gTime : TIME;


float3x3 getTextureTransform()
{
    float posU = -fmod( gTime/20 ,1 );
    float posV = 0;

    return float3x3( 0, 1, 0, 1, 0, 0, posU, posV, 1 );
}



technique tec0
{
    pass P0
    {
        TextureTransform[0] = getTextureTransform ();
        TextureTransformFlags[0] = Count2;
    }
}

 

Link to comment
float gTime : TIME;
float scrollSpeed = 1.0;


float3x3 getTextureTransform()
{
    float posU = -fmod((gTime/20)*scrollSpeed,1);
    float posV = 0;

    return float3x3( 0, 1, 0, 1, 0, 0, posU, posV, 1 );
}



technique tec0
{
    pass P0
    {
        TextureTransform[0] = getTextureTransform ();
        TextureTransformFlags[0] = Count2;
    }
}

Try this (no guarantee it'll work, I'm not a shader coder). Also, this will probably look glitchy if you continuously change the speed - you should set it only once and not change it once it's scrolling or it may jump forward or back instantaneously. The parameter you need to set with dxSetShaderValue is "scrollSpeed".

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...