UE4_如果快速做出毛玻璃效果_假景深

UE4_如果快速做出毛玻璃效果_假景深

2022-08-20 15:02

一个SpiralBlur-SceneTexture材质节点完成效果,启用半透明材质

通过修改BlurAmount数值大小调整效果

spiralBlur-SceneTexture

custom节点,HLSL语言

float3 CurColor = 0;

float2 BaseUV = MaterialFloat2(ScreenAlignedPosition(Parameters.ScreenPosition).xy);

float2 NewUV = BaseUV;

float StepSize = Distance / (int) DistanceSteps;

float CurDistance = 0;

float2 CurOffset = 0;

float TwoPi = 6.283185;

float Substep = 0;

float2 ScenePixels=View.BufferSizeAndInvSize.xy*BaseUV;

ScenePixels+=View.TemporalAAParams.r;

float2 RandomSamp = ((uint)(ScenePixels.x) + 2 * (uint)(ScenePixels.y)) % 5;

RandomSamp+=Texture2DSample(Tex,TexSampler,ScenePixels);

RandomSamp/=5;

RandomSamp-=0.5;

TempAARotation*=RandomSamp;

TempAADistance*=StepSize*RandomSamp;

int i=0;

if (DistanceSteps<1)

{ return DecodeSceneColorForMaterialNode(NewUV);

} else

{ //CurDistance += 0.5*StepSize;

while ( i < (int) DistanceSteps)

{

//CurDistance+=StepSize;

for (int j = 0; j < (int) RadialSteps; j++)

{ CurOffset.x = cos(TwoPi*((TempAARotation+Substep) / RadialSteps));

CurOffset.y = sin(TwoPi*((TempAARotation+Substep) / RadialSteps));

CurOffset *=DistanceMask;

NewUV.x = BaseUV.x + (CurOffset.x * (CurDistance+(RandomSamp*TempAADistance)));

NewUV.y = BaseUV.y + (CurOffset.y * (CurDistance+(RandomSamp*TempAADistance)));

CurColor += DecodeSceneColorForMaterialNode(NewUV);

//CurDistance+=(StepSize+(TempAADistance))/RadialSteps;

Substep++;

} CurDistance+=StepSize;

Substep+=RadialOffset;

i++;

} CurColor = CurColor / ((int)DistanceSteps*(int)RadialSteps);

return CurColor;

}

spiralBlur-Texture

float3 CurColor=0;

float2 NewUV = UV;

int i=0;

float StepSize = Distance / (int) DistanceSteps;

float CurDistance=0;

float2 CurOffset=0;

float SubOffset = 0;

float TwoPi = 6.283185;

float accumdist=0;

if (DistanceSteps < 1)

{ return Texture2DSample(Tex,TexSampler,UV);

} else

{ while ( i < (int) DistanceSteps)

{ CurDistance += StepSize;

for (int j = 0; j < (int) RadialSteps; j++)

{

SubOffset +=1;

CurOffset.x = cos(TwoPi*(SubOffset / RadialSteps));

CurOffset.y = sin(TwoPi*(SubOffset / RadialSteps));

NewUV.x = UV.x + CurOffset.x * CurDistance;

NewUV.y = UV.y + CurOffset.y * CurDistance;

float distpow = pow(CurDistance, KernelPower);

CurColor += Texture2DSample(Tex,TexSampler,NewUV)*distpow;

accumdist += distpow;

}

SubOffset +=RadialOffset;

i++;

} CurColor = CurColor;

CurColor /=accumdist;

return CurColor;

}

评论(0)

相关推荐
闲晨3 小时前
C++ 继承:代码传承的魔法棒,开启奇幻编程之旅
java·c语言·开发语言·c++·经验分享
幼儿园老大*4 小时前
Go的环境搭建以及GoLand安装教程
开发语言·经验分享·后端·golang·go
考试宝4 小时前
国家宠物美容师职业技能等级评价(高级)理论考试题
经验分享·笔记·职场和发展·学习方法·业界资讯·宠物
momo_aa11 小时前
mac找到主目录下的文件夹
经验分享
天行健PLUS17 小时前
【经验分享】六西格玛管理培训适合哪些人参加?
经验分享
小奥超人18 小时前
PPT文件设置了修改权限,如何取消权?
windows·经验分享·microsoft·ppt·办公技巧
Jack黄从零学c++21 小时前
C++ 的异常处理详解
c++·经验分享
做网站建设制作设计小程序推广1 天前
如何建购物网站提升用户体验
经验分享
程思扬1 天前
为什么Uptime+Kuma本地部署与远程使用是网站监控新选择?
linux·服务器·网络·经验分享·后端·网络协议·1024程序员节
白狐欧莱雅1 天前
使用python中的pygame简单实现飞机大战游戏
经验分享·python·游戏·pygame