MisterQuestions Posted March 3, 2015 Posted March 3, 2015 Hey all i was trying to make an background for a login panel. but doesn't work i just get a orange ground laggy Can some body help me? This is my code: client.lua function DrawTheBlurredBackground() dxSetRenderTarget(); dxUpdateScreenSource( myScreenSource ); dxDrawImage( 0, 0, screenW, screenH, myShader ); end function StartLoginPanel() showChat(false) showCursor(true) dxSetShaderValue( myShader, "ScreenSource", myScreenSource ); addEventHandler("onClientRender", root, DrawTheMainLoginPanel) addEventHandler( "onClientHUDRender", getRootElement(), DrawTheBlurredBackground ); end addEventHandler("onClientResourceStart",root,StartLoginPanel) BlurShader.fx 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(); } } "El conocimiento jamás debe detenerse, por que es lo único que nos salvará cuando no nos quede más". Att: -|TG|-Mister[Q]<.
Moderators IIYAMA Posted March 3, 2015 Moderators Posted March 3, 2015 local screenWidth, screenHeight = guiGetScreenSize ( ) local quality = 50 -- 1% t/m 100% local scalingFactor = quality/100 local myScreenSource = dxCreateScreenSource(screenWidth*scalingFactor, screenHeight*scalingFactor) Rendering with full resolution will lagg, because those functions are slow. And post all required variables next time, now I am just gambling what the problem might be. If it still does lagg after reducing the quality, you can also choose for an update after every 2 frames. (which will split up the fps in half) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Gallardo9944 Posted March 3, 2015 Posted March 3, 2015 I update it every frame with full resolution and there's no lag what so ever. Players don't complain. Code Debugger - Minimalistic MTA debug line replacement
Moderators IIYAMA Posted March 3, 2015 Moderators Posted March 3, 2015 Hmm, disagree with you. I am drawing my screen at 1920x1080, with 2 x 7970 cards(overkill) and yet I feel a strange kind of lagg. But that without using a shader, which you probably do. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Ren_712 Posted March 3, 2015 Posted March 3, 2015 Dividing huge numbers per pixel has always been quite resource demanding. I'd suggest rethinking the way you deal with that. Also there is a resource on community that you might like to check out: https://community.multitheftauto.com/index.php?p= ... s&id=10163 I make shaders .. mainly. My community resources I'll do some custom stuff, I'm open for cooperation.
MisterQuestions Posted March 4, 2015 Author Posted March 4, 2015 but why i just got n orange render laggy? 0 Blur "El conocimiento jamás debe detenerse, por que es lo único que nos salvará cuando no nos quede más". Att: -|TG|-Mister[Q]<.
MTA Team ccw Posted March 4, 2015 MTA Team Posted March 4, 2015 You're not setting BlurStrength or UVSize. Add something like this: dxSetShaderValue( myShader, "BlurStrength", 1 ); dxSetShaderValue( myShader, "UVSize", screenWidth/8, screenHeight/8 );
MisterQuestions Posted March 4, 2015 Author Posted March 4, 2015 Thanks worked ! [solved] "El conocimiento jamás debe detenerse, por que es lo único que nos salvará cuando no nos quede más". Att: -|TG|-Mister[Q]<.
MisterQuestions Posted March 9, 2015 Author Posted March 9, 2015 Hey got n problem (Sorry for revive this post) But when players enter just see a black background But after some restarts of script ingame you can see blurred bground Why? "El conocimiento jamás debe detenerse, por que es lo único que nos salvará cuando no nos quede más". Att: -|TG|-Mister[Q]<.
Gallardo9944 Posted March 9, 2015 Posted March 9, 2015 Have you used fadeCamera? Code Debugger - Minimalistic MTA debug line replacement
MisterQuestions Posted March 10, 2015 Author Posted March 10, 2015 Nope, fade its done later, but idk, it works sometimes others no weird thing... "El conocimiento jamás debe detenerse, por que es lo único que nos salvará cuando no nos quede más". Att: -|TG|-Mister[Q]<.
MTA Team ccw Posted March 10, 2015 MTA Team Posted March 10, 2015 onClientResourceStart is attached to root, which means it will be triggered for every starting resource. Check all your scripts and ensure they use resourceRoot for onResourceStart/Stop and onClientResourceStart/Stop Also, use 'debugscript 3' and fix all warnings.
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