UE4:Shader
UE的材质一般包含了不同的材质模型
基础颜色
Metallic
高光度
粗糙度
各向异性
自发光颜色
不透明度
不透明蒙版
Normal
切线
世界场景位置偏移
世界场景位移
曲面细分乘数
Subsurface Color
Custom Data 0
Custom Data 1
环境光遮挡
折射
像素深度偏移
着色模型
HLSL
UE支持的是HLSL,OpenGL支持的是GLSL
struct Functions { float2 csqr( float2 a ) { return float2( a.x*a.x - a.y*a.y, 2.*a.x*a.y ); } float2 iSphere( in float3 ro, in float3 rd, in float4 sph )//from iq { float3 oc = ro;// - sph.xyz; float b = dot( oc, rd ); float c = dot( oc, oc ) - sph.w*sph.w; float h = 1.0; //b*b - c; return float2(-b-h, -b+h ); } float map(in float3 p, float2 sctime) { float res = 0.; float3 c = p; c.xy = c.xy * sctime.x + float2(c.y, c.x) * sctime.y; for (int i = 0; i < 10; ++i) { p =.7*abs(p)/dot(p,p) -.7; p.yz= csqr(p.yz); p=p.zxy; res += exp(-19. * abs(dot(p,c))); } return res/2.; } float3 raymarch( in float3 ro, float3 rd, float2 tminmax , float2 sctime) { //tminmax += float2(1.,1.) * sin( iTime * 1.3)*3.0; float3 one3 = float3(1.,1.,1.); float3 t = one3 * tminmax.x; float3 dt = float3(.07, 0.02, 0.05); float3 col= float3(0.0,0.0,0.0); float3 c = one3 * 0.; for( int i=0; i<64; i++ ) { float3 s = float3(2.0, 3.0, 4.0); t+=dt*exp(-s*c); float3 a = step(t,one3*tminmax.y); float3 pos = ro+t*rd; c.x = map(ro+t.x*rd, sctime); c.y = map(ro+t.y*rd, sctime); c.z = map(ro+t.z*rd, sctime); col = lerp(col, .99*col+ .08*c*c*c, a); } // float3 c0 = float3(0.4,0.3,0.99); // float3 c1 = float3(0.9,0.7,0.0); // float3 c2 = float3(0.9,0.1,0.2); return c0 * col.x + c1 * col.y + c2 * col.z; } }; Functions f; // float time; // float3 ro; float2 p = -1.0 + 2.0 * uv; // p.x *= iResolution.x/iResolution.y; float2 m = float2(0.0,0.0); // float3 ro = float3(15.0,0.0,0.0); float3 ta = float3( 0.0 , 0.0, 0.0 ); float3 ww = normalize( ta - ro ); float3 uu = normalize( cross(ww,float3(0.0,1.0,0.0) ) ); float3 vv = normalize( cross(uu,ww)); float3 rd = normalize( p.x*uu + p.y*vv + 4.0*ww ); float2 tmm = f.iSphere( ro, rd, float4(0.,0.,0.,2.) ); // raymarch float3 col = f.raymarch(ro,rd,tmm, float2(sin(time), cos(time))); // shade col = .5 *(log(1.+col)); col = clamp(col,0.,1.); return float4( col, 1.0 );
UE中的雾气
雾气分为扁平雾和体积雾
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)