Sign in to follow this  
Cyber14

Texture color

Recommended Posts

Hi im using "UV scripted" shader to set textures to my objects but im wondering if I can set texture color in MTA using shaders? This method is possible in SAMP by setting the "materialcolor" parametr using the SetObjectMaterial function. I would like to use it like changing the texture scale in UV Scripted, its just: dxSetShaderValue ( myShader, "gUVScale", 1, 1); and the scale changes. I would like to have something like this dxSetShaderValue ( myShader, "gUVColor", 255, 0, 0); for red color. Does anyone know how to do it?

Share this post


Link to post

A simple color shader

float4 tColor = float4(1,1,1,1);

technique tec0
{
    pass P0
    {
        MaterialDiffuse = tColor;
        MaterialEmissive = tColor;

        DiffuseMaterialSource = Material;
        EmissiveMaterialSource = Material;
        NormalizeNormals = TRUE;
        // FillMode = WIREFRAME;
        // AlphaBlendEnable = TRUE;
        

        ColorOp[0] = SELECTARG1;
        ColorArg1[0] = Diffuse;
        
        AlphaOp[0] = SELECTARG1;
        AlphaArg1[0] = Diffuse;
        
        Lighting = true;
    }
}

You might want to disable emissive

Share this post


Link to post

@Mr.Loki I tried to use your code by combining it with UV Scripted and the texture was white and my texture-image wasnt even visible. How can I change the color and which color format should I use? (I think that float4(1,1,1,1); is not "rgba" representation because it wasnt work) And can I make this color a bit transparent?

This is my code (its from the file uv_scripted.fx because I have changed only this one):

//
// Example shader - uv_scripted.fx
//

#include "include/tex_matrix.fx"

///////////////////////////////////////////////////////////////////////////////
// Global variables
///////////////////////////////////////////////////////////////////////////////
texture gOrigTexure0 : TEXTURE0;
texture gCustomTex0 : CUSTOMTEX0;

float2 gUVPrePosition = float2( 0, 0 );
float2 gUVScale = float( 1 );                     // UV scale
float2 gUVScaleCenter = float2( 0.5, 0.5 );
float gUVRotAngle = float( 0 );                   // UV Rotation
float2 gUVRotCenter = float2( 0.5, 0.5 );
float2 gUVPosition = float2( 0, 0 );              // UV position
float4 tColor = float4(1,1,1,1);                  // color

///////////////////////////////////////////////////////////////////////////////
// Functions
///////////////////////////////////////////////////////////////////////////////


//-------------------------------------------
// Returns UV transform using external settings
//-------------------------------------------
float3x3 getTextureTransform()
{
    return makeTextureTransform( gUVPrePosition, gUVScale, gUVScaleCenter, gUVRotAngle, gUVRotCenter, gUVPosition );
}


///////////////////////////////////////////////////////////////////////////////
// Techniques
///////////////////////////////////////////////////////////////////////////////
technique hello
{
    pass P0
    {
        // Set the texture
        Texture[0] = gCustomTex0;       // Use custom texture

        // Set the UV thingy
        TextureTransform[0] = getTextureTransform();

        // Enable UV thingy
        TextureTransformFlags[0] = Count2;
        
        MaterialDiffuse = tColor;
        MaterialEmissive = tColor;

        DiffuseMaterialSource = Material;
        EmissiveMaterialSource = Material;
        NormalizeNormals = TRUE;
        // FillMode = WIREFRAME;
        // AlphaBlendEnable = TRUE;
        

        ColorOp[0] = SELECTARG1;
        ColorArg1[0] = Diffuse;
        
        AlphaOp[0] = SELECTARG1;
        AlphaArg1[0] = Diffuse;
        
        Lighting = true;
    }
}

 

Edited by Cyber14

Share this post


Link to post

I'm no pro with shaders so i cant help with that problem sorry xD

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.