载入中...
搜索中...
未找到
eve::weather::shaders 命名空间参考
变量 | |
| constexpr const char * | kWeatherVertWgsl |
| constexpr const char * | kWeatherFragWgsl |
| constexpr const char * | kBoltVertWgsl |
| constexpr const char * | kBoltFragWgsl |
变量说明
◆ kBoltFragWgsl
|
inlineconstexpr |
初始值:
= R"wgsl(
struct Params{data:array<vec4f,8>};struct In{@builtin(position) pos:vec4f,@location(1) uv:vec2f,@location(2) tint:vec4f,@location(3) world:vec3f,@location(5) view:vec3f};@group(0) @binding(15) var<uniform> params:Params;fn p(i:u32)->f32{return params.data[i/4u][i%4u];}
@fragment fn fs_main(i:In)->@location(0) vec4f{let flash=clamp(p(11u),0.0,1.0);if(flash<=0.01){discard;}let across=abs(i.uv.x);let core=1.0-smoothstep(0.08,0.34,across);let halo=pow(max(0.0,1.0-across),2.2)*flash;let bayer=array<f32,16>(0.0,0.5,0.125,0.625,0.75,0.25,0.875,0.375,0.1875,0.6875,0.0625,0.5625,0.9375,0.4375,0.8125,0.3125);let q=vec2u(i.pos.xy)%vec2u(4);if(max(core,halo*0.72)<=bayer[q.y*4u+q.x]){discard;}let color=mix(vec3f(0.20,0.38,0.95),vec3f(0.92,0.97,1.0),core)*(0.55+0.85*flash);let fog=clamp(1.0-exp(-length(i.view)*p(10u)),0.0,1.0);return vec4f(mix(color,vec3f(p(7u),p(8u),p(9u)),fog*0.6),1);}
)wgsl"
在文件 WeatherWgsl.h 第 86 行定义.
被这些函数引用 eve::weather::Weather::init().
◆ kBoltVertWgsl
|
inlineconstexpr |
初始值:
= R"wgsl(
struct Light3D{posRadius:vec4f,color:vec4f};struct Frame{mvp:mat4x4f,model:mat4x4f,lightDir:vec4f,lightColor:vec4f,tint:vec4f,cameraPos:vec4f,ambient:vec4f,lights:array<Light3D,8>,texBomb:vec4f,parallax:vec4f,surface:vec4f,view:mat4x4f,clipInfo:vec4f,cloud:vec4f,cloudWind:vec4f};struct In{@location(0) pos:vec3f,@location(1) normal:vec3f,@location(2) uv:vec2f};struct Out{@builtin(position) pos:vec4f,@location(0) normal:vec3f,@location(1) uv:vec2f,@location(2) tint:vec4f,@location(3) world:vec3f,@location(4) camera:vec3f,@location(5) view:vec3f};@group(0) @binding(0) var<uniform> frame:Frame;@vertex fn vs_main(i:In)->Out{let w=frame.model*vec4f(i.pos,1);var o:Out;o.pos=frame.mvp*vec4f(i.pos,1);o.pos.y=-o.pos.y;o.normal=i.normal;o.uv=i.uv;o.tint=frame.tint;o.world=w.xyz;o.camera=frame.cameraPos.xyz;o.view=(frame.view*w).xyz;return o;}
)wgsl"
在文件 WeatherWgsl.h 第 82 行定义.
被这些函数引用 eve::weather::Weather::init().
◆ kWeatherFragWgsl
|
inlineconstexpr |
初始值:
= R"wgsl(
struct Params{data:array<vec4f,8>};struct In{@builtin(position) pos:vec4f,@location(1) uv:vec2f,@location(2) tint:vec4f,@location(3) world:vec3f,@location(4) camera:vec3f,@location(5) view:vec3f,@location(6) particle:f32};
@group(0) @binding(1) var albedo:texture_2d<f32>;@group(0) @binding(7) var samp:sampler;@group(0) @binding(15) var<uniform> params:Params;fn p(i:u32)->f32{return params.data[i/4u][i%4u];}
@fragment fn fs_main(i:In)->@location(0) vec4f {
var tex=textureSample(albedo,samp,i.uv)*i.tint;
// Evaluate derivatives before particle discard for uniform control flow.
let t=i.uv.y;
let center=0.5+(0.045+i.particle*0.035)*sin(t*3.141593);
let taper=smoothstep(0.0,0.08,t)*(1.0-smoothstep(0.92,1.0,t));
let head=fract(p(0u)*0.22+i.particle*7.13)*1.5-0.25;
let along=1.0-t;
let light=smoothstep(head-0.32,head-0.12,along)*(1.0-smoothstep(head-0.035,head+0.025,along));
let halfWidth=0.006;
let aa=max(fwidth(i.uv.x-center),0.001);
if(p(12u)>1.5) {
let ribbon=1.0-smoothstep(max(halfWidth-aa,0.0),halfWidth+aa,abs(i.uv.x-center));
tex=vec4f(vec3f(0.94,0.98,1.0)*i.tint.rgb,ribbon*taper*light*i.tint.a*0.16);
}
if(p(6u)<=0.0 || i.particle>=p(6u)){discard;}
let coverage=sqrt(max(tex.a,0.0))*select(0.95,0.88,p(12u)>1.5);
let threshold=fract(52.9829189*fract(dot(floor(i.pos.xy),vec2f(0.06711056,0.00583715))));
if(coverage<=threshold){discard;}
let fog=clamp(1.0-exp(-length(i.view)*p(10u)),0.0,1.0);
let glint=0.72+0.28*pow(max(0.0,1.0-abs(i.uv.x-0.5)*2.0),2.0);
return vec4f(mix(tex.rgb*glint,vec3f(p(7u),p(8u),p(9u)),fog),1);
}
)wgsl"
在文件 WeatherWgsl.h 第 54 行定义.
被这些函数引用 eve::weather::Weather::init().
◆ kWeatherVertWgsl
|
inlineconstexpr |
在文件 WeatherWgsl.h 第 5 行定义.
被这些函数引用 eve::weather::Weather::init().