Overkillz Posted March 5, 2019 Posted March 5, 2019 Hello dear community, Im not an expert with shader so I have been looking for a blur shader over the MTA Community resource. I found one that its pretty simple to use, however, when I draw it, it overdraw my current dx UI. I don't want to use Ren's resource, I know that it is very usefull but I want to learn how to deal with my problem I hope you can bring me a solution to work with it. local sX, sY = guiGetScreenSize() local myScreenSource = dxCreateScreenSource(sX, sY) function drawBlurScreen() dxUpdateScreenSource(myScreenSource) dxSetShaderValue(blurShader, "ScreenSource", myScreenSource) dxSetShaderValue(blurShader, "BlurStrength", 6) dxSetShaderValue(blurShader, "UVSize", sX, sY) dxDrawImage(0, 0, sX, sY, blurShader,0,0,0) end addEventHandler("onClientResourceStart", resourceRoot, function() blurShader, blurTec = dxCreateShader("files/shader/blur.fx") if blurShader then addEventHandler("onClientRender",root,drawBlurScreen) end end) texture ScreenSource; float BlurStrength; float2 UVSize; sampler TextureSampler = sampler_state { Texture = <ScreenSource>; MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = Wrap; AddressV = Wrap; }; static const float2 poisson[16] = { float2(-0.326212f, -0.40581f), float2(-0.840144f, -0.07358f), float2(-0.695914f, 0.457137f), float2(-0.203345f, 0.620716f), float2(0.96234f, -0.194983f), float2(0.473434f, -0.480026f), float2(0.519456f, 0.767022f), float2(0.185461f, -0.893124f), float2(0.507431f, 0.064425f), float2(0.89642f, 0.412458f), float2(-0.32194f, -0.932615f), float2(-0.65432f, -0.87421f), float2(-0.456899f, -0.633247f), float2(-0.123456f, -0.865433f), float2(-0.664332f, -0.25680f), float2(-0.791559f, -0.59771f) }; float4 PixelShaderFunction(float2 TextureCoordinate : TEXCOORD0) : COLOR0 { float4 color = tex2D(TextureSampler, TextureCoordinate); for(int i = 0; i < 16; i++) { float2 coord= TextureCoordinate.xy + (poisson[i] / UVSize * BlurStrength); color += tex2D(TextureSampler, coord); } return(color/17); } technique BlurShader { pass Pass1 { PixelShader = compile ps_2_0 PixelShaderFunction(); } } Thanks for reading, best regards.
Overkillz Posted March 5, 2019 Author Posted March 5, 2019 23 minutes ago, TRtam said: First draw the blur and then draw the UI I want to blur the UI too
Discord Moderators Pirulax Posted March 6, 2019 Discord Moderators Posted March 6, 2019 Meh, doing that'd be pretty hard, since screen source only containts the image that is drawn by GTA.
Overkillz Posted March 6, 2019 Author Posted March 6, 2019 31 minutes ago, Pirulax said: Meh, doing that'd be pretty hard, since screen source only containts the image that is drawn by GTA. Im talking about a custom UI made by dX's. Not default GTA/MTA UI.
Discord Moderators Pirulax Posted March 7, 2019 Discord Moderators Posted March 7, 2019 Thats what I was talking about.
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