Jump to content

85242

Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by 85242

  1. not working, shows only the blur
  2. // // blackwhite.fx // texture screenSource; sampler TextureSampler = sampler_state { Texture = <screenSource>; }; float4 PixelShaderFunction(float2 TextureCoordinate : TEXCOORD0) : COLOR0 { float4 color = tex2D(TextureSampler, TextureCoordinate); float value = (color.r + color.g + color.b) / 11; color.r = value; color.g = value; color.b = value; return color; } technique BlackAndWhite { pass Pass1 { PixelShader = compile ps_2_0 PixelShaderFunction(); } } //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(); } }
  3. local blackWhiteShader = dxCreateShader("fx/blackwhite.fx") local screenX, screenY = guiGetScreenSize() local screenSource = dxCreateScreenSource(screenX, screenY) local blurStrength = 6 local blurShader = dxCreateShader("fx/BlurShader.fx") function doBlackAndWhite() if (blackWhiteShader) then dxUpdateScreenSource(screenSource) dxSetShaderValue(blackWhiteShader, "screenSource", screenSource) dxDrawImage(0, 0, screenX, screenY, blackWhiteShader) end end function blur() if (blurShader) then dxSetShaderValue(blurShader, "ScreenSource", screenSource); dxSetShaderValue(blurShader, "BlurStrength", blurStrength); dxSetShaderValue(blurShader, "UVSize", screenWidth, screenHeight); dxDrawImage(0, 0, screenX, screenY, blurShader) end end how to run these two shaders at once addEventHandler("onClientPreRender", getRootElement(), doBlackAndWhite) addEventHandler("onClientPreRender", getRootElement(), blur) it doesn't work. Only 1 shader load
  4. i want to make fade effect on every image switch like this: https://i.imgur.com/OA08JvD.mp4 Images = { {"image1.png", 255}, {"image2.png", 0}, }; function fadeImages() if (Images[1][2] > 0) then Images[1][2] = Images[1][2]-1; end if (Images[2][2] < 255) then Images[2][2] = Images[2][2]+1; end dxDrawImage(500, 500, 250, 250, Images[1][1], 0, 0, 0, tocolor(255, 255, 255, Images[1][2]), false); dxDrawImage(500, 500, 250, 250, Images[2][1], 0, 0, 0, tocolor(255, 255, 255, Images[2][2]), false); end but it's only work with 2 images, i have 4 images. can you help me with the code?
  5. hello how can i add fading effect on every image switch? local textures = {} for i=1, 4 do textures[i] = dxCreateTexture("img/bg" .. i .. ".png") or "img/bg" .. i .. ".png" -- apply a fallback in case of failing end local backgroundTexture = textures[1] function random() backgroundTexture = textures[math.random(4)] end setTimer( random, 3000, 0 ) local angle = 0 local function draw() dxDrawImage(0, 0, screenSize.x, screenSize.y, backgroundTexture, angle, 0, -120) end
×
×
  • Create New...