MatreN Posted January 20, 2020 Share Posted January 20, 2020 Hello friends I want to give 3d glitch effect when the marker is touched. How will I do. Link to comment
MatreN Posted January 20, 2020 Author Share Posted January 20, 2020 9 minutes ago, XaskeL said: Show example, please Look 46 second Link to comment
XaskeL Posted January 20, 2020 Share Posted January 20, 2020 (edited) I writted shader for you. Code for client.Lua: local SHADER_CODE = base64Decode("AQn//sQCAAAAAAAABQAAAAQAAAAcAAAAAAAAAAAAAAABAAAADwAAAG15U2NyZWVuU291cmNlAAADAAAAAAAAAFAAAABcAAAAAAAAAAEAAAABAAAAAAAAAAYAAABnVGltZQAAAAUAAABUSU1FAAAAAAMAAAACAAAAxAAAAOAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFQAAAGdXb3JsZFZpZXdQcm9qZWN0aW9uAAAAABQAAABXT1JMRFZJRVdQUk9KRUNUSU9OAAoAAAAEAAAAKAIAAAAAAAAAAAAAAgAAAAUAAAAEAAAAAAAAAAAAAAAAAAAAAwAAAAIAAAACAAAAAAAAAAAAAAAAAAAAAQAAAAEAAAADAAAAAgAAAAIAAAAAAAAAAAAAAAAAAAABAAAAAQAAAAIAAAACAAAAAgAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAgAAAAIAAAACAAAAAAAAAAAAAAAAAAAAAQAAAAEAAAACAAAAAgAAAAIAAAAAAAAAAAAAAAAAAAABAAAAAQAAAAYAAACkAAAAAAEAABABAAAMAQAApQAAAAABAAAoAQAAJAEAAKYAAAAAAQAASAEAAEQBAACqAAAAAAEAAGgBAABkAQAAqQAAAAABAACIAQAAhAEAAKsAAAAAAQAAqAEAAKQBAAAOAAAAU2NyZWVuU2FtcGxlcgAAAAMAAAAAAAAAXAIAAAAAAAAAAAAAAQAAAAEAAAAAAAAADAAAAEdsaXRjaFBvd2VyAAMAAAAQAAAABAAAAAAAAAAAAAAAAAAAA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D4AAAO2AAAjkoAQAAAQAABGAAQAAgAkAVaAAAFWABAAABAEAEYABAACACQCqoAAAAIBCAAADBAAPgAAA7IAACOSgAQAAAgEAAoAAAP+AQgAAAwAAD4ABAOSAAAjkoAQAAAQBAA+AAwDkgA4AxqACAOSABAAABAEAD4AEAOSAEADGoAEA5IAEAAAEAAAPgAAA5IAKAFqgAQDkgAUAAAMACA+AAADkgAwA5KD//wAAAAAAAAAAAAD/////AAAAAAAAAABwAQAAAAL+//7/NQBDVEFCHAAAAJ8AAAAAAv7/AQAAABwAAAAAAAAgmAAAADAAAAACAAAABAAAAEgAAABYAAAAZ1dvcmxkVmlld1Byb2plY3Rpb24Aq6urAwADAAQABAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB2c18yXzAATWljcm9zb2Z0IChSKSBITFNMIFNoYWRlciBDb21waWxlciA5LjI3Ljk1Mi4zMDIyAFEAAAUEAA+gAACAPwAAAAAAAAAAAAAAAB8AAAIAAACAAAAPkB8AAAIFAACAAQAPkAQAAAQAAA+AAAAkkAQAQKAEABWgCQAAAwAAAcAAAOSAAADkoAkAAAMAAALAAADkgAEA5KAJAAADAAAEwAAA5IACAOSgCQAAAwAACMAAAOSAAwDkoAEAAAIAAAPgAQDkkP//AAD/////AwAAAAAAAAAAAAAAAQAAAA8AAABteVNjcmVlblNvdXJjZQAA") -- export to mta and writted code by: XaskeL -- shader code from glsl by: Coolok CGlitch = { GlitchPower = 0.001; -- Glitch Power (0.0f to 1.0f); ScreenSize = { guiGetScreenSize() }; -- default screen size -- example[1]: CGlitch:destroy() -- example[2]: CGlitch.destroy() -- function for destroy glitch effects destroy = function(self) if CGlitch.AlreadyHandlered then removeEventHandler('onClientHUDRender', root, CGlitch.draw); removeEventHandler('onClientPreRender', root, CGlitch.update); CGlitch.AlreadyHandlered = false; end if self.Shader then destroyElement(self.Shader); self.Shader = false; end if self.MyScreenSource then destroyElement(self.MyScreenSource); self.MyScreenSource = false; end return true; end; -- function for update screen source update = function() if CGlitch.MyScreenSource then dxUpdateScreenSource(CGlitch.MyScreenSource); end end; -- function for draw glitch effect draw = function() if CGlitch.Shader then dxDrawImage(0, 0, CGlitch.ScreenSize[1], CGlitch.ScreenSize[2], CGlitch.Shader) end if (CGlitch.fTime and CGlitch.fTime < getTickCount()) then CGlitch:destroy(); end end; -- example [1]: CGlitch:show(500); -- example [2]: CGlitch.show(CGlitch, 500); -- params: @self (table CGlitch), 500 (time in milliseconds or false for permanently drawing) show = function(self, fTime) -- create screen source & shader self.MyScreenSource = dxCreateScreenSource(CGlitch.ScreenSize[1], CGlitch.ScreenSize[2]); self.Shader = dxCreateShader(SHADER_CODE); -- set default parametres dxSetShaderValue(self.Shader, 'GlitchPower', self.GlitchPower); dxSetShaderValue(self.Shader, 'myScreenSource', self.MyScreenSource); -- set work time if fTime then self.fTime = getTickCount() + fTime; else self.fTime = false; end -- create event handlers if (not self.AlreadyHandlered) then addEventHandler('onClientPreRender', root, CGlitch.update); addEventHandler('onClientHUDRender', root, CGlitch.draw); self.AlreadyHandlered = true; end end; }; --[[ example: CGlitch:show(500); -- show 500 ms --]] --[[ example: CGlitch:show(false); -- show permanently addCommandHandler('disableglitch', function() CGlitch:destroy(); end ) --]] Example for use: local MarkerPos = { x = 0.0; y = 0.0; z = 0.0; }; local theMarker = createMarker(MarkerPos.x, MarkerPos.y, MarkerPos.z, "cylinder", 1.5, 255, 255, 0, 170) addEventHandler('onClientMarkerHit', theMarker, function() CGlitch:show(500); end); Screenshot: Edited January 20, 2020 by XaskeL 1 Link to comment
XaskeL Posted January 20, 2020 Share Posted January 20, 2020 (edited) -- example [1]: CGlitch:show(500); -- example [2]: CGlitch.show(CGlitch, 500); -- params: @self (table CGlitch), 500 (time in milliseconds or false for permanently drawing) show = function(self, fTime) -- create screen source & shader if not self.Shader then self.MyScreenSource = dxCreateScreenSource(CGlitch.ScreenSize[1], CGlitch.ScreenSize[2]); self.Shader = dxCreateShader(SHADER_CODE); -- set default parametres dxSetShaderValue(self.Shader, 'GlitchPower', self.GlitchPower); dxSetShaderValue(self.Shader, 'myScreenSource', self.MyScreenSource); end -- set work time if fTime then self.fTime = getTickCount() + fTime; else self.fTime = false; end -- create event handlers if (not self.AlreadyHandlered) then addEventHandler('onClientPreRender', root, CGlitch.update); addEventHandler('onClientHUDRender', root, CGlitch.draw); self.AlreadyHandlered = true; end end; I forgot to add check, replace code this function. Edited January 20, 2020 by XaskeL Link to comment
MatreN Posted January 20, 2020 Author Share Posted January 20, 2020 Would you rewrite this to me? I really did not understand anything. I also couldn't run what was Marker. @XaskeL Link to comment
XaskeL Posted January 20, 2020 Share Posted January 20, 2020 12 minutes ago, MatreN said: Would you rewrite this to me? I really did not understand anything. I also couldn't run what was Marker. @XaskeL Link for download working example (Click Here) 3 Link to comment
Scripting Moderators ds1-e Posted January 20, 2020 Scripting Moderators Share Posted January 20, 2020 36 minutes ago, XaskeL said: Link for download working example (Click Here) Looks awesome, can you share shader code as .fx? Link to comment
ClawSuit Posted May 3 Share Posted May 3 @XaskeL where can I learn shaders to use in MTA? 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