Cyber14 Posted July 17, 2018 Share Posted July 17, 2018 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? Link to comment
Mr.Loki Posted July 18, 2018 Share Posted July 18, 2018 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 Link to comment
Cyber14 Posted July 31, 2018 Author Share Posted July 31, 2018 (edited) @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 July 31, 2018 by Cyber14 Link to comment
Mr.Loki Posted August 1, 2018 Share Posted August 1, 2018 You didn't define "tColor" in your code Link to comment
Cyber14 Posted August 1, 2018 Author Share Posted August 1, 2018 (edited) @Mr.Loki i did it on line 19 and It works but not as I wanted Edited August 1, 2018 by Cyber14 Link to comment
Mr.Loki Posted August 1, 2018 Share Posted August 1, 2018 I'm no pro with shaders so i cant help with that problem sorry Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now