[Unreal]언리얼 커스텀 블러(발자국용) / Simple Blur Material on SnowTrail

2021. 10. 8. 14:44unreal/unreal materials

 

this blog explains the cheap Simple Blur Material

 

Snow Trile based on "that link

https://www.raywenderlich.com/5760-creating-snow-trails-in-unreal-engine-4

 

Creating Snow Trails in Unreal Engine 4

In this Unreal Engine 4 tutorial, you will learn how to create deformable snow trails using a scene capture and render targets

www.raywenderlich.com

also basic system used in "interactive water in real game project" - https://bigflash0913.tistory.com/16"

 

The basic idea is to capture what you need, draw it on a texture, and use that texture to represent it.

 

 

in normal case project is using "show only list"mode in scene capture because performance.
 so we need to sending "show only list" the necessary capturing objects

 

Anyway, if we follow the link, we have some nice snow trails and footprints.

It is looks like that image

HardEdge trail
Blur Edge

trail's edge is to hard , 

now we make it like right image using blure with Some fake

 

look this image 

we copies three or four times original image and past some manipulated

 

this Function is workin in landscape material.

footprint node(linked to tesselation slot)
4way blur 

1.projection base UV

- it is explaned in link

 

This node converts the position of the world coordinates around the character into uv.

 

 

2.  edgeparameters

thes section inclued parameters of edge controll

EdgeNoise - look kile this image

using noise for Footprint & Edge

 

EdgeNoiseUV - EdgeNoise textur's uv tiling

EdgeNoiseTexPow - intensity noise

DisplacementHeight - depth of footprint

 

3.base foot print

Tex - footprint rendertarget texture

thes section include parameters of representing footprints or trail

Steps - number of blur steps

Distance - blure max distance

 

4wayblur code

==========================================

float3 CurColor;

float3 CurColor0 = 0.0;

float3 CurColor1 = 0.0;

float3 CurColor2 = 0.0;

float3 CurColor3 = 0.0;

float3 CurColor4 = 0.0;

 

float3 newSample = 0.0;

float3 EdgemaskSample = 0.0;

float2 Vector;

float2 NewUV;

 

int i;

Steps = max(Steps, 1);

float StepSize = Distance / (int) Steps;

CurColor0 = Texture2DSample(Tex,TexSampler,UV);

EdgemaskSample = saturate(Texture2DSampleLevel(EdgeNoise,EdgeNoiseSampler,EdgeNoiseUV, 0.0f)+EdgeNoiseTexPow);

 

EdgePow = (DisplacementHeight/25)*EdgePow;

 

    Vector = float2(1.0, 1.0);

 

    //4Way blur

 

        NewUV = UV;

        while ( i < (int) Steps) 

            {

            NewUV.x += (StepSize * Vector.x);// Right Blur

            float3 newSample1=Texture2DSampleLevel(Tex,TexSampler,NewUV, 0.0f);

            float3 CurrentAbberationValue = 0.0;

 

                if(i == Steps-1)

                {

                CurrentAbberationValue=-1*EdgePow;

// If the current step is the last step-1, apply the lifted value

 

                }

                    else

                {               

                CurrentAbberationValue=saturate(1.0-abs((i+1.0)*(1/Steps))); }           

// normal blur Function

decreasing texture's intensity by number of copied

               

 

            CurColor1 += newSample1*CurrentAbberationValue;          

            i++;

            }

 

        NewUV = UV;

        i = 0.0;

        while ( i < (int) Steps)

            {

 

            NewUV.x += (StepSize * Vector.x*-1.0);// Left Blur

 

            float3 newSample2=Texture2DSampleLevel(Tex,TexSampler,NewUV, 0.0f);

                        float3 CurrentAbberationValue = 0.0;

                if(i == Steps-1)

                {

                CurrentAbberationValue=-1*EdgePow;

                }

                    else

                {               

                CurrentAbberationValue=saturate(1.0-abs((i+1.0)*(1/Steps)));

                }           

            

            CurColor2 += newSample2*CurrentAbberationValue;

           

            i++;

            }

 

    

 

        NewUV = UV;

        i = 0.0;

        while ( i < (int) Steps)

            {

 

            NewUV.y += (StepSize * Vector.y);

 

            float3 newSample2=Texture2DSampleLevel(Tex,TexSampler,NewUV, 0.0f);

                        float3 CurrentAbberationValue = 0.0;

                if(i == Steps-1)

                {

                CurrentAbberationValue=-1*EdgePow;

                }

                    else

                {               

                CurrentAbberationValue=saturate(1.0-abs((i+1.0)*(1/Steps)));

                }           

        

            CurColor3 += newSample2*CurrentAbberationValue;



            i++;

            }



        NewUV = UV;

        i = 0.0;

        while ( i < (int) Steps)

            {

 

          

            NewUV.y += (StepSize * Vector.y*-1.0);

 

            float3 newSample2=Texture2DSampleLevel(Tex,TexSampler,NewUV, 0.0f);

                        float3 CurrentAbberationValue = 0.0;

                if(i == Steps-1)

                {

                CurrentAbberationValue=-1*EdgePow;

                }

                    else

                {               

                CurrentAbberationValue=saturate(1.0-abs((i+1.0)*(1/Steps)));

                }           

         

            CurColor4 += newSample2*CurrentAbberationValue;



            i++;

            }

        

   

CurColor = (CurColor1+CurColor2+CurColor3+CurColor4)*BlurAlpha*EdgemaskSample;

//collapse all samples(up, down, left, right)and  multiply edge mask and blur power

 

return CurColor;

 

==============================================================