Gordon_G Posted March 24, 2017 Share Posted March 24, 2017 Hi ! So, I would like to apply a texture file to only 1 element, so, a Shader. But, I've not seen any example on the wiki so.. Could someone give me one ? Or just, (could be better) to explain me, what functions use and why ? Thanks ! Link to comment
NeXuS™ Posted March 24, 2017 Share Posted March 24, 2017 You'll have to use engineApplyShaderToWorldTexture there is now no such function as engineApplyShaderToWorldModel. You'll have to get the texture's name which you would like to change (eg. vehiclegrunge256). There is a good way to find out the texture's name tho, download this. After you got the texture's name, you can get the element you wish to replace, and just do engineApplyShaderToWorldTexture(shaderElement, textureName, elementVar) and it's done. EZPZ. Link to comment
Gordon_G Posted March 24, 2017 Author Share Posted March 24, 2017 Thanks a lot ! How to do if I need to put an image instead of an effect file ? Link to comment
NeXuS™ Posted March 24, 2017 Share Posted March 24, 2017 You could just add it to a renderTarget (via rendering, or just guiimage), and then apply that as the texture of the shader. Link to comment
Gordon_G Posted March 24, 2017 Author Share Posted March 24, 2017 (edited) I don't understand EDIT : I think I get it, I will tell you after my try Edited March 24, 2017 by Gordon_G Link to comment
itHyperoX Posted March 24, 2017 Share Posted March 24, 2017 (edited) client tabla = { -- YourPNGName Textura name {"YourPNGName", "prolaps01"}, {"YourPNGName", "heat_01"} } addEventHandler( "onClientResourceStart", resourceRoot, function() for i = 1, #tabla do local shader, tec = dxCreateShader ( "texreplace.fx" ) local tex = dxCreateTexture ( "files/"..tabla[i][1]..".png" ) engineApplyShaderToWorldTexture ( shader, tabla[i][2] ) engineApplyShaderToWorldTexture ( shader, tabla[i][2].."lod" ) dxSetShaderValue ( shader, "gTexture", tex ) end end) texreplace.fx texture gTexture; technique TexReplace { pass P0 { Texture[0] = gTexture; } } meta: <meta> <script src="sourceC.lua" type="client"></script> <file src="texreplace.fx"></file> <!-- Files --> <file src="YourPNGName.png"/> </meta> Edited March 24, 2017 by TheMOG Link to comment
Gordon_G Posted March 24, 2017 Author Share Posted March 24, 2017 (edited) Ii finally did it : addEventHandler("onClientResourceStart", resourceRoot, function() myShader,tecName = dxCreateShader( "shader.fx" ) myImage = dxCreateTexture( "image.png" ) if myShader and myImage then dxSetShaderValue( myShader, "tex0", myImage ) engineApplyShaderToWorldTexture( myShader, "ws_dickgoblinmural" ) else outputChatBox( "Problem - use: debugscript 3" ) end end ) And, need those files : shader.fx and mta-helper.fx EDIT : I did not see your post TheMOG, sorry, but thanks Edited March 24, 2017 by Gordon_G 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