AlvarO Posted October 29, 2015 Share Posted October 29, 2015 Hello, so I need to make a blur background to a script, the problem is i don't know how to script it, I just got the .fx file. texture texture0; float factor; sampler Sampler0 = sampler_state { Texture = (texture0); AddressU = MIRROR; AddressV = MIRROR; }; struct PSInput { float2 TexCoord : TEXCOORD0; }; float4 PixelShader_Background(PSInput PS) : COLOR0 { float4 sum = tex2D(Sampler0, PS.TexCoord); for (float i = 1; i < 3; i++) { sum += tex2D(Sampler0, float2(PS.TexCoord.x, PS.TexCoord.y + (i * factor))); sum += tex2D(Sampler0, float2(PS.TexCoord.x, PS.TexCoord.y - (i * factor))); sum += tex2D(Sampler0, float2(PS.TexCoord.x - (i * factor), PS.TexCoord.y)); sum += tex2D(Sampler0, float2(PS.TexCoord.x + (i * factor), PS.TexCoord.y)); } sum /= 9; sum.a = 1.0; return sum; } technique complercated { pass P0 { PixelShader = compile ps_2_0 PixelShader_Background(); } } technique simple { pass P0 { Texture[0] = texture0; } } Link to comment
Ren_712 Posted October 31, 2015 Share Posted October 31, 2015 you can use this script: https://community.multitheftauto.com/in ... s&id=10163 there are some exported functions that let you create blur boxes But if You want to apply your shader to a screen space, then you'll find a good amount of help on wiki: https://wiki.multitheftauto.com/wiki/DxCreateShader https://wiki.multitheftauto.com/wiki/DxSetShaderValue Your texture0 should be the screenSource https://wiki.multitheftauto.com/wiki/Dx ... reenSource don't forget to update it. your 'blurfactor' should be set as well. (0 - 1) i guess Link to comment
AlvarO Posted November 1, 2015 Author Share Posted November 1, 2015 I made this and it dosn't works local x, y = guiGetScreenSize() local px, py = 1920, 1080 local sx, sy = (x/px), (y/py) screen = dxCreateScreenSource ( px, py ) function drawLogin() dxUpdateScreenSource( screen ) blurShader = dxCreateShader( "shader.fx" ) dxSetShaderValue( blurShader, "bShowThing", true ) dxSetShaderValue( blurShader, "speed", 2.4 ) dxSetShaderValue( blurShader, "positionOfCheese", 100, 200, 300 ) setCameraMatrix(4141.2734375, -1625.0224609375, 72.958938598633, -300000, 0, 0) showCursor(true) dxDrawRectangle(x*0.385, y*0.35, 450, 50, tocolor(170, 35, 35, 255)) dxDrawRectangle(x*0.385, y*0.38, 450, 250, tocolor(255, 255, 255, 255)) dxDrawRectangle(x*0.385, y*0.6, 450, 50, tocolor(200, 200, 200, 255)) dxDrawRectangle(x*0.48, y*0.613, 100, 25, rectanglecchanger1) dxDrawRectangle(x*0.55, y*0.613, 100, 25, rectanglecchanger2) dxDrawText("Login panel", x*(-0.15), x*(-0.15), x, y, tocolor(15, 15, 15, 255), 1.5, "arial", "center", "center", false, false, true, true, false) dxDrawText("Username", x*(-0.15), y*(-0.15), x, y, tocolor(15, 15, 15, 255), 1.5, "arial", "center", "center", false, false, true, true, false) dxDrawText("Password", x*(-0.15), y*0.01, x, y, tocolor(15, 15, 15, 255), 1.5, "arial", "center", "center", false, false, true, true, false) dxDrawText("remember me?", x*(-0.1), x*0.14, x, y, tocolor(15, 15, 15, 255), 1, "arial", "center", "center", false, false, true, true, false) dxDrawText("Login", x*0.01, x*0.14, x, y, tocolor(15, 15, 15, 255), 1, "arial", "center", "center", false, false, true, true, false) dxDrawText("Register", x*0.152, x*0.14, x, y, tocolor(15, 15, 15, 255), 1, "arial", "center", "center", false, false, true, true, false) end addEventHandler("onClientRender", root, drawLogin) Link to comment
Dealman Posted November 2, 2015 Share Posted November 2, 2015 You do realize you're creating a new shader with every frame, right? You only need to create it once. I doubt you need 30-60 new shaders per second You then draw the shader via dxDrawImage. Link to comment
AlvarO Posted November 2, 2015 Author Share Posted November 2, 2015 I tested it and now appear a black background dxDrawImage(0, 0, x, y, blurShader, 0, 0, 0, tocolor(255, 255, 255, 150)) Link to comment
Ren_712 Posted November 3, 2015 Share Posted November 3, 2015 your shader has only 2 variables: texture texture0; -- here goes screen float factor; -- here goes value (0 - 1) this instead of showCheese, and other weird stuff you set. Link to comment
AlvarO Posted November 3, 2015 Author Share Posted November 3, 2015 Didn't understand, can you give me an example? Link to comment
Ren_712 Posted November 4, 2015 Share Posted November 4, 2015 I do respect that you want to learn how to script. But seriously ... dxSetShaderValue - that's what you need, it's like with any other function. Just read the wiki page, not just copy and paste stuff. Think and learn - you will gain something by that. Unless you want a ready solution. But i need to be a little bit more motivated to do so. 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