Jump to content

[Question] Apply shaders to vehicles


XML

Recommended Posts

Posted

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 ?

Posted

 

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)

Posted (edited)

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
Posted (edited)

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™
Posted

No, no, i'm not saying you replace the texture of the car. I'm telling you to replace the textures of an object and attach it to the car

Posted

@NeXuS™

I need to make a trigger to server side to apply it, So everyone can see it,

But how about the new players that enters the server after the trigger is done ?

Posted

You'll have to create the synchronization for it. Using maybe an element-data, which would tell if he needs to load any textures on that car. You'll have to find your way around.

  • Thanks 1
Posted

Alright thanks, I guess i'm going to use an element-data,

That saves the texture, And there will be a loop on client side to search for vehicles,

That have this element-data and load the shader for them.

  • Moderators
Posted (edited)

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
Posted

The sync for this is easy.

theVehicle = getPedOccupiedVehicle ( thePlayer )
engineApplyShaderToWorldTexture( myShader, "vehiclegrunge256", theVehicle )

 

Posted (edited)

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)

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...