Jump to content

Applying shader to a single world texture (vehicle)


Hale

Recommended Posts

Hi! I'm trying to make a script that'll give a player an ability to change their nitro color, however, I seem to fail at it :S. I tried applying the color to the world texture with engineApplyShaderToWorldTexture and then put the player's current vehicle as the third argument, but it doesn't change. Then I tried doing the same but without the third argument, and what happened is the shader was applied to every single nitro on every vehicle, not just the player's vehicle like I want. Any ideas on how to fix this?

 

nitroShader = dxCreateShader("nitro.fx")

function updateNitroColor(r,g,b)
	if not nitroShader then return end
	if not r or not g or not b then return end
  
	local vehicle = getPedOccupiedVehicle(localPlayer)
	if not vehicle then return end
	engineApplyShaderToWorldTexture (nitroShader,"smoke", vehicle)
	dxSetShaderValue (nitroShader, "gNitroColor", r/100, g/100, b/100)
end
Link to comment
2 hours ago, Jayceon said:

Try this:


nitroShader = dxCreateShader("nitro.fx", 0, 100, false, "vehicle")

 

I tried it before and now again, same thing happens. No errors in debug but the nitro smoke is not affected either.

Link to comment
14 hours ago, MIKI785 said:

You can't. The nitro texture is global, it's not tied to vehicle elements. Hence you can't change it for only one vehicle, it's either all of them or none.

What would be the best way to create custom nitro colors for everyone then? My first thought was to create marker but that'd look ugly as hell, there must be a better way.

Link to comment
  • 3 weeks later...
On 6/20/2017 at 04:28, MIKI785 said:

You can't. The nitro texture is global, it's not tied to vehicle elements. Hence you can't change it for only one vehicle, it's either all of them or none.

"smoke" and "shad_car" also can't be tied to one vehicle as i've tried and failed.

But what's the point of `targetElement` then ?!

engineApplyShaderToWorldTexture ( shader, textureName [, element targetElement)

On 6/20/2017 at 19:24, Hale said:

What would be the best way to create custom nitro colors for everyone then? My first thought was to create marker but that'd look ugly as hell, there must be a better way.

did you find an alternative?

Link to comment
3 hours ago, pa3ck said:

There are other components which can be changed on individual vehicles like paintjobs, rims, glass etc and that is when targetElement comes in to play.

The thing is there's servers that use custom under-vehicle neon, and custom nitro colors which is unique for each player, it just confuses me.

Link to comment
8 minutes ago, koragg said:

https://github.com/JarnoVgr/Mr.Green-MTA-Resources/blob/master/resources/[gameplay]/mrgreen-settings/visual.lua

Here you can see how the different nitro color works (if you wanna search around the resource a bit).

I took a look at it, it uses same nitro color for every vehicle.

I have an idea to use `createEffect` with shaders, i wonder if that will work, will probably try later.

Link to comment
1 hour ago, pro-mos said:

I took a look at it, it uses same nitro color for every vehicle.

I have an idea to use `createEffect` with shaders, i wonder if that will work, will probably try later.

I'm pretty sure every player has a different nos color cuz I'm using it at my server :D Maybe not in that particular file but that's the resource for sure.

Link to comment

There's a difference between paintjobs and nitro effect. Basically every single car got their own body, which you can change, because the "parent" is the vehicle itself. But not all cars have the nitro effect element, the parent is basically the "word", or at least that is what I understand. For example if you want to use shader for the ocean, you wouldn't be able to differentiate between the ocean in San Fierro and Los Santos, they are the same. 

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