2kristof2 Posted May 18, 2016 Share Posted May 18, 2016 Hey, I wanted to make a texture for 1 object with ID XXXX but it worked for all objects with this ID. Here is lua code of a shader: local blockTexture = {"images/block1.png", "images/block2.png", "images/block3.png"} local shader = dxCreateShader('shader.fx') local t_x = 256 local t_y = 256 local renderTarget = dxCreateRenderTarget(t_x,t_y,true) function start_shaders() dxSetRenderTarget(renderTarget) do dxDrawImage(0,0,256,256, blockTexture[math.random(1,3)]) end dxSetRenderTarget() do dxSetShaderValue(shader,'gTexture',renderTarget) end end addEventHandler('onClientResourceStart',resourceRoot,start_shaders) function apply_shader(element) engineApplyShaderToWorldTexture(shader,'Crate_B', element) end And here .fx file: texture gTexture; technique TexReplace { pass P0 { Texture[0] = gTexture; } } I wanted to make a function apply_shader which applies a random texture (block1, block2 or block3) to an object by using: call(getResourceFromName("shader"),"apply_shader",block) but it didn't work properly. 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