Jump to content

[Question] Apply shaders to vehicles


XML

Recommended Posts

Hello guys,

i've seen in some servers that you can change the texture

of the same vehicle many times, So you can seen other players

having the same vehicle but another texture, I know that i have to use Shader functions

but how to do it, And how to make all players able to see other player's vehicle texture ?

Link to comment

 

If you find it very difficult to use shaders, I recommend changing the textures of an object and applying them to a car that is invisible (it will not give you as many problems as shaders)

8 minutes ago, XML said:

Hello guys,

i've seen in some servers that you can change the texture

of the same vehicle many times, So you can seen other players

having the same vehicle but another texture, I know that i have to use Shader functions

but how to do it, And how to make all players able to see other player's vehicle texture ?

If you find it very difficult to use shaders, I recommend changing the textures of an object and applying them to a car that is invisible (it will not give you as many problems as shaders)

Link to comment

The problem is, If i used the texture instead of shaders,

This will not be for only one vehicle, Unless if it was on client side for the local player,

Which is not what i want, Shader can make it for a certain vehicle instead of all,

That's why i start with it, It is difficult but i need to know how is that going to be

Edited by XML
Link to comment

Pretty easy.

This is the .fx file.

//-- Declare the texture. These are set using dxSetShaderValue( shader, "Tex0", texture )
texture Tex0;

technique simple
{
    pass P0
    {
        //-- Set up texture stage 0
        Texture[0] = Tex0;

        //-- Leave the rest of the states to the default settings
    }
}
local openedImg = dxCreateTexture("test.png")
local shaderFile = dxCreateShader("shader.fx")
dxSetShaderValue(shaderFile, "Tex0", openedImg)
engineApplyShaderToWorldTexture(shaderFile, "vehiclegrunge256")

You can get the texture name using this resource.

Edited by NeXuS™
Link to comment
  • Moderators

You probably need to save the pixels of the texture in stead of the texture. As textures are client-side only elements, which should not be able to sync.(Just in case if you get stuck there)

https://wiki.multitheftauto.com/wiki/DxGetTexturePixels

 

Even though a better way would be saving the file names, as every client does already have the textures.

Edited by IIYAMA
  • Thanks 1
Link to comment

Just save paint job string name with your preferred method (account data or MySQL or cookies) and use the above code I provided..
The client will check other players paint job string names for which paint job to use then it applies it accordingly, it can be tricky but that simple.

Edited by Justin|X5|
​​​​​​​(Posted too late to edit my last post)
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...