Image Posted September 16, 2012 Share Posted September 16, 2012 (edited) * Edited December 10, 2014 by Guest Link to comment
Image Posted September 17, 2012 Author Share Posted September 17, 2012 Use Photoshop. I want to make it in-game, not outside. Link to comment
myonlake Posted September 17, 2012 Share Posted September 17, 2012 Eh, he means you use Photoshop to blur a background image, and then add it in-game via DirectX functions. dxDrawImage If this is still not what you mean, you should check out the shader feature, which was added a while ago. https://wiki.multitheftauto.com/wiki/Shader Link to comment
Image Posted September 17, 2012 Author Share Posted September 17, 2012 (edited) * Edited December 12, 2014 by Guest Link to comment
Anderl Posted September 17, 2012 Share Posted September 17, 2012 Eh, he means you use Photoshop to blur a background image, and then add it in-game via DirectX functions. dxDrawImage If this is still not what you mean, you should check out the shader feature, which was added a while ago. https://wiki.multitheftauto.com/wiki/Shader I know the function but not the effect file, or the lua script I can not prepare p.s.: sry for my bad english, i used google translator If you can't make such easy thing like drawing an image in the screen, then you should start learning Lua -- drawing an image is a very basic thing. Link to comment
Image Posted September 17, 2012 Author Share Posted September 17, 2012 I expressed myself badly almost everything I can do whatever I want in lua, but I do not know the .fx file prepared Link to comment
Anderl Posted September 17, 2012 Share Posted September 17, 2012 I expressed myself badly almost everything I can do whatever I want in lua, but I do not know the .fx file prepared There's no need for use of shaders. Photoshop is enough. Link to comment
Image Posted September 17, 2012 Author Share Posted September 17, 2012 Can you show me how can I do it? There is a graphic of the team, but unfortunately he can not make that transparent to the blur. (I do not want to blur an image, but the player's camera. Such an HDR effect, but it is only 2D) Link to comment
Ren_712 Posted September 17, 2012 Share Posted September 17, 2012 (edited) I think you could use shader "motion blur" (by orange) from community. Just strip the lua out of 'motion stuff' and fix the blur values x and y. You may need to edit the fx file. I guess that's the easiest way. Edited September 17, 2012 by Guest Link to comment
Image Posted September 17, 2012 Author Share Posted September 17, 2012 The problem is that the effect is only one-way. The gaussian blur effect benefits both directions is required. A vertical and a horizontal accordingly. Link to comment
Ren_712 Posted September 17, 2012 Share Posted September 17, 2012 (edited) As far as i can say , that is not that tough to realise how this effect is drawn and modify it .. just play with the .x and .y stuff. or .. you might check this out: http://www.geeks3d.com/20100909/shader- ... r-in-glsl/ this is what you have on mind ? - it's not HLSL, but it's not that hard to understand/convert it. update: How about looking at shader_bloom from examples... Edited September 17, 2012 by Guest Link to comment
Image Posted September 17, 2012 Author Share Posted September 17, 2012 or .. you might check this out: http://www.geeks3d.com/20100909/shader- ... r-in-glsl/ this is what you have on mind ? - it's not HLSL, but it's not that hard to understand/convert it. yes, it is, i'll try it Link to comment
Ren_712 Posted September 17, 2012 Share Posted September 17, 2012 Another thought. blurH and V effect from shader_bloom. If you want to use just one effect do that: blurH: changes from line 95 for(int i = 0; i < 7; ++i) { coord.x = PS.TexCoord.x + Kernel[i]/sTex0Size.x; coord.y = PS.TexCoord.y + Kernel[i]/sTex0Size.y; Color += tex2D(Sampler0, coord.xy) * Weights[i] * sBloom; } Link to comment
Image Posted September 17, 2012 Author Share Posted September 17, 2012 i edited the c_bloom.lua and the blurh.fx files and it works thank you very much Link to comment
robhol Posted September 18, 2012 Share Posted September 18, 2012 If you can't make such easy thing like drawing an image in the screen, then you should start learning Lua -- drawing an image is a very basic thing. He's obviously not looking to draw a simple image OR use freaking Photoshop, so calm down. Link to comment
Image Posted September 18, 2012 Author Share Posted September 18, 2012 i have another problem it uses extremely amount of performance and my fps drops here's my lua code: -- -- c_bloom.lua -- local scx, scy = guiGetScreenSize() ----------------------------------------------------------------------------------- -- Le settings ----------------------------------------------------------------------------------- Settings = {} Settings.var = {} Settings.var.bloom = 1.5 Settings.var.blendR = 255 Settings.var.blendG = 255 Settings.var.blendB = 255 Settings.var.blendA = 100 ---------------------------------------------------------------- -- onClientResourceStart ---------------------------------------------------------------- addEventHandler( "onClientResourceStart", resourceRoot, function() -- Version check if getVersion ().sortable < "1.1.0" then outputChatBox( "Resource is not compatible with this client." ) return end -- Create things myScreenSource = dxCreateScreenSource( scx/2, scy/2 ) blurHShader,tecName = dxCreateShader( "blurH.fx" ) outputDebugString( "blurHShader is using technique " .. tostring(tecName) ) --blurVShader,tecName = dxCreateShader( "blurV.fx" ) --outputDebugString( "blurVShader is using technique " .. tostring(tecName) ) -- Check everything is ok bAllValid = myScreenSource and blurHShader if not bAllValid then outputChatBox( "Could not create some things. Please use debugscript 3" ) end end ) ----------------------------------------------------------------------------------- -- onClientHUDRender ----------------------------------------------------------------------------------- addEventHandler( "onClientHUDRender", root, function() if not Settings.var then return end if bAllValid then -- Reset render target pool RTPool.frameStart() -- Update screen dxUpdateScreenSource( myScreenSource ) -- Start with screen local current = myScreenSource -- Apply all the effects, bouncing from one render target to another current = applyGBlurH( current, Settings.var.bloom ) --current = applyGBlurV( current, Settings.var.bloom ) -- When we're done, turn the render target back to default dxSetRenderTarget() -- Mix result onto the screen using 'add' rather than 'alpha blend' if current then dxSetShaderValue( blurHShader, "TEX0", current ) local col = tocolor(Settings.var.blendR, Settings.var.blendG, Settings.var.blendB, Settings.var.blendA) dxDrawImage( 0, 0, scx, scy, blurHShader, 0,0,0, col) end end end ) ----------------------------------------------------------------------------------- -- Apply the different stages ----------------------------------------------------------------------------------- function applyGBlurH( Src, bloom ) if not Src then return nil end local mx,my = dxGetMaterialSize( Src ) local newRT = RTPool.GetUnused(mx,my) if not newRT then return nil end dxSetRenderTarget( newRT, true ) dxSetShaderValue( blurHShader, "TEX0", Src ) dxSetShaderValue( blurHShader, "TEX0SIZE", mx,my ) dxSetShaderValue( blurHShader, "BLOOM", bloom ) dxDrawImage( 0, 0, mx, my, blurHShader ) return newRT end ----------------------------------------------------------------------------------- -- Pool of render targets ----------------------------------------------------------------------------------- RTPool = {} RTPool.list = {} function RTPool.frameStart() for rt,info in pairs(RTPool.list) do info.bInUse = false end end function RTPool.GetUnused( mx, my ) -- Find unused existing for rt,info in pairs(RTPool.list) do if not info.bInUse and info.mx == mx and info.my == my then info.bInUse = true return rt end end -- Add new local rt = dxCreateRenderTarget( mx, my ) if rt then outputDebugString( "creating new RT " .. tostring(mx) .. " x " .. tostring(mx) ) RTPool.list[rt] = { bInUse = true, mx = mx, my = my } end return rt end and the .fx code: // // Example shader - blurH.fx // // Horizontal blur // //--------------------------------------------------------------------- // blurH settings //--------------------------------------------------------------------- float sBloom : BLOOM = 1; texture sTex0 : TEX0; float2 sTex0Size : TEX0SIZE; //--------------------------------------------------------------------- // Include some common stuff //--------------------------------------------------------------------- #include "mta-helper.fx" //----------------------------------------------------------------------------- // Static data //----------------------------------------------------------------------------- static const float Kernel[13] = {-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6}; static const float Weights[13] = { 0.002216, 0.008764, 0.026995, 0.064759, 0.120985, 0.176033, 0.199471, 0.176033, 0.120985, 0.064759, 0.026995, 0.008764, 0.002216}; //static const float Weights[13] = { 0.2270270270, 0.3162162162, 0.0702702703, 0.064759, 0.120985, 0.176033, 0.199471, 0.176033, 0.120985, 0.064759, 0.026995, 0.008764, 0.002216}; //--------------------------------------------------------------------- // Sampler for the main texture //--------------------------------------------------------------------- sampler Sampler0 = sampler_state { Texture = (sTex0); MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; }; //--------------------------------------------------------------------- // Structure of data sent to the vertex shader //--------------------------------------------------------------------- struct VSInput { float3 Position : POSITION0; float4 Diffuse : COLOR0; float2 TexCoord : TEXCOORD0; }; //--------------------------------------------------------------------- // Structure of data sent to the pixel shader ( from the vertex shader ) //--------------------------------------------------------------------- struct PSInput { float4 Position : POSITION0; float4 Diffuse : COLOR0; float2 TexCoord: TEXCOORD0; }; //------------------------------------------------------------------------------------------ // VertexShaderFunction // 1. Read from VS structure // 2. Process // 3. Write to PS structure //------------------------------------------------------------------------------------------ PSInput VertexShaderFunction(VSInput VS) { PSInput PS = (PSInput)0; // Calculate screen pos of vertex PS.Position = MTACalcScreenPosition ( VS.Position ); // Pass through color and tex coord PS.Diffuse = VS.Diffuse; PS.TexCoord = VS.TexCoord; return PS; } //------------------------------------------------------------------------------------------ // PixelShaderFunction // 1. Read from PS structure // 2. Process // 3. Return pixel color //------------------------------------------------------------------------------------------ float4 PixelShaderFunction(PSInput PS) : COLOR0 { float4 Color = 0; float2 coord; coord.y = PS.TexCoord.y; for(int i = 0; i < 7; ++i) { coord.x = PS.TexCoord.x + Kernel[i]/sTex0Size.x; coord.y = PS.TexCoord.y + Kernel[i]/sTex0Size.y; Color += tex2D(Sampler0, coord.xy) * Weights[i] * sBloom; } Color = Color * PS.Diffuse; Color.a = 1; return Color; } //------------------------------------------------------------------------------------------ // Techniques //------------------------------------------------------------------------------------------ technique blurh { pass P0 { VertexShader = compile vs_2_0 VertexShaderFunction(); PixelShader = compile ps_2_0 PixelShaderFunction(); } } // Fallback technique fallback { pass P0 { // Just draw normally } } Link to comment
Ren_712 Posted September 19, 2012 Share Posted September 19, 2012 Forget the render targets. How about just getting screen source , applying the effect and then writing it. This might help. You have to understand that this bloom effect is quite demanding. addEventHandler( "onClientHUDRender", resourceRoot, function() if not Settings.var then return end if bAllValid then dxUpdateScreenSource( myScreenSource ) dxSetShaderValue( blurHShader, "TEX0", myScreenSource) dxSetShaderValue( blurHShader, "TEX0SIZE",scx/2,scy/2) dxSetShaderValue( blurHShader, "BLOOM", Settings.var.bloom ) dxDrawImage( 0, 0, scx, scy, blurHShader, 0,0,0) end end ) As for the FX file. In line 95 you can manipulate the value (how many times is the effect applied) the lower, the faster. Link to comment
Image Posted September 20, 2012 Author Share Posted September 20, 2012 Forget the render targets.How about just getting screen source , applying the effect and then writing it. This might help. You have to understand that this bloom effect is quite demanding. addEventHandler( "onClientHUDRender", resourceRoot, function() if not Settings.var then return end if bAllValid then dxUpdateScreenSource( myScreenSource ) dxSetShaderValue( blurHShader, "TEX0", myScreenSource) dxSetShaderValue( blurHShader, "TEX0SIZE",scx/2,scy/2) dxSetShaderValue( blurHShader, "BLOOM", Settings.var.bloom ) dxDrawImage( 0, 0, scx, scy, blurHShader, 0,0,0) end end ) As for the FX file. In line 95 you can manipulate the value (how many times is the effect applied) the lower, the faster. it doesn't work 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