2021. 10. 8. 14:44ㆍunreal/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
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
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.
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;
==============================================================
'unreal > unreal materials' 카테고리의 다른 글
[Unreal_Materials]파도 (0) | 2022.08.04 |
---|---|
[Unreal]언리얼 공격판정 머터리얼 / Attack Preview Decal Material (3) | 2022.02.16 |
[Unreal]언리얼 스폰용 머터리얼 제작 / material _ Death & spawn Effect (0) | 2020.11.04 |
언리얼 카툰 머터리얼_Unreal simple Cartoon Material (0) | 2019.11.05 |