Jump to content

Questions about shaders


Overkillz

Recommended Posts

Hello dear community, well, today I started to working with shaders and I have 2 questions about them.

  1. The first one is how can I modify the following variable float3 colorrgb = float3(255,255,255); with dxSetShaderValue. I tried to use: dxSetShaderValue(myShader, "colorrgb", 255,0,0) but it didn't work.
  2. Will give I get problem while using dxSetShaderValue on a render ?

Thats all for now. I hope u can bring me a hand. Thanks for reading.

Best regards.

Link to comment

1) Just use float3 colorrgb; in your shader, that should allow you to use dxSetShaderValue, you could also see the examples on the wiki for more details.

2) I suppose you are asking if you get problems when you call dxSetShaderValue in onClientRender events. Actually I'm not sure but I wouldn't call it more than really necessary.

  • Like 1
Link to comment
13 hours ago, Overkillz said:
  1. The first one is how can I modify the following variable float3 colorrgb = float3(255,255,255); with dxSetShaderValue. I tried to use: dxSetShaderValue(myShader, "colorrgb", 255,0,0) but it didn't work.

.FX
Something like this:

float3 color;

Should be in your .FX file, find the tag, for example this one is "color".

.LUA

function resource_starts()
dxSetShaderValue(shader, "color", 255, 0, 0)
end
addEventHandler("onClientResourceStart", getRootElement(), resource_starts)
13 hours ago, Overkillz said:
  1. Will I get a problem while using dxSetShaderValue with onClientRender ?

onClientRender constantly is called EVERY TIME the clients screen renders a frame, it's not efficient for something like what you need.
You're gonna have to find a new event to replace it.
https://wiki.multitheftauto.com/wiki/Client_Scripting_Events
I recommend onClientResourceStart

Quote

onClientRender

Clientside event

This event is triggered every time GTA renders a new frame. It is required for the DirectX drawing functions, and also useful for other clientside operations that have to be applied repeatedly with very short time differences between them.

Source: MTA SA Wiki

  • Like 1
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...