Jump to content

Issue creating multiple shaders with the same file


Overkillz

Recommended Posts

Hello dear community. Im currently trying to create multiple shaders using the same file.

In fact they are created but with the same values. For example. To the second shader I set it a different colour but when I draw it, practically has the same value as the first one. Other issue is that sometimes one of the both shaders isn't draw. I can't really remember why because I have tested it few days ago. Anyways, the goal of this topic is that you could help me to fix it or give me some tips to reach the goal.

currentHealth = 0
currentNos = 0

function startDrawing()
	dxDrawImage( 100, 350, 300, 300, myShader,0,0,0,tocolor(40,220,40,255)  )
	dxDrawImage( 450, 350, 300, 300, myShader2,0,0,0,tocolor(255,0,0,255)  )
	local theVehicle = getPedOccupiedVehicle(localPlayer)
	if theVehicle then
		local theHealth = getElementHealth(theVehicle) or 0
		local theNos = getVehicleNitroLevel(theVehicle) or 0
		currentHealth = (theHealth-250)/750
		currentNos = theNos
	else
		currentHealth = 0
		currentNos = 0
	end
	dxSetShaderValue( myShader, "degrees", currentHealth*180 )
	dxSetShaderValue( myShader2, "degrees", (currentNos*180) )
end

function startShadeing()
	myShader = dxCreateShader( "ring/Circle.fx" ) --Health
	myShader2 = dxCreateShader( "ring/Circle.fx" ) --Nos
	myTexture = dxCreateTexture( "ring/emptyCircle.png" )
	
	dxSetShaderValue( myShader, "tex", myTexture )
	dxSetShaderValue( myShader2, "tex", myTexture )
	
	dxSetShaderTransform(myShader2,180,180,0)
	
	dxSetShaderValue(myShader, "rgba", 0/255, 255/255, 40/255,1)
	dxSetShaderValue(myShader2, "rgba", 0/255, 40/255, 220/255,1)
	addEventHandler("onClientRender",root,startDrawing)
end
addEventHandler("onClientResourceStart",resourceRoot,startShadeing)

Thanks for reading, best regards.

 

Link to comment
  • Moderators

Afaik different shaders aren't linked.

The only thing I learned from shaders is that tocolor behaves different when using shaders. Put it on 255, 255, 255 and let the shader do the rest.

 

This might also giving some problems if the shader isn't handling it right:

currentHealth = (theHealth-250)/750

>>>> 0 health > -250 > / 750 > * 180 = -60

if currentHealth < 0 then
	currentHealth = 0
end

 

Edited by IIYAMA
Link to comment
9 minutes ago, IIYAMA said:

Afaik different shaders aren't linked.

The only thing I learned from shaders is that tocolor behaves different when using shaders. Put it on 255, 255, 255 and let the shader do the rest.

 

This might also giving some problems if the shader isn't handling it right:


currentHealth = (theHealth-250)/750

>>>> 0 health > -250 > / 750 > * 180 = -60


if currentHealth < 0 then
	currentHealth = 0
end

 

Sorry, currentHealth variable is defined rightly. I just did the code again and I forgot to add math.max^_^

Respecting the shaders. Why should I put the shaders 255,255,255 ? It depends of the shader file and how it is coded or im wrong ?

Regards.

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