Jump to content

Use post-processing for part of screen (gui part)


photo

Recommended Posts

I see nice effect in main menu of OilRush: blur back when menu-windows opens. It's done by global post-processing:

engine.render.setColorSaturation(0.5f);
engine.render.setColorContrast(0.3f);
engine.render.setMaterials("post_hblur_2d,post_vblur_2d");

I need to have blur in part of screen under my gui sprite (like focusing screen).

Can I set material for sprite (with half-transparent texture), that can be blur 3d word under it?

Or it can be done only with WidgetSpriteViewport, and I need to draw my world into it and then apply material to it? (it seems not easy way :) )

 

See screenshot.

post-151-0-09966200-1296644222_thumb.jpg

Link to comment

Can I set material for sprite (with half-transparent texture), that can be blur 3d word under it?

 

I don't think so, as post-materials only work on full screen or render target dimensions

 

Or it can be done only with WidgetSpriteViewport, and I need to draw my world into it and then apply material to it?

 

Should be possible. But maybe there is an easier approach by extending existing post_hblur_2d and post_vblur_2d post-materials (have a look into data\core\materials\unigine_post.mat and core/shaders/post/fragment_blur_2d.shader)

 

Simple idea:

 

  1. add a additional (optional) mask texture to post_hblur_2d and post_vblur_2d post-materials. For every screen pixel where you want blurring set mask texture to 1, else 0 (or a value [0-1])
  2. Extend blur_2d_fragment.shader and add a first-step texel lookup of your additional mask texture for current pixel and blur pixel only if mask texel=1 (or use some blending between unblured color value and blurred on based on mask texel value [0-1])
  3. Assign propper mask texture to your custom post_hblur_2d and post_vblur_2d material. Mask textures can be generated offline if the regions where you want blurring are static or dynamically via UNIGINE script image class (e.g. based on current widget position)

 

Maybe UNIGINE is willing to include such add-on as an option if you kindly ask for it (I guess Alexander could implement such thing within minutes). Having an - optional - opportunity to mask/scale some post-processing effect to certain regions might be a cool effect variation.

Link to comment
×
×
  • Create New...