'LinKin Posted August 27, 2013 Share Posted August 27, 2013 Hello, As some of you might know, there's a free resouce which applies a shader to the vehicles. Since I was working in a script to enable/disable some other textures such as roads, ramps.. etc. I just realized that I don't know how to 'destroy' the vehicle's shader if it is being used. Here's the .lua file from the free resource which you can find at: https://community.multitheftauto.com/in ... ls&id=4422 addEventHandler( "onClientResourceStart", resourceRoot, function() -- Version check if getVersion ().sortable < "1.1.0" then outputChatBox( "Resource is not compatible with this client." ) return end -- Create shader local myShader, tex = dxCreateShader ( "car_paint.fx" ) if not myShader then outputChatBox( "Could not create shader. Please use debugscript 3" ) else outputChatBox( "Using technique " .. tex ) -- Set textures local textureVol = dxCreateTexture ( "images/smallnoise3d.dds" ); local textureCube = dxCreateTexture ( "images/cube_env256.dds" ); dxSetShaderValue ( myShader, "sRandomTexture", textureVol ); dxSetShaderValue ( myShader, "sReflectionTexture", textureCube ); engineApplyShaderToWorldTexture ( myShader, "vehiclegrunge256" ) engineApplyShaderToWorldTexture ( myShader, "?emap*" ) end end ) Thanks, LinKin Link to comment
Castillo Posted August 27, 2013 Share Posted August 27, 2013 addCommandHandler ( "carpaint", function ( ) if isElement ( myShader ) then engineRemoveShaderFromWorldTexture ( myShader, "vehiclegrunge256" ) engineRemoveShaderFromWorldTexture ( myShader, "?emap*" ) destroyElement ( myShader ) if isElement ( textureVol ) then destroyElement ( textureVol ) end if isElement ( textureCube ) then destroyElement ( textureCube ) end return end -- Version check if ( getVersion ( ).sortable < "1.1.0" ) then outputChatBox ( "Resource is not compatible with this client." ) return end -- Create shader myShader, tex = dxCreateShader ( "car_paint.fx" ) if ( not myShader ) then outputChatBox ( "Could not create shader. Please use debugscript 3" ) else outputChatBox ( "Using technique ".. tex ) -- Set textures textureVol = dxCreateTexture ( "images/smallnoise3d.dds" ); textureCube = dxCreateTexture ( "images/cube_env256.dds" ); dxSetShaderValue ( myShader, "sRandomTexture", textureVol ); dxSetShaderValue ( myShader, "sReflectionTexture", textureCube ); engineApplyShaderToWorldTexture ( myShader, "vehiclegrunge256" ) engineApplyShaderToWorldTexture ( myShader, "?emap*" ) end end ) Try 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