1import bevy_render::bindless::{bindless_samplers_filtering, bindless_textures_2d}; 6 pbr_functions::SampleBias, 9 pbr_lighting as lighting, 11 mesh_view_bindings::view, 12 parallax_mapping::parallaxed_uv, 14 prepass::utils as prepass_utils, 18@if(SCREEN_SPACE_AMBIENT_OCCLUSION) 19import package::render::mesh_view_bindings::screen_space_ambient_occlusion_texture; 20@if(SCREEN_SPACE_AMBIENT_OCCLUSION) 21import package::ssao::utils::ssao_multibounce; 23@if(MESHLET_MESH_MATERIAL_PASS) 24import package::meshlet::visibility_buffer_resolve::VertexOutput; 25@elif(PREPASS_PIPELINE) 26import package::prepass::io::VertexOutput; 28import package::render::forward_io::VertexOutput; 31import package::render::pbr_bindings::material_indices; 34fn pbr_input_from_vertex_output( 38) -> pbr_types::PbrInput { 39 var pbr_input: pbr_types::PbrInput = pbr_types::pbr_input_new(); 41@if(MESHLET_MESH_MATERIAL_PASS) 42 pbr_input.flags = in.mesh_flags; 44 pbr_input.flags = mesh[in.instance_index].flags; 46 pbr_input.is_orthographic = view.clip_from_view[3].w == 1.0; 47 pbr_input.V = pbr_functions::calculate_view(in.world_position, pbr_input.is_orthographic); 48 pbr_input.frag_coord = in.position; 49 pbr_input.world_position = in.world_position; 52 pbr_input.material.base_color = in.color; 54 let is_logically_front = pbr_functions::winding_corrected_front_facing(pbr_input.flags, is_front); 55 pbr_input.world_normal = pbr_functions::prepare_world_normal( 61@if(LOAD_PREPASS_NORMALS) 62 pbr_input.N = prepass_utils::prepass_normal(in.position, 0u); 64 pbr_input.N = normalize(pbr_input.world_normal); 71fn pbr_input_from_standard_material( 74) -> pbr_types::PbrInput { 75@if(MESHLET_MESH_MATERIAL_PASS) 76 let slot = in.material_bind_group_slot; 78 let slot = mesh[in.instance_index].material_and_lightmap_bind_group_slot & 0xffffu; 80 let flags = pbr_bindings::material_array[material_indices[slot].material].flags; 82 let flags = pbr_bindings::material.flags; 84 let base_color = pbr_bindings::material_array[material_indices[slot].material].base_color; 86 let base_color = pbr_bindings::material.base_color; 88 let deferred_lighting_pass_id = 89 pbr_bindings::material_array[material_indices[slot].material].deferred_lighting_pass_id; 91 let deferred_lighting_pass_id = pbr_bindings::material.deferred_lighting_pass_id; 93 let alpha_cutoff = pbr_bindings::material_array[material_indices[slot].material].alpha_cutoff; 95 let alpha_cutoff = pbr_bindings::material.alpha_cutoff; 97 let double_sided = (flags & pbr_types::STANDARD_MATERIAL_FLAGS_DOUBLE_SIDED_BIT) != 0u; 99 var pbr_input: pbr_types::PbrInput = pbr_input_from_vertex_output(in, is_front, double_sided); 100 pbr_input.material.flags = flags; 101 pbr_input.material.base_color *= base_color; 102 pbr_input.material.deferred_lighting_pass_id = deferred_lighting_pass_id; 103 let is_logically_front = pbr_functions::winding_corrected_front_facing(pbr_input.flags, is_front); 106 let NdotV = max(dot(pbr_input.N, pbr_input.V), 0.0001); 109 var bias: SampleBias; 110@if(MESHLET_MESH_MATERIAL_PASS) { 112 let mip_scale = exp2(view.mip_bias); 113 bias.ddx_uv = in.ddx_uv * mip_scale; 114 bias.ddy_uv = in.ddy_uv * mip_scale; 117 bias.mip_bias = view.mip_bias; 122@if(VERTEX_UVS && BINDLESS) 123 let uv_transform = pbr_bindings::material_array[material_indices[slot].material].uv_transform; 125 let uv_transform = pbr_bindings::material.uv_transform; 128pbr_input.material.uv_transform = uv_transform; 130@if(VERTEX_UVS && VERTEX_UVS_A) 131 var uv = (uv_transform * vec3(in.uv, 1.0)).xy; 134@if(VERTEX_UVS && VERTEX_UVS_B) 135 var uv_b = (uv_transform * vec3(in.uv_b, 1.0)).xy; 139@if(VERTEX_UVS && VERTEX_TANGENTS) 140 if ((flags & pbr_types::STANDARD_MATERIAL_FLAGS_DEPTH_MAP_BIT) != 0u) { 142 let TBN = pbr_functions::calculate_tbn_mikktspace(in.world_normal, in.world_tangent); 147 let Vt = vec3(dot(V, T), dot(V, B), dot(V, N)); 149 let parallax_depth_scale = pbr_bindings::material_array[material_indices[slot].material].parallax_depth_scale; 151 let parallax_depth_scale = pbr_bindings::material.parallax_depth_scale; 153 let max_parallax_layer_count = pbr_bindings::material_array[material_indices[slot].material].max_parallax_layer_count; 155 let max_parallax_layer_count = pbr_bindings::material.max_parallax_layer_count; 157 let max_relief_mapping_search_steps = pbr_bindings::material_array[material_indices[slot].material].max_relief_mapping_search_steps; 159 let max_relief_mapping_search_steps = pbr_bindings::material.max_relief_mapping_search_steps; 163 parallax_depth_scale, 164 max_parallax_layer_count, 165 max_relief_mapping_search_steps, 177 uv_b = parallaxed_uv( 178 parallax_depth_scale, 179 max_parallax_layer_count, 180 max_relief_mapping_search_steps, 194 if ((flags & pbr_types::STANDARD_MATERIAL_FLAGS_BASE_COLOR_TEXTURE_BIT) != 0u) { 196 let texture = bindless_textures_2d[material_indices[slot].base_color_texture]; 198 let texture = pbr_bindings::base_color_texture; 200 let sampler_ = bindless_samplers_filtering[material_indices[slot].base_color_sampler]; 202 let sampler_ = pbr_bindings::base_color_sampler; 203 @if(STANDARD_MATERIAL_BASE_COLOR_UV_B) 207 @if(MESHLET_MESH_MATERIAL_PASS) 208 pbr_input.material.base_color *= textureSampleGrad(texture, sampler_, coords, bias.ddx_uv, bias.ddy_uv); 210 pbr_input.material.base_color *= textureSampleBias(texture, sampler_, coords, bias.mip_bias); 212@if(ALPHA_TO_COVERAGE) { 216 let alpha_mode = flags & pbr_types::STANDARD_MATERIAL_FLAGS_ALPHA_MODE_RESERVED_BITS; 217 if alpha_mode == pbr_types::STANDARD_MATERIAL_FLAGS_ALPHA_MODE_ALPHA_TO_COVERAGE { 220 let alpha_cutoff = pbr_bindings::material_array[material_indices[slot].material].alpha_cutoff; 222 let alpha_cutoff = pbr_bindings::material.alpha_cutoff; 224 pbr_input.material.base_color.a = (pbr_input.material.base_color.a - alpha_cutoff) / 225 max(fwidth(pbr_input.material.base_color.a), 0.0001) + 0.5; 231 pbr_input.material.flags = flags; 232 pbr_input.material.alpha_cutoff = alpha_cutoff; 235 if ((flags & pbr_types::STANDARD_MATERIAL_FLAGS_UNLIT_BIT) == 0u) { 237 pbr_input.material.ior = pbr_bindings::material_array[material_indices[slot].material].ior; 238 pbr_input.material.attenuation_color = 239 pbr_bindings::material_array[material_indices[slot].material].attenuation_color; 240 pbr_input.material.attenuation_distance = 241 pbr_bindings::material_array[material_indices[slot].material].attenuation_distance; 244 pbr_input.material.ior = pbr_bindings::material.ior; 245 pbr_input.material.attenuation_color = pbr_bindings::material.attenuation_color; 246 pbr_input.material.attenuation_distance = pbr_bindings::material.attenuation_distance; 251 pbr_input.material.reflectance = 252 pbr_bindings::material_array[material_indices[slot].material].reflectance; 254 pbr_input.material.reflectance = pbr_bindings::material.reflectance; 256@if(PBR_SPECULAR_TEXTURES_SUPPORTED && VERTEX_UVS) { 259 if ((flags & pbr_types::STANDARD_MATERIAL_FLAGS_SPECULAR_TEXTURE_BIT) != 0u) { 261 let texture = bindless_textures_2d[material_indices[slot].specular_texture]; 263 let texture = pbr_bindings::specular_texture; 265 let sampler_ = bindless_samplers_filtering[material_indices[slot].specular_sampler]; 267 let sampler_ = pbr_bindings::specular_sampler; 268 @if(STANDARD_MATERIAL_SPECULAR_UV_B) 272 @if(MESHLET_MESH_MATERIAL_PASS) 273 let specular = textureSampleGrad(texture, sampler_, coords, bias.ddx_uv, bias.ddy_uv).a; 275 let specular = textureSampleBias(texture, sampler_, coords, bias.mip_bias).a; 278 pbr_input.material.reflectance *= specular * 0.5; 282 if ((flags & pbr_types::STANDARD_MATERIAL_FLAGS_SPECULAR_TINT_TEXTURE_BIT) != 0u) { 284 let texture = bindless_textures_2d[material_indices[slot].specular_tint_texture]; 286 let texture = pbr_bindings::specular_tint_texture; 288 let sampler_ = bindless_samplers_filtering[material_indices[slot].specular_tint_sampler]; 290 let sampler_ = pbr_bindings::specular_tint_sampler; 291 @if(STANDARD_MATERIAL_SPECULAR_TINT_UV_B) 295 @if(MESHLET_MESH_MATERIAL_PASS) 296 let specular_tint = textureSampleGrad(texture, sampler_, coords, bias.ddx_uv, bias.ddy_uv).rgb; 298 let specular_tint = textureSampleBias(texture, sampler_, coords, bias.mip_bias).rgb; 299 pbr_input.material.reflectance *= specular_tint; 306 var emissive: vec4<f32> = pbr_bindings::material_array[material_indices[slot].material].emissive; 308 var emissive: vec4<f32> = pbr_bindings::material.emissive; 311 if ((flags & pbr_types::STANDARD_MATERIAL_FLAGS_EMISSIVE_TEXTURE_BIT) != 0u) { 313 let texture = bindless_textures_2d[material_indices[slot].emissive_texture]; 315 let texture = pbr_bindings::emissive_texture; 317 let sampler_ = bindless_samplers_filtering[material_indices[slot].emissive_sampler]; 319 let sampler_ = pbr_bindings::emissive_sampler; 320 @if(STANDARD_MATERIAL_EMISSIVE_UV_B) 324 @if(MESHLET_MESH_MATERIAL_PASS) 325 emissive = vec4<f32>(emissive.rgb * textureSampleGrad(texture, sampler_, coords, bias.ddx_uv, bias.ddy_uv).rgb, emissive.a); 327 emissive = vec4<f32>(emissive.rgb * textureSampleBias(texture, sampler_, coords, bias.mip_bias).rgb, emissive.a); 329 pbr_input.material.emissive = emissive; 333 var metallic: f32 = pbr_bindings::material_array[material_indices[slot].material].metallic; 335 var metallic: f32 = pbr_bindings::material.metallic; 337 var perceptual_roughness: f32 = pbr_bindings::material_array[material_indices[slot].material].perceptual_roughness; 339 var perceptual_roughness: f32 = pbr_bindings::material.perceptual_roughness; 342 if ((flags & pbr_types::STANDARD_MATERIAL_FLAGS_METALLIC_ROUGHNESS_TEXTURE_BIT) != 0u) { 344 let texture = bindless_textures_2d[material_indices[slot].metallic_roughness_texture]; 346 let texture = pbr_bindings::metallic_roughness_texture; 348 let sampler_ = bindless_samplers_filtering[material_indices[slot].metallic_roughness_sampler]; 350 let sampler_ = pbr_bindings::metallic_roughness_sampler; 351 @if(STANDARD_MATERIAL_METALLIC_ROUGHNESS_UV_B) 355 @if(MESHLET_MESH_MATERIAL_PASS) 356 let metallic_roughness = textureSampleGrad(texture, sampler_, coords, bias.ddx_uv, bias.ddy_uv); 358 let metallic_roughness = textureSampleBias(texture, sampler_, coords, bias.mip_bias); 359 if ((flags & pbr_types::STANDARD_MATERIAL_FLAGS_METALLIC_ROUGHNESS_RG_BIT) != 0u) { 360 perceptual_roughness *= metallic_roughness.r; 361 metallic *= metallic_roughness.g; 364 perceptual_roughness *= metallic_roughness.g; 365 metallic *= metallic_roughness.b; 368 pbr_input.material.metallic = metallic; 369 pbr_input.material.perceptual_roughness = perceptual_roughness; 373 pbr_input.material.clearcoat = 374 pbr_bindings::material_array[material_indices[slot].material].clearcoat; 376 pbr_input.material.clearcoat = pbr_bindings::material.clearcoat; 378@if(VERTEX_UVS && PBR_MULTI_LAYER_MATERIAL_TEXTURES_SUPPORTED) 379 if ((flags & pbr_types::STANDARD_MATERIAL_FLAGS_CLEARCOAT_TEXTURE_BIT) != 0u) { 381 let texture = bindless_textures_2d[material_indices[slot].clearcoat_texture]; 383 let texture = pbr_bindings::clearcoat_texture; 385 let sampler_ = bindless_samplers_filtering[material_indices[slot].clearcoat_sampler]; 387 let sampler_ = pbr_bindings::clearcoat_sampler; 388 @if(STANDARD_MATERIAL_CLEARCOAT_UV_B) 392 @if(MESHLET_MESH_MATERIAL_PASS) 393 pbr_input.material.clearcoat *= textureSampleGrad(texture, sampler_, coords, bias.ddx_uv, bias.ddy_uv).r; 395 pbr_input.material.clearcoat *= textureSampleBias(texture, sampler_, coords, bias.mip_bias).r; 400 pbr_input.material.clearcoat_perceptual_roughness = 401 pbr_bindings::material_array[material_indices[slot].material].clearcoat_perceptual_roughness; 403 pbr_input.material.clearcoat_perceptual_roughness = 404 pbr_bindings::material.clearcoat_perceptual_roughness; 406@if(VERTEX_UVS && PBR_MULTI_LAYER_MATERIAL_TEXTURES_SUPPORTED) 407 if ((flags & pbr_types::STANDARD_MATERIAL_FLAGS_CLEARCOAT_ROUGHNESS_TEXTURE_BIT) != 0u) { 409 let texture = bindless_textures_2d[material_indices[slot].clearcoat_roughness_texture]; 411 let texture = pbr_bindings::clearcoat_roughness_texture; 413 let sampler_ = bindless_samplers_filtering[material_indices[slot].clearcoat_roughness_sampler]; 415 let sampler_ = pbr_bindings::clearcoat_roughness_sampler; 416 @if(STANDARD_MATERIAL_CLEARCOAT_ROUGHNESS_UV_B) 420 @if(MESHLET_MESH_MATERIAL_PASS) 421 pbr_input.material.clearcoat_perceptual_roughness *= textureSampleGrad(texture, sampler_, coords, bias.ddx_uv, bias.ddy_uv).g; 423 pbr_input.material.clearcoat_perceptual_roughness *= textureSampleBias(texture, sampler_, coords, bias.mip_bias).g; 427 var specular_transmission: f32 = 428 pbr_bindings::material_array[material_indices[slot].material].specular_transmission; 430 var specular_transmission: f32 = pbr_bindings::material.specular_transmission; 432@if(VERTEX_UVS && PBR_TRANSMISSION_TEXTURES_SUPPORTED) 433 if ((flags & pbr_types::STANDARD_MATERIAL_FLAGS_SPECULAR_TRANSMISSION_TEXTURE_BIT) != 0u) { 435 let texture = bindless_textures_2d[ 436 material_indices[slot].specular_transmission_texture 439 let texture = pbr_bindings::specular_transmission_texture; 441 let sampler_ = bindless_samplers_filtering[ 442 material_indices[slot].specular_transmission_sampler 445 let sampler_ = pbr_bindings::specular_transmission_sampler; 446 @if(STANDARD_MATERIAL_SPECULAR_TRANSMISSION_UV_B) 450 @if(MESHLET_MESH_MATERIAL_PASS) 451 specular_transmission *= textureSampleGrad(texture, sampler_, coords, bias.ddx_uv, bias.ddy_uv).r; 453 specular_transmission *= textureSampleBias(texture, sampler_, coords, bias.mip_bias).r; 455 pbr_input.material.specular_transmission = specular_transmission; 458 var thickness: f32 = pbr_bindings::material_array[material_indices[slot].material].thickness; 460 var thickness: f32 = pbr_bindings::material.thickness; 462@if(VERTEX_UVS && PBR_TRANSMISSION_TEXTURES_SUPPORTED) 463 if ((flags & pbr_types::STANDARD_MATERIAL_FLAGS_THICKNESS_TEXTURE_BIT) != 0u) { 465 let texture = bindless_textures_2d[material_indices[slot].thickness_texture]; 467 let texture = pbr_bindings::thickness_texture; 469 let sampler_ = bindless_samplers_filtering[material_indices[slot].thickness_sampler]; 471 let sampler_ = pbr_bindings::thickness_sampler; 472 @if(STANDARD_MATERIAL_THICKNESS_UV_B) 476 @if(MESHLET_MESH_MATERIAL_PASS) 477 thickness *= textureSampleGrad(texture, sampler_, coords, bias.ddx_uv, bias.ddy_uv).g; 479 thickness *= textureSampleBias(texture, sampler_, coords, bias.mip_bias).g; 483@if(!MESHLET_MESH_MATERIAL_PASS) 485 (transpose(mesh[in.instance_index].world_from_local) * vec4(pbr_input.N, 0.0)).xyz 487 pbr_input.material.thickness = thickness; 490 var diffuse_transmission = 491 pbr_bindings::material_array[material_indices[slot].material].diffuse_transmission; 493 var diffuse_transmission = pbr_bindings::material.diffuse_transmission; 495@if(VERTEX_UVS && PBR_TRANSMISSION_TEXTURES_SUPPORTED) 496 if ((flags & pbr_types::STANDARD_MATERIAL_FLAGS_DIFFUSE_TRANSMISSION_TEXTURE_BIT) != 0u) { 498 let texture = bindless_textures_2d[material_indices[slot].diffuse_transmission_texture]; 500 let texture = pbr_bindings::diffuse_transmission_texture; 502 let sampler_ = bindless_samplers_filtering[material_indices[slot].diffuse_transmission_sampler]; 504 let sampler_ = pbr_bindings::diffuse_transmission_sampler; 505 @if(STANDARD_MATERIAL_DIFFUSE_TRANSMISSION_UV_B) 509 @if(MESHLET_MESH_MATERIAL_PASS) 510 diffuse_transmission *= textureSampleGrad(texture, sampler_, coords, bias.ddx_uv, bias.ddy_uv).a; 512 diffuse_transmission *= textureSampleBias(texture, sampler_, coords, bias.mip_bias).a; 514 pbr_input.material.diffuse_transmission = diffuse_transmission; 516 var diffuse_occlusion: vec3<f32> = vec3(1.0); 517 var specular_occlusion: f32 = 1.0; 519 if ((flags & pbr_types::STANDARD_MATERIAL_FLAGS_OCCLUSION_TEXTURE_BIT) != 0u) { 521 let texture = bindless_textures_2d[material_indices[slot].occlusion_texture]; 523 let texture = pbr_bindings::occlusion_texture; 525 let sampler_ = bindless_samplers_filtering[material_indices[slot].occlusion_sampler]; 527 let sampler_ = pbr_bindings::occlusion_sampler; 528 @if(STANDARD_MATERIAL_OCCLUSION_UV_B) 532 @if(MESHLET_MESH_MATERIAL_PASS) 533 diffuse_occlusion *= textureSampleGrad(texture, sampler_, coords, bias.ddx_uv, bias.ddy_uv).r; 535 diffuse_occlusion *= textureSampleBias(texture, sampler_, coords, bias.mip_bias).r; 537@if(SCREEN_SPACE_AMBIENT_OCCLUSION) { 538 let ssao_tex_pos = vec2<i32>(in.position.xy - view.viewport.xy); 539 let ssao = textureLoad(screen_space_ambient_occlusion_texture, ssao_tex_pos, 0i).r; 540 let ssao_multibounce = ssao_multibounce(ssao, pbr_input.material.base_color.rgb); 541 diffuse_occlusion = min(diffuse_occlusion, ssao_multibounce); 544 let roughness = lighting::perceptualRoughnessToRoughness(pbr_input.material.perceptual_roughness); 545 specular_occlusion = saturate(pow(NdotV + ssao, exp2(-16.0 * roughness - 1.0)) - 1.0 + ssao); 547 pbr_input.diffuse_occlusion = diffuse_occlusion; 548 pbr_input.specular_occlusion = specular_occlusion; 551@if(!LOAD_PREPASS_NORMALS) { 553 pbr_input.N = normalize(pbr_input.world_normal); 554 pbr_input.clearcoat_N = pbr_input.N; 556@if(VERTEX_UVS && VERTEX_TANGENTS) 557 let TBN = pbr_functions::calculate_tbn_mikktspace(pbr_input.world_normal, in.world_tangent); 559@if(VERTEX_UVS && VERTEX_TANGENTS && STANDARD_MATERIAL_NORMAL_MAP) { 562 let texture = bindless_textures_2d[material_indices[slot].normal_map_texture]; 564 let texture = pbr_bindings::normal_map_texture; 566 let sampler_ = bindless_samplers_filtering[material_indices[slot].normal_map_sampler]; 568 let sampler_ = pbr_bindings::normal_map_sampler; 569 @if(STANDARD_MATERIAL_NORMAL_MAP_UV_B) 573 @if(MESHLET_MESH_MATERIAL_PASS) 574 let Nt = textureSampleGrad(texture, sampler_, coords, bias.ddx_uv, bias.ddy_uv).rgb; 576 let Nt = textureSampleBias(texture, sampler_, coords, bias.mip_bias).rgb; 578 pbr_input.N = pbr_functions::apply_normal_mapping( 588@if(VERTEX_UVS && VERTEX_TANGENTS && STANDARD_MATERIAL_CLEARCOAT) { 594@if(STANDARD_MATERIAL_CLEARCOAT_NORMAL_MAP) { 597 let clearcoat_texture = bindless_textures_2d[material_indices[slot].clearcoat_normal_texture]; 599 let clearcoat_texture = pbr_bindings::clearcoat_normal_texture; 601 let clearcoat_sampler = bindless_samplers_filtering[material_indices[slot].clearcoat_normal_sampler]; 603 let clearcoat_sampler = pbr_bindings::clearcoat_normal_sampler; 604 @if(STANDARD_MATERIAL_CLEARCOAT_NORMAL_UV_B) 605 let clearcoat_coords = uv_b; 607 let clearcoat_coords = uv; 608 @if(MESHLET_MESH_MATERIAL_PASS) 609 let clearcoat_Nt = textureSampleGrad(clearcoat_texture, clearcoat_sampler, clearcoat_coords, bias.ddx_uv, bias.ddy_uv).rgb; 611 let clearcoat_Nt = textureSampleBias(clearcoat_texture, clearcoat_sampler, clearcoat_coords, bias.mip_bias).rgb; 613 pbr_input.clearcoat_N = pbr_functions::apply_normal_mapping( 629@if(PBR_ANISOTROPY_TEXTURE_SUPPORTED && VERTEX_TANGENTS && STANDARD_MATERIAL_ANISOTROPY) { 632 var anisotropy_strength = 633 pbr_bindings::material_array[material_indices[slot].material].anisotropy_strength; 635 var anisotropy_strength = pbr_bindings::material.anisotropy_strength; 637 var anisotropy_direction = 638 pbr_bindings::material_array[material_indices[slot].material].anisotropy_rotation; 640 var anisotropy_direction = pbr_bindings::material.anisotropy_rotation; 643 if ((flags & pbr_types::STANDARD_MATERIAL_FLAGS_ANISOTROPY_TEXTURE_BIT) != 0u) { 645 let texture = bindless_textures_2d[material_indices[slot].anisotropy_texture]; 647 let texture = pbr_bindings::anisotropy_texture; 649 let sampler_ = bindless_samplers_filtering[material_indices[slot].anisotropy_sampler]; 651 let sampler_ = pbr_bindings::anisotropy_sampler; 652 @if(STANDARD_MATERIAL_ANISOTROPY_UV_B) 656 @if(MESHLET_MESH_MATERIAL_PASS) 657 let anisotropy_texel = textureSampleGrad(texture, sampler_, coords, bias.ddx_uv, bias.ddy_uv).rgb; 659 let anisotropy_texel = textureSampleBias(texture, sampler_, coords, bias.mip_bias).rgb; 661 let anisotropy_direction_from_texture = normalize(anisotropy_texel.rg * 2.0 - 1.0); 663 anisotropy_direction = 664 mat2x2(anisotropy_direction.xy, anisotropy_direction.yx * vec2(-1.0, 1.0)) * 665 anisotropy_direction_from_texture; 666 anisotropy_strength *= anisotropy_texel.b; 669 pbr_input.anisotropy_strength = anisotropy_strength; 671 let anisotropy_T = normalize(TBN * vec3(anisotropy_direction, 0.0)); 672 let anisotropy_B = normalize(cross(pbr_input.world_normal, anisotropy_T)); 673 pbr_input.anisotropy_T = anisotropy_T; 674 pbr_input.anisotropy_B = anisotropy_B; 684 let lightmap_exposure = 685 pbr_bindings::material_array[material_indices[slot].material].lightmap_exposure; 687 let lightmap_exposure = pbr_bindings::material.lightmap_exposure; 689 pbr_input.lightmap_light = lightmap(in.uv_b, lightmap_exposure, in.instance_index);