Overkillz Posted March 24, 2018 Share Posted March 24, 2018 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 IIYAMA Posted March 24, 2018 Moderators Share Posted March 24, 2018 (edited) 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 March 24, 2018 by IIYAMA Link to comment
Overkillz Posted March 24, 2018 Author Share Posted March 24, 2018 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
Moderators IIYAMA Posted March 24, 2018 Moderators Share Posted March 24, 2018 I think that it depends on the shader. Because tocolor didn't work with the shaders I tried. Link to comment
Overkillz Posted March 25, 2018 Author Share Posted March 25, 2018 I didn't use tocolor to set it. I On 24/3/2018 at 20:48, Overkillz said: dxSetShaderValue(myShader, "rgba", 0/255, 255/255, 40/255,1) dxSetShaderValue(myShader2, "rgba", 0/255, 40/255, 220/255,1) Link to comment
Moderators IIYAMA Posted March 26, 2018 Moderators Share Posted March 26, 2018 I know, but you did both, so maybe that could have caused problems. I am not an expert with shaders, so everything is maybe this and maybe that.? Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now