Jump to content
  • Advertisement

Igor Kokarev

  • Content Count

  • Joined

  • Last visited

Community Reputation

115 Neutral

About Igor Kokarev

  • Rank
  1. Igor Kokarev

    [DX9] Blur with variable radius

    Update: The problem is solved. Thanks.   We're trying to implement 2-pass Gaussian blur on HSL2.0. Here is a code of shader for horizontal blur. Pixelwidth is a radius. This shader doesn't work, the result looks as without the shader, please can you help? sampler s0: register(s0); float1 pixelwidth: register(c0); float PixelKernel[13] = { -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, }; static const float BlurWeights[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, }; float1 Clip(float1 arg): float1 { if (arg<0) arg=0; if (arg>1) arg=1; return arg; } float4 main_ps(float2 tex: TEXCOORD0):COLOR { float4 cl=(0,0,0,0); float2 coord=tex; for (int i=0; i<13; i++){ coord.x=Clip(tex.x+PixelKernel*pixelwidth); cl+=tex2D(s0, coord)*BlurWeights; } return cl; }
  2. Igor Kokarev

    [DX9] Blur with variable radius

    We afraid that Summed Area Tables on PS 2.0 will not work fast enough.   Computable shaders is a good idea, but it require DX11 or Cuda.
  3. Igor Kokarev

    [DX9] Blur with variable radius

    Thanks, I'll try Summed Area Tables.
  4. Igor Kokarev

    [DX9] Blur with variable radius

    Thanks for your responses!   I need to apply a dynamic blur to photography for multimedia application in realtime. Blur radius will change in every frame smoothly. Radius will be between 0 and around 150.   Hodgman, I see very nice blur on your screenshot. My congratulations! Regrettably I need variable blur adjustable by user (templates).
  5. Please advice blur with variable radius with good quality for entire screen.   I've read advice to use separated gaussian blur x, y axis. However all examples were for certain fixed radius. How to implement variable radius?   Also it's important to avoid moire artefacts for animated objects inside blurred scene. We tried downsampling + spline and it gave moire defects.    
  6. phil_t,   Results are brilliant! Exactly what we need for a correct alpha blending. Thank you!
  7. phil_t,   Thanks again! I'll write about result.
  8. phil_t,   Thanks, we'll try idea with premultiplied alpha. Very interesting.     Please look on the following illustration:   [attachment=14384:86704_1363885776_compare.png]   - Left picture - layers in Photoshop.   - Right picture - rendering of alpha textures to alpha rendertarget.   Problems of DirectX rendering with D3DBLENDOP_ADD   1. Shadows of globes are more bright than on left picture. 2. Hardly visible visual artefacts on a border between two globes. 3. Color of shadows of globes depends on color of rendertarget, although color is transparent. Left part - black background color (alpha 0), right part - background color is red (alpha 0).   So as you can see the result is terrible. And we can't mix layers correctly for our multimedia application.        
  9. C0lumbo,   Thanks you for advice!   But if we understood rightly your sample, it doesn't take alpha of source textures. My images has semi-transparent areas and with your code pictures will have aliased edges. Right?     We need the following result:      resultAlpha = dstAlpha + srcAlpha - dstAlpha*srcAlpha ;    resultRed = ( dstRed*dstAlpha*(1-srcAlpha) + srcRed*srcAlpha  ) / resAlpha ;    resultGreen = ( dstGreen*dstAlpha*(1-srcAlpha) + srcGreen*srcAlpha  ) / resAlpha ;    resultBlue = ( dstBlue*dstAlpha*(1-srcAlpha) + srcBlue*srcAlpha  ) / resAlpha ;    Same formala is used in Photoshop to mix layers.
  10. I need to render several alpha textures (PNG images - photos and text) to 32-bit alpha RT. And then render alpha RT to backbuffer. This is for 2D multimedia app.   D3DBLENDOP_ADD doesn not mix correctly layers. The result is not same if I render alpha textures directly to 24-bit backbuffer.   In other words, I need same alpha blending as used for layers in Photoshop (by default).   I know alternate solution with rendering of each alpha texture to RT and then use shaders. But it works slow because of multiple switching of rendertargets for each alpha texture.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!