eugene.litvinov Posted February 2, 2011 Share Posted February 2, 2011 It could be great to have ability to add post-effects to screen regions (through rectangles or texture masks). This will usable for game-gui elements, when under a window we see part of world with blur or something else. Link to comment
ulf.schroeter Posted February 2, 2011 Share Posted February 2, 2011 Some more details here Link to comment
ulf.schroeter Posted February 4, 2011 Share Posted February 4, 2011 Masked blur sample implementation based on existing UNIGINE blur shader. Out-of-the-box UNIGINE optional mask support for all post materials would be great. fragment_blur_mask_2d.shader (DIRECT3D9 excerpt) ... half mask_scale; half4 main(FRAGMENT_IN IN) : COLOR { half3 color = tex2D(s_texture_0,IN.texcoord_0.xy).xyz; half3 color_blured = color * 0.142300f + tex2D(s_texture_0,IN.texcoord_1.xy).xyz * 0.134610f + tex2D(s_texture_0,IN.texcoord_1.zw).xyz * 0.134610f + tex2D(s_texture_0,IN.texcoord_2.xy).xyz * 0.113945f + tex2D(s_texture_0,IN.texcoord_2.zw).xyz * 0.113945f + tex2D(s_texture_0,IN.texcoord_3.xy).xyz * 0.086310f + tex2D(s_texture_0,IN.texcoord_3.zw).xyz * 0.086310f + tex2D(s_texture_0,IN.texcoord_4.xy).xyz * 0.058501f + tex2D(s_texture_0,IN.texcoord_4.zw).xyz * 0.058501f + tex2D(s_texture_0,IN.texcoord_5.xy).xyz * 0.035483f + tex2D(s_texture_0,IN.texcoord_5.zw).xyz * 0.035483f; #ifdef MASK half mask_value = tex2D(s_texture_1,IN.texcoord_0.xy).x; color = lerp( color, color_blured, mask_scale * mask_value ); #endif return half4(color,1.0f); } .... post_h/vblur_mask_2d material definitions ... <material name="post_hblur_mask_2d" parent="post_hblur_2d" editable="0"> <state name="mask">1</state> <shader pass="post" defines="HBLUR" mask_defines=",MASK" vertex="core/shaders/post/vertex_blur_2d.shader" fragment="core/shaders/post/fragment_blur_mask_2d.shader"/> <texture name="Mask" unit="1" pass="post" mask="1" filter="bilinear">core/textures/post_blur_mask.dds</texture> <parameter name="mask_scale" mask="1" type="slider" shared="1" min="0.0" max="1.0">1.0</parameter> </material> <material name="post_vblur_mask_2d" parent="post_vblur_2d" editable="0"> <state name="mask">1</state> <shader pass="post" defines="VBLUR" mask_defines=",MASK" vertex="core/shaders/post/vertex_blur_2d.shader" fragment="core/shaders/post/fragment_blur_mask_2d.shader"/> <texture name="Mask" unit="1" pass="post" mask="1" filter="bilinear">core/textures/post_blur_mask.dds</texture> <parameter name="mask_scale" mask="1" type="slider" shared="1" min="0.0" max="1.0">1.0</parameter> </material> .... Usage Inherit from material post_vblur_mask_2d and/or post_hblur_mask_2d. Assign mask textures to inherited material(s) and use as render post materials. Mask influence can be dynamically scaled via material mask_scale parameter. Disabling mask state in inherited material(s) gives you default fullscreen blur. Sample 1 Link to comment
ulf.schroeter Posted February 5, 2011 Share Posted February 5, 2011 Thinking about more general solution it might be helpfull to have exposed ("hidden=0") post material hierarchy for easy setup of different user customized post material instances in material editor. Internal-only post materials like stereo post materials still could stay hidden. <material name="post_base" hidden="0" editable="0"> ... </material> <material name="post_hblur_2d" parent="post_base" hidden="0" editable="0"> ... </material> <material name="post_stereo" hidden="1"> ... </material> Link to comment
ulf.schroeter Posted March 6, 2011 Share Posted March 6, 2011 @UNIGINE any feedback ? Link to comment
ulf.schroeter Posted May 31, 2011 Share Posted May 31, 2011 Editable post material hiearchies available with latest SDK 20110531 Link to comment
Recommended Posts