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)

相关推荐
汇能感知1 小时前
光谱相机的工作原理
经验分享·笔记·科技·相机
汇能感知1 小时前
光谱相机在农业中的具体应用案例
经验分享·笔记·科技
番茄电脑全能王1 小时前
《战神:诸神黄昏》游戏运行时提示找不到emp.dll怎么办?emp.dll丢失如何修复?
经验分享·游戏·电脑
赵谨言2 小时前
基于python 微信小程序的医院就诊小程序
经验分享·python·毕业设计
asyxchenchong8883 小时前
GEE云计算、多源遥感、高光谱遥感技术蓝碳储量估算;红树林植被指数计算及提取
经验分享
asyxchenchong8883 小时前
生态学研究新工具:CASA模型原理解析与MODIS NDVI/FPAR遥感数据处理
经验分享
黑客老陈9 小时前
面试经验分享 | 北京渗透测试岗位
运维·服务器·经验分享·安全·web安全·面试·职场和发展
做网站建设制作设计小程序推广17 小时前
武汉做网站优化推广效果的科学评估方法
经验分享
咏颜21 小时前
Ubuntu离线安装Docker容器
linux·运维·服务器·经验分享·ubuntu·docker
志-AOX1 天前
IDEA用jformdesigner插件做管理系统MVC架构
经验分享