Overkillz Posted December 31, 2016 Share Posted December 31, 2016 Hey dear community, Im trying to draw multiple photos using mask shader. The script is based on shader_hud_mask or something like that. Well, my problem is that using this method it lags me a lot, but a lot of. I hope you can help me to use a better way for it. function dxDrawMaskAvatar(posX,posY,sizeX,sizeY,url,r,g,b,a,postGUI) if url and url ~= "" then imageTexture = dxCreateTexture(url) hudMaskShader = dxCreateShader("files/img/hud_mask.fx") maskTexture1 = dxCreateTexture("files/img/circle_mask.png") validMask = hudMaskShader and imageTexture and maskTexture1 if not validMask then outputChatBox( "Could not create some things. Please use debugscript 3" ) else dxSetShaderValue( hudMaskShader, "sPicTexture", imageTexture ) dxSetShaderValue( hudMaskShader, "sMaskTexture", maskTexture1 ) end --### DRAW dxSetShaderValue( hudMaskShader, "sMaskTexture", maskTexture1 ) dxDrawImage( posX,posY,sizeX,sizeY, hudMaskShader, 0,0,0, tocolor(r,g,b,a),postGUI or false ) end end --######## --##Draw Avatar --######## function testingDrawAvatar() dxDrawMaskAvatar(sX/2,sY/2,sY*0.05,sY*0.05,"files/img/defaultavatar.png",255,255,255,255,true) dxDrawMaskAvatar(sX/2,sY/3,sY*0.05,sY*0.05,"files/img/user.png",255,255,255,255,true) end addEventHandler( "onClientRender", getRootElement(),testingDrawAvatar) Thanks for reading. Link to comment
Bonsai Posted December 31, 2016 Share Posted December 31, 2016 Creating a texture and shader should not be done inside a render function. Do it only once somewhere, then use it. Link to comment
Overkillz Posted December 31, 2016 Author Share Posted December 31, 2016 2 hours ago, Bonsai said: Creating a texture and shader should not be done inside a render function. Do it only once somewhere, then use it. I tried it but the image isn't the same for everybody. Each one has his own image. Link to comment
Bonsai Posted December 31, 2016 Share Posted December 31, 2016 Then you probably have to work with tables and use players or the image path as an index. Everything but creating a new texture on every frame. 1 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