export const FP_SHADER_CHUNK_APPLY_DECALS: "\n#ifndef FP_SHADER_CHUNK_APPLY_DECALS\n    #define FP_SHADER_CHUNK_APPLY_DECALS\n    \n    // process decals\n    for(uint i=0u; i < fp_cluster_metadata.w; i++){\n        uint lookup_index = fp_cluster_metadata.z + i;\n\n        uint light_descriptor = texelFetch(fp_t_light_lookup, address_to_data_texture_coordinates(lookup_index), 0 ).r;\n\n        uint type = (light_descriptor) & 0x3u;\n        uint light_address = light_descriptor >> 2;\n        \n        // decal\n        vec4 light_data_0 = texelFetch(fp_t_light_data, address_to_data_texture_coordinates(light_address), 0);\n        vec4 light_data_1 = texelFetch(fp_t_light_data, address_to_data_texture_coordinates(light_address+1u), 0);\n        vec4 light_data_2 = texelFetch(fp_t_light_data, address_to_data_texture_coordinates(light_address+2u), 0);\n        vec4 light_data_3 = texelFetch(fp_t_light_data, address_to_data_texture_coordinates(light_address+3u), 0);\n        \n        mat4 decal_transform_matrix = mat4(\n              light_data_0,\n              light_data_1,\n              light_data_2,\n              light_data_3\n        );\n        \n        vec4 local_position = decal_transform_matrix*vec4(v_world_position, 1.0);\n        \n        if(max3(abs(local_position.xyz)) < 0.5){\n            \n            // we're inside decal volume\n            vec4 light_data_4 = texelFetch(fp_t_light_data, address_to_data_texture_coordinates(light_address+4u), 0);\n            \n            // compute normal of the decal, we get this by extracting rotation matrix and transforming (0,1,0) vector using that \n            vec3 decal_normal = normalize(vec3(\n                decal_transform_matrix[0][2], decal_transform_matrix[1][2], decal_transform_matrix[2][2]\n            )); \n            \n            // Get geometry normal in world-space\n            vec3 g_normal = normalize( ( transpose(viewMatrix) * vec4( normal, 0.0 ) ).xyz );\n                            \n            float decal_surface_dot = dot(decal_normal, g_normal);\n                            \n            // we fade out decals when the projection angle to the surface gets too steep\n            // 0.7 is cos(45deg) and 0.5 is cos(60deg), dot returns cos of angle between two normals\n            float decal_surface_angle_fade = smoothstep(-0.5,-0.7,decal_surface_dot);\n            \n            if(decal_surface_angle_fade <= 0.0){\n                continue;\n            }\n            \n            vec2 decal_local_uv = (local_position.xy + 0.5);\n            vec2 decal_uv = decal_local_uv*light_data_4.zw + light_data_4.xy;\n                            \n            vec4 decal_color = texture2D(fp_t_decal_atlas,decal_uv, -0.2);\n            \n            vec4 decal_color_tint = texelFetch(fp_t_light_data, address_to_data_texture_coordinates(light_address+5u), 0);\n            \n            decal_color*= decal_color_tint;\n            \n            // compute decal alpha\n            float decal_alpha = decal_color.a * decal_surface_angle_fade;\n            \n            if(decal_alpha < 0.003){\n                continue;\n            }\n            \n            material.diffuseColor = material.diffuseColor*(1.0-decal_alpha) + decal_color.xyz*decal_alpha;\n        } \n                      \n    }\n    \n#endif\n";
//# sourceMappingURL=FP_SHADER_CHUNK_APPLY_DECALS.d.ts.map