@@ -235,16 +235,13 @@ fn fresnel(f0: vec3<f32>, LdotH: f32) -> vec3<f32> {
235
235
// Multiscattering approximation:
236
236
// <https://google.github.io/filament/Filament.html#listing_energycompensationimpl>
237
237
fn specular_multiscatter (
238
- input : ptr <function , LightingInput >,
239
238
D : f32 ,
240
239
V : f32 ,
241
240
F : vec3 <f32 >,
241
+ F0 : vec3 <f32 >,
242
+ F_ab: vec2 <f32 >,
242
243
specular_intensity : f32 ,
243
244
) -> vec3 <f32 > {
244
- // Unpack.
245
- let F0 = (*input ). F0_;
246
- let F_ab = (*input ). F_ab;
247
-
248
245
var Fr = (specular_intensity * D * V ) * F ;
249
246
Fr *= 1.0 + F0 * (1.0 / F_ab. x - 1.0 );
250
247
return Fr ;
@@ -329,7 +326,7 @@ fn specular(
329
326
let F = fresnel (F0 , LdotH );
330
327
331
328
// Calculate the specular light.
332
- let Fr = specular_multiscatter (input , D , V , F , specular_intensity );
329
+ let Fr = specular_multiscatter (D , V , F , F0 , (* input ) . F_ab , specular_intensity );
333
330
return Fr ;
334
331
}
335
332
@@ -397,7 +394,7 @@ fn specular_anisotropy(
397
394
let Fa = fresnel (F0 , LdotH );
398
395
399
396
// Calculate the specular light.
400
- let Fr = specular_multiscatter (input , Da , Va , Fa , specular_intensity );
397
+ let Fr = specular_multiscatter (Da , Va , Fa , F0 , (* input ) . F_ab , specular_intensity );
401
398
return Fr ;
402
399
}
403
400
@@ -482,7 +479,7 @@ fn cubemap_uv(direction: vec3<f32>, cubemap_type: u32) -> vec2<f32> {
482
479
),
483
480
max_axis != abs_direction . x
484
481
);
485
-
482
+
486
483
var face_uv : vec2 <f32 >;
487
484
var divisor : f32 ;
488
485
var corner_uv : vec2 <u32 > = vec2 (0 , 0 );
@@ -500,12 +497,12 @@ fn cubemap_uv(direction: vec3<f32>, cubemap_type: u32) -> vec2<f32> {
500
497
face_uv = (face_uv / divisor ) * 0.5 + 0.5 ;
501
498
502
499
switch cubemap_type {
503
- case CUBEMAP_TYPE_CROSS_VERTICAL: {
504
- face_size = vec2 (1.0 / 3.0 , 1.0 / 4.0 );
500
+ case CUBEMAP_TYPE_CROSS_VERTICAL: {
501
+ face_size = vec2 (1.0 / 3.0 , 1.0 / 4.0 );
505
502
corner_uv = vec2 <u32 >((0x111102u >> (4 * face_index )) & 0xFu , (0x132011u >> (4 * face_index )) & 0xFu );
506
503
}
507
- case CUBEMAP_TYPE_CROSS_HORIZONTAL: {
508
- face_size = vec2 (1.0 / 4.0 , 1.0 / 3.0 );
504
+ case CUBEMAP_TYPE_CROSS_HORIZONTAL: {
505
+ face_size = vec2 (1.0 / 4.0 , 1.0 / 3.0 );
509
506
corner_uv = vec2 <u32 >((0x131102u >> (4 * face_index )) & 0xFu , (0x112011u >> (4 * face_index )) & 0xFu );
510
507
}
511
508
case CUBEMAP_TYPE_SEQUENCE_HORIZONTAL: {
@@ -765,7 +762,7 @@ fn directional_light(
765
762
view_bindings ::clustered_decal_sampler ,
766
763
decal_uv - floor (decal_uv ),
767
764
0.0
768
- ). r;
765
+ ). r;
769
766
} else {
770
767
texture_sample = 0f ;
771
768
}
0 commit comments