# , SPV_EXT_descriptor_indexing  GLSL.std.450  mainFj  rend3-pbr/shaders/src/opaque.frag rend3-pbr/shaders/src/lighting/../math.glslrend3-pbr/shaders/src/lighting/../structures.glsl rend3-pbr/shaders/src/lighting/brdf.glsl rend3-pbr/shaders/src/lighting/pixel.glsl rend3-pbr/shaders/src/lighting/surface.glslrend3-pbr/shaders/src/lighting/texture_access.glsl rend3-pbr/shaders/src/structures.glsl// OpModuleProcessed entry-point main // OpModuleProcessed client vulkan100 // OpModuleProcessed target-env vulkan1.0 // OpModuleProcessed entry-point main #line 1 #version 440 #ifdef GPU_MODE #extension GL_EXT_nonuniform_qualifier : require #endif #include "structures.glsl" layout(location = 0) in vec4 i_view_position; layout(location = 1) in vec3 i_normal; layout(location = 2) in vec3 i_tangent; layout(location = 3) in vec2 i_coords0; layout(location = 4) in vec2 i_coords1; layout(location = 5) in vec4 i_color; layout(location = 6) flat in uint i_material; layout(location = 0) out vec4 o_color; layout(set = 0, binding = 0) uniform sampler primary_sampler; layout(set = 0, binding = 1) uniform sampler nearest_sampler; layout(set = 0, binding = 2) uniform samplerShadow shadow_sampler; layout(set = 2, binding = 0) restrict readonly buffer DirectionalLightBuffer { DirectionalLightBufferHeader directional_light_header; DirectionalLight directional_lights[]; }; layout(set = 2, binding = 1) uniform texture2DArray shadow; layout(set = 3, binding = 0) uniform UniformBuffer { UniformData uniforms; }; #ifdef GPU_MODE layout(set = 4, binding = 0, std430) restrict readonly buffer MaterialBuffer { GPUMaterialData materials[]; }; layout(set = 5, binding = 0) uniform texture2D textures[]; #endif #ifdef CPU_MODE layout(set = 4, binding = 0) uniform texture2D albedo_tex; layout(set = 4, binding = 1) uniform texture2D normal_tex; layout(set = 4, binding = 2) uniform texture2D roughness_tex; layout(set = 4, binding = 3) uniform texture2D metallic_tex; layout(set = 4, binding = 4) uniform texture2D reflectance_tex; layout(set = 4, binding = 5) uniform texture2D clear_coat_tex; layout(set = 4, binding = 6) uniform texture2D clear_coat_roughness_tex; layout(set = 4, binding = 7) uniform texture2D emissive_tex; layout(set = 4, binding = 8) uniform texture2D anisotropy_tex; layout(set = 4, binding = 9) uniform texture2D ambient_occlusion_tex; layout(set = 4, binding = 10) uniform TextureData { CPUMaterialData material; }; #endif #include "lighting/surface.glsl" void main() { #ifdef GPU_MODE GPUMaterialData material = materials[i_material]; #endif PixelData pixel = get_per_pixel_data(material); if (MATERIAL_FLAG(FLAGS_UNLIT)) { o_color = pixel.albedo; // o_normal = vec4(i_normal, 0.0); } else { vec3 v = -normalize(i_view_position.xyz); vec3 color = vec3(pixel.emissive); for (uint i = 0; i < directional_light_header.total_lights; ++i) { DirectionalLight light = directional_lights[i]; vec3 shadow_ndc = (directional_lights[i].view_proj * uniforms.inv_view * i_view_position).xyz; vec2 shadow_flipped = (shadow_ndc.xy * 0.5) + 0.5; vec4 shadow_shadow_coords = vec4(shadow_flipped.x, 1 - shadow_flipped.y, float(i), shadow_ndc.z); float shadow_value; if (shadow_shadow_coords.x < 0 || shadow_shadow_coords.x > 1 || shadow_shadow_coords.y < 0 || shadow_shadow_coords.y > 1 || shadow_ndc.z < -1 || shadow_ndc.z > 1) { shadow_value = 1.0; } else { shadow_value = textureGrad(sampler2DArrayShadow(shadow, shadow_sampler), shadow_shadow_coords, vec2(0), vec2(0)); } color += surface_shading(directional_lights[i], pixel, v, shadow_value * pixel.ambient_occlusion); } o_color = max(vec4(color, pixel.albedo.a), uniforms.ambient * pixel.albedo); // o_normal = vec4(pixel.normal, 0.0); } }  #ifndef SHADER_MATH_GLSL #define SHADER_MATH_GLSL #define PI 3.14159265359 #define HALF_PI 1.570796327 float saturate(float x) { return clamp(x, 0.0, 1.0); } vec4 srgb_to_linear(vec4 srgb) { vec3 color_srgb = srgb.rgb; vec3 selector = ceil(color_srgb - 0.04045); // 0 if under value, 1 if over vec3 under = color_srgb / 12.92; vec3 over = pow((color_srgb + 0.055) / 1.055, vec3(2.4)); vec3 result = mix(under, over, selector); return vec4(result, srgb.a); } vec4 linear_to_srgb(vec4 linear) { vec3 color_linear = linear.rgb; vec3 selector = ceil(color_linear - 0.0031308); // 0 if under value, 1 if over vec3 under = 12.92 * color_linear; vec3 over = 1.055 * pow(color_linear, vec3(0.41666)) - 0.055; vec3 result = mix(under, over, selector); return vec4(result, linear.a); } #endif#ifndef SHADER_STRUCTURES_GLSL #define SHADER_STRUCTURES_GLSL struct Plane { vec4 inner; }; struct Frustum { Plane left; Plane right; Plane top; Plane bottom; // No far plane Plane near; }; struct ObjectInputData { uint start_idx; uint count; int vertex_offset; uint material_idx; mat4 transform; // xyz position; w radius vec4 bounding_sphere; }; /// If you change this struct, change the object output size in culling.rs struct ObjectOutputData { mat4 model_view; mat4 model_view_proj; mat3 inv_trans_model_view; uint material_idx; }; struct IndirectCall { uint vertex_count; uint instance_count; uint base_index; int vertex_offset; uint base_instance; }; #define FLAGS_ALBEDO_ACTIVE 0x0001 #define FLAGS_ALBEDO_BLEND 0x0002 #define FLAGS_ALBEDO_VERTEX_SRGB 0x0004 #define FLAGS_BICOMPONENT_NORMAL 0x0008 #define FLAGS_SWIZZLED_NORMAL 0x0010 #define FLAGS_AOMR_COMBINED 0x0020 #define FLAGS_AOMR_SWIZZLED_SPLIT 0x0040 #define FLAGS_AOMR_SPLIT 0x0080 #define FLAGS_AOMR_BW_SPLIT 0x0100 #define FLAGS_CC_GLTF_COMBINED 0x0200 #define FLAGS_CC_GLTF_SPLIT 0x0400 #define FLAGS_CC_BW_SPLIT 0x0800 #define FLAGS_UNLIT 0x1000 #define FLAGS_NEAREST 0x2000 #define MATERIAL_FLAG(name) bool(material.material_flags & name) struct GPUMaterialData { uint albedo_tex; uint normal_tex; uint roughness_tex; uint metallic_tex; // -- 16 -- uint reflectance_tex; uint clear_coat_tex; uint clear_coat_roughness_tex; uint emissive_tex; // -- 16 -- uint anisotropy_tex; uint ambient_occlusion_tex; uint _padding0; uint _padding1; // -- 16 -- mat3 uv_transform0; // -- 16 -- mat3 uv_transform1; // -- 16 -- vec4 albedo; // -- 16 -- vec3 emissive; float roughness; // -- 16 -- float metallic; float reflectance; float clear_coat; float clear_coat_roughness; // -- 16 -- float anisotropy; float ambient_occlusion; float alpha_cutout; uint material_flags; }; struct CPUMaterialData { mat3 uv_transform0; // -- 16 -- mat3 uv_transform1; // -- 16 -- vec4 albedo; // -- 16 -- vec3 emissive; float roughness; // -- 16 -- float metallic; float reflectance; float clear_coat; float clear_coat_roughness; // -- 16 -- float anisotropy; float ambient_occlusion; float alpha_cutout; uint material_flags; // -- 16 -- uint texture_enable; }; struct UniformData { mat4 view; mat4 view_proj; mat4 inv_view; mat4 inv_origin_view_proj; Frustum frustum; vec4 ambient; }; struct DirectionalLightBufferHeader { uint total_lights; }; struct DirectionalLight { mat4 view_proj; vec3 color; vec3 direction; }; #endif #ifndef SHADER_LIGHTING_BRDF_GLSL #define SHADER_LIGHTING_BRDF_GLSL #include "../math.glsl" float D_GGX(float NoH, float a) { float a2 = a * a; float f = (NoH * a2 - NoH) * NoH + 1.0; return a2 / (PI * f * f); } vec3 F_Schlick(float u, vec3 f0, float f90) { return f0 + (f90 - f0) * pow(1.0 - u, 5.0); } float F_Schlick(float u, float f0, float f90) { return f0 + (f90 - f0) * pow(1.0 - u, 5.0); } float Fd_Burley(float NoV, float NoL, float LoH, float roughness) { float f90 = 0.5 + 2.0 * roughness * LoH * LoH; float lightScatter = F_Schlick(NoL, 1.0, f90); float viewScatter = F_Schlick(NoV, 1.0, f90); return lightScatter * viewScatter * (1.0 / PI); } float Fd_Lambert() { return 1.0 / PI; } float V_SmithGGXCorrelated(float NoV, float NoL, float a) { float a2 = a * a; float GGXL = NoV * sqrt((-NoL * a2 + NoL) * NoL + a2); float GGXV = NoL * sqrt((-NoV * a2 + NoV) * NoV + a2); return 0.5 / (GGXV + GGXL); } #endif  #ifndef SHADER_LIGHTING_PIXEL_GLSL #define SHADER_LIGHTING_PIXEL_GLSL #include "texture_access.glsl" #include "../structures.glsl" #include "../math.glsl" vec3 compute_diffuse_color(const vec4 baseColor, float metallic) { return baseColor.rgb * (1.0 - metallic); } vec3 compute_f0(const vec4 baseColor, float metallic, float reflectance) { return baseColor.rgb * metallic + (reflectance * (1.0 - metallic)); } float compute_dielectric_f0(float reflectance) { return 0.16 * reflectance * reflectance; } float perceptual_roughness_to_roughness(float perceptual_roughness) { return perceptual_roughness * perceptual_roughness; } struct PixelData { vec4 albedo; vec3 diffuse_color; float roughness; vec3 normal; float metallic; vec3 f0; float perceptual_roughness; vec3 emissive; float reflectance; float clear_coat; float clear_coat_roughness; float clear_coat_perceptual_roughness; float anisotropy; float ambient_occlusion; uint material_flags; }; PixelData get_per_pixel_data_sampled(MATERIAL_TYPE material, sampler s) { PixelData pixel; vec2 coords = vec2(material.uv_transform0 * vec3(i_coords0, 1.0)); vec2 uvdx = dFdx(coords); vec2 uvdy = dFdy(coords); if (MATERIAL_FLAG(FLAGS_ALBEDO_ACTIVE)) { if (HAS_ALBEDO_TEXTURE) { pixel.albedo = textureGrad(sampler2D(ALBEDO_TEXTURE, s), coords, uvdx, uvdy); } else { pixel.albedo = vec4(1.0); } if (MATERIAL_FLAG(FLAGS_ALBEDO_BLEND)) { vec4 vert_color = i_color; if (MATERIAL_FLAG(FLAGS_ALBEDO_VERTEX_SRGB)) { vert_color = srgb_to_linear(vert_color); } pixel.albedo *= vert_color; } } else { pixel.albedo = vec4(0.0, 0.0, 0.0, 1.0); } pixel.albedo *= material.albedo; if (MATERIAL_FLAG(FLAGS_UNLIT)) { pixel.normal = normalize(i_normal); } else { if (HAS_NORMAL_TEXTURE) { vec4 texture_read = textureGrad(sampler2D(NORMAL_TEXTURE, s), coords, uvdx, uvdy); vec3 normal; if (MATERIAL_FLAG(FLAGS_BICOMPONENT_NORMAL)) { vec2 bicomp; if (MATERIAL_FLAG(FLAGS_SWIZZLED_NORMAL)) { bicomp = texture_read.ag; } else { bicomp = texture_read.rg; } bicomp = bicomp * 2.0 - 1.0; normal = vec3(bicomp, sqrt(1 - (bicomp.r * bicomp.r) - (bicomp.g * bicomp.g))); } else { normal = normalize(texture_read.rgb * 2.0 - 1.0); } vec3 in_normal = normalize(i_normal); vec3 in_tangent = normalize(i_tangent); vec3 bitangent = cross(in_normal, in_tangent); mat3 tbn = mat3(i_tangent, bitangent, i_normal); pixel.normal = tbn * normal; } else { pixel.normal = i_normal; } pixel.normal = normalize(pixel.normal); // Extract AO, metallic, and roughness data from various packed formats // In roughness texture: // Red: AO // Green: Metallic // Blue: Roughness if (MATERIAL_FLAG(FLAGS_AOMR_COMBINED)) { if (HAS_ROUGHNESS_TEXTURE) { vec3 aomr = textureGrad(sampler2D(ROUGHNESS_TEXTURE, s), coords, uvdx, uvdy).rgb; pixel.ambient_occlusion = material.ambient_occlusion * aomr.r; pixel.metallic = material.metallic * aomr.g; pixel.perceptual_roughness = material.roughness * aomr.b; } else { pixel.ambient_occlusion = material.ambient_occlusion; pixel.metallic = material.metallic; pixel.perceptual_roughness = material.roughness; } } // In ao texture: // Red: AO // In roughness texture: // Green: Metallic // Blue: Roughness else if (MATERIAL_FLAG(FLAGS_AOMR_SWIZZLED_SPLIT) || MATERIAL_FLAG(FLAGS_AOMR_SPLIT)) { if (HAS_ROUGHNESS_TEXTURE) { vec4 texture_read = textureGrad(sampler2D(ROUGHNESS_TEXTURE, s), coords, uvdx, uvdy); vec2 mr = MATERIAL_FLAG(FLAGS_AOMR_SWIZZLED_SPLIT) ? texture_read.gb : texture_read.rg; pixel.metallic = material.metallic * mr[0]; pixel.perceptual_roughness = material.roughness * mr[1]; } else { pixel.metallic = material.metallic; pixel.perceptual_roughness = material.ambient_occlusion; } if (HAS_AMBIENT_OCCLUSION_TEXTURE) { pixel.ambient_occlusion = material.ambient_occlusion * textureGrad(sampler2D(AMBIENT_OCCLUSION_TEXTURE, s), coords, uvdx, uvdy).r; } else { pixel.ambient_occlusion = material.ambient_occlusion; } } // In ao texture: // Red: AO // In metallic texture: // Red: Metallic // In roughness texture: // Red: Roughness else if (MATERIAL_FLAG(FLAGS_AOMR_BW_SPLIT)) { if (HAS_ROUGHNESS_TEXTURE) { pixel.perceptual_roughness = material.roughness * textureGrad(sampler2D(ROUGHNESS_TEXTURE, s), coords, uvdx, uvdy).r; } else { pixel.perceptual_roughness = material.roughness; } if (HAS_METALLIC_TEXTURE) { pixel.metallic = material.metallic * textureGrad(sampler2D(METALLIC_TEXTURE, s), coords, uvdx, uvdy).r; } else { pixel.metallic = material.metallic; } if (HAS_AMBIENT_OCCLUSION_TEXTURE) { pixel.ambient_occlusion = material.ambient_occlusion * textureGrad(sampler2D(AMBIENT_OCCLUSION_TEXTURE, s), coords, uvdx, uvdy).r; } else { pixel.ambient_occlusion = material.ambient_occlusion; } } if (HAS_REFLECTANCE_TEXTURE) { pixel.reflectance = material.reflectance * textureGrad(sampler2D(REFLECTANCE_TEXTURE, s), coords, uvdx, uvdy).r; } else { pixel.reflectance = material.reflectance; } pixel.diffuse_color = compute_diffuse_color(pixel.albedo, pixel.metallic); // Assumes an interface from air to an IOR of 1.5 for dielectrics float reflectance = compute_dielectric_f0(pixel.reflectance); pixel.f0 = compute_f0(pixel.albedo, pixel.metallic, reflectance); if (MATERIAL_FLAG(FLAGS_CC_GLTF_COMBINED)) { if (HAS_CLEAR_COAT_TEXTURE) { vec2 cc = textureGrad(sampler2D(CLEAR_COAT_TEXTURE, s), coords, uvdx, uvdy).rg; pixel.clear_coat = material.clear_coat * cc.r; pixel.clear_coat_perceptual_roughness = material.clear_coat_roughness * cc.g; } else { pixel.clear_coat = material.clear_coat; pixel.clear_coat_perceptual_roughness = material.clear_coat_roughness; } } else if (MATERIAL_FLAG(FLAGS_CC_GLTF_SPLIT)) { if (HAS_CLEAR_COAT_TEXTURE) { pixel.clear_coat = material.clear_coat * textureGrad(sampler2D(CLEAR_COAT_TEXTURE, s), coords, uvdx, uvdy).r; } else { pixel.clear_coat = material.clear_coat; } if (HAS_CLEAR_COAT_ROUGHNESS_TEXTURE) { pixel.clear_coat_perceptual_roughness = material.clear_coat_roughness * textureGrad(sampler2D(CLEAR_COAT_ROUGHNESS_TEXTURE, s), coords, uvdx, uvdy).g; } else { pixel.clear_coat_perceptual_roughness = material.clear_coat_roughness; } } else if (MATERIAL_FLAG(FLAGS_CC_BW_SPLIT)) { if (HAS_CLEAR_COAT_TEXTURE) { pixel.clear_coat = material.clear_coat * textureGrad(sampler2D(CLEAR_COAT_TEXTURE, s), coords, uvdx, uvdy).r; } else { pixel.clear_coat = material.clear_coat; } if (HAS_CLEAR_COAT_ROUGHNESS_TEXTURE) { pixel.clear_coat_perceptual_roughness = material.clear_coat_roughness * textureGrad(sampler2D(CLEAR_COAT_ROUGHNESS_TEXTURE, s), coords, uvdx, uvdy).r; } else { pixel.clear_coat_perceptual_roughness = material.clear_coat_roughness; } } if (pixel.clear_coat != 0.0) { float base_perceptual_roughness = max(pixel.perceptual_roughness, pixel.clear_coat_perceptual_roughness); pixel.perceptual_roughness = mix(pixel.perceptual_roughness, base_perceptual_roughness, pixel.clear_coat); pixel.clear_coat_roughness = perceptual_roughness_to_roughness(pixel.clear_coat_perceptual_roughness); } pixel.roughness = perceptual_roughness_to_roughness(pixel.perceptual_roughness); if (HAS_EMISSIVE_TEXTURE) { pixel.emissive = material.emissive * textureGrad(sampler2D(EMISSIVE_TEXTURE, s), coords, uvdx, uvdy).rgb; } else { pixel.emissive = material.emissive; } // TODO: Aniso info if (HAS_ANISOTROPY_TEXTURE) { pixel.anisotropy = material.anisotropy * textureGrad(sampler2D(ANISOTROPY_TEXTURE, s), coords, uvdx, uvdy).r; } else { pixel.anisotropy = material.anisotropy; } } pixel.material_flags = material.material_flags; return pixel; } #ifdef GPU_MODE PixelData get_per_pixel_data(MATERIAL_TYPE material) { if (MATERIAL_FLAG(FLAGS_NEAREST)) { return get_per_pixel_data_sampled(material, nearest_sampler); } else { return get_per_pixel_data_sampled(material, primary_sampler); } } #endif #ifdef CPU_MODE // In CPU mode the primary sampler gets switched out for what we need, so we don't switch in the shader. // This is because OpenGL can't deal with any texture being used with multiple different samplers. PixelData get_per_pixel_data(MATERIAL_TYPE material) { return get_per_pixel_data_sampled(material, primary_sampler); } #endif #endif 0// These are derived by the wonderful https://google.github.io/filament/Filament.md.html #ifndef SHADER_LIGHTING_SURFACE_GLSL #define SHADER_LIGHTING_SURFACE_GLSL #include "brdf.glsl" #include "pixel.glsl" vec3 surface_shading(DirectionalLight light, PixelData pixel, vec3 v, float occlusion) { vec3 l = normalize(mat3(uniforms.view) * -light.direction); vec3 n = pixel.normal; vec3 h = normalize(v + l); float NoV = abs(dot(n, v)) + 1e-5; float NoL = saturate(dot(n, l)); float NoH = saturate(dot(n, h)); float LoH = saturate(dot(l, h)); float f90 = saturate(dot(pixel.f0, vec3(50.0 * 0.33))); float D = D_GGX(NoH, pixel.roughness); vec3 F = F_Schlick(LoH, pixel.f0, f90); float V = V_SmithGGXCorrelated(NoV, NoL, pixel.roughness); // TODO: figure out how they generate their lut float energy_compensation = 1.0; // specular vec3 Fr = (D * V) * F; // diffuse vec3 Fd = pixel.diffuse_color * Fd_Lambert(); vec3 color = Fd + Fr * energy_compensation; float light_attenuation = 1.0; return (color * light.color) * (light_attenuation * NoL * occlusion); } #endif #ifndef SHADER_TEXTURE_ACCESS_GLSL #define SHADER_TEXTURE_ACCESS_GLSL bool has_texture(uint idx) { return idx != 0; } #ifdef GPU_MODE #define MATERIAL_TYPE GPUMaterialData #define HAS_ALBEDO_TEXTURE has_texture(material.albedo_tex) #define HAS_NORMAL_TEXTURE has_texture(material.normal_tex) #define HAS_ROUGHNESS_TEXTURE has_texture(material.roughness_tex) #define HAS_METALLIC_TEXTURE has_texture(material.metallic_tex) #define HAS_REFLECTANCE_TEXTURE has_texture(material.reflectance_tex) #define HAS_CLEAR_COAT_TEXTURE has_texture(material.clear_coat_tex) #define HAS_CLEAR_COAT_ROUGHNESS_TEXTURE has_texture(material.clear_coat_roughness_tex) #define HAS_EMISSIVE_TEXTURE has_texture(material.emissive_tex) #define HAS_ANISOTROPY_TEXTURE has_texture(material.anisotropy_tex) #define HAS_AMBIENT_OCCLUSION_TEXTURE has_texture(material.ambient_occlusion_tex) #define ALBEDO_TEXTURE textures[nonuniformEXT(material.albedo_tex - 1)] #define NORMAL_TEXTURE textures[nonuniformEXT(material.normal_tex - 1)] #define ROUGHNESS_TEXTURE textures[nonuniformEXT(material.roughness_tex - 1)] #define METALLIC_TEXTURE textures[nonuniformEXT(material.metallic_tex - 1)] #define REFLECTANCE_TEXTURE textures[nonuniformEXT(material.reflectance_tex - 1)] #define CLEAR_COAT_TEXTURE textures[nonuniformEXT(material.clear_coat_tex - 1)] #define CLEAR_COAT_ROUGHNESS_TEXTURE textures[nonuniformEXT(material.clear_coat_roughness_tex - 1)] #define EMISSIVE_TEXTURE textures[nonuniformEXT(material.emissive_tex - 1)] #define ANISOTROPY_TEXTURE textures[nonuniformEXT(material.anisotropy_tex - 1)] #define AMBIENT_OCCLUSION_TEXTURE textures[nonuniformEXT(material.ambient_occlusion_tex - 1)] #endif #ifdef CPU_MODE #define MATERIAL_TYPE CPUMaterialData #define HAS_ALBEDO_TEXTURE bool((material.texture_enable >> 0) & 0x1) #define HAS_NORMAL_TEXTURE bool((material.texture_enable >> 1) & 0x1) #define HAS_ROUGHNESS_TEXTURE bool((material.texture_enable >> 2) & 0x1) #define HAS_METALLIC_TEXTURE bool((material.texture_enable >> 3) & 0x1) #define HAS_REFLECTANCE_TEXTURE bool((material.texture_enable >> 4) & 0x1) #define HAS_CLEAR_COAT_TEXTURE bool((material.texture_enable >> 5) & 0x1) #define HAS_CLEAR_COAT_ROUGHNESS_TEXTURE bool((material.texture_enable >> 6) & 0x1) #define HAS_EMISSIVE_TEXTURE bool((material.texture_enable >> 7) & 0x1) #define HAS_ANISOTROPY_TEXTURE bool((material.texture_enable >> 8) & 0x1) #define HAS_AMBIENT_OCCLUSION_TEXTURE bool((material.texture_enable >> 9) & 0x1) #define ALBEDO_TEXTURE albedo_tex #define NORMAL_TEXTURE normal_tex #define ROUGHNESS_TEXTURE roughness_tex #define METALLIC_TEXTURE metallic_tex #define REFLECTANCE_TEXTURE reflectance_tex #define CLEAR_COAT_TEXTURE clear_coat_tex #define CLEAR_COAT_ROUGHNESS_TEXTURE clear_coat_roughness_tex #define EMISSIVE_TEXTURE emissive_tex #define ANISOTROPY_TEXTURE anisotropy_tex #define AMBIENT_OCCLUSION_TEXTURE ambient_occlusion_tex #endif #endif // SHADER_TEXTURE_ACCESS_GLSL#ifndef SHADER_STRUCTURES_GLSL #define SHADER_STRUCTURES_GLSL struct Plane { vec4 inner; }; struct Frustum { Plane left; Plane right; Plane top; Plane bottom; // No far plane Plane near; }; struct ObjectInputData { uint start_idx; uint count; int vertex_offset; uint material_idx; mat4 transform; // xyz position; w radius vec4 bounding_sphere; }; /// If you change this struct, change the object output size in culling.rs struct ObjectOutputData { mat4 model_view; mat4 model_view_proj; mat3 inv_trans_model_view; uint material_idx; }; struct IndirectCall { uint vertex_count; uint instance_count; uint base_index; int vertex_offset; uint base_instance; }; #define FLAGS_ALBEDO_ACTIVE 0x0001 #define FLAGS_ALBEDO_BLEND 0x0002 #define FLAGS_ALBEDO_VERTEX_SRGB 0x0004 #define FLAGS_BICOMPONENT_NORMAL 0x0008 #define FLAGS_SWIZZLED_NORMAL 0x0010 #define FLAGS_AOMR_COMBINED 0x0020 #define FLAGS_AOMR_SWIZZLED_SPLIT 0x0040 #define FLAGS_AOMR_SPLIT 0x0080 #define FLAGS_AOMR_BW_SPLIT 0x0100 #define FLAGS_CC_GLTF_COMBINED 0x0200 #define FLAGS_CC_GLTF_SPLIT 0x0400 #define FLAGS_CC_BW_SPLIT 0x0800 #define FLAGS_UNLIT 0x1000 #define FLAGS_NEAREST 0x2000 #define MATERIAL_FLAG(name) bool(material.material_flags & name) struct GPUMaterialData { uint albedo_tex; uint normal_tex; uint roughness_tex; uint metallic_tex; // -- 16 -- uint reflectance_tex; uint clear_coat_tex; uint clear_coat_roughness_tex; uint emissive_tex; // -- 16 -- uint anisotropy_tex; uint ambient_occlusion_tex; uint _padding0; uint _padding1; // -- 16 -- mat3 uv_transform0; // -- 16 -- mat3 uv_transform1; // -- 16 -- vec4 albedo; // -- 16 -- vec3 emissive; float roughness; // -- 16 -- float metallic; float reflectance; float clear_coat; float clear_coat_roughness; // -- 16 -- float anisotropy; float ambient_occlusion; float alpha_cutout; uint material_flags; }; struct CPUMaterialData { mat3 uv_transform0; // -- 16 -- mat3 uv_transform1; // -- 16 -- vec4 albedo; // -- 16 -- vec3 emissive; float roughness; // -- 16 -- float metallic; float reflectance; float clear_coat; float clear_coat_roughness; // -- 16 -- float anisotropy; float ambient_occlusion; float alpha_cutout; uint material_flags; // -- 16 -- uint texture_enable; }; struct UniformData { mat4 view; mat4 view_proj; mat4 inv_view; mat4 inv_origin_view_proj; Frustum frustum; vec4 ambient; }; struct DirectionalLightBufferHeader { uint total_lights; }; struct DirectionalLight { mat4 view_proj; vec3 color; vec3 direction; }; #endif GL_EXT_nonuniform_qualifier GL_GOOGLE_cpp_style_line_directiveGL_GOOGLE_include_directive maini_coords0*texturesFi_colorji_normali_tangentnearest_samplerprimary_sampler$Plane$inner%Frustum%left%right%top%bottom%near&UniformData&view&view_proj&inv_view &inv_origin_view_proj&frustum&ambient'UniformBuffer'uniforms)GPUMaterialDataalbedo_texnormal_texroughness_texmetallic_texreflectance_texclear_coat_tex clear_coat_roughness_texemissive_texanisotropy_tex  ambient_occlusion_tex _padding0 _padding1 uv_transform0 uv_transform1albedoemissiveroughnessmetallicreflectanceclear_coat clear_coat_roughnessanisotropyambient_occlusionalpha_cutoutmaterial_flagsMaterialBuffermaterialsi_materialo_colori_view_position DirectionalLightBufferHeadertotal_lightsDirectionalLightview_projcolordirectionDirectionalLightBuffer directional_light_headerdirectional_lightsZshadow\shadow_sampleri_coords1GG*"G*!GFGjGG"G!G"G!H$#H%#H%#H%# H%#0H%#@H&H&#H&H&H&#@H&H&H&#H&H&H&#H&H&#H&#PH'#G'G)"G)!H#H#H#H# H#H#H#H#H# H #$H #(H #,H H #0H H H #`H H#H#H#H#H#H#H#H#H#H#H#GHHH#GG"G!GGGGH#HH#HH#@H#PG`HHH#HHH#GG"G!GZ"GZ!G\"G\!GGGGG'G(G)GGGGGGGGGGGGG4G5G6GNGOGPGkGlGmGGGGGGGGGGGGGGGGOGPGQGG GH GI G G G G G G G" G# G$ GT GU GV Gt Gu Gv G G G G G G G G G G G G G G G! G9 G: G; GY GZ G[ Gs Gt Gu G G G  !  0 2HK LKW+c+d?+m%=+xGa=+~@,~~~+I@+@+>+?+0+ #>  ;+0+ '(' )(;)* /'3',;dddd+0? E;EF+0J,Xcccd+0c i;ij+o+0+0+@;i+0 ++0@+0%+0~++0 +0;+0y+0 ;L;L$%$$$$$&WWWW%'& (';() *W+F'7+]A,^]]]000000000000HH0 ; 0;  ;;E0W ; 0 +J X YX;YZ;L\^X,acc ;4,mmm,xxx,ddd,dd,+=,+or?,.+'+0+0+0+0+0 H+0  +0  +0 +0+0+0+0+0"+0%6  8=0A=A=0A=0A?=0A=0AJ=0A=0A=0A=0A=0A  =H  A  = A=A=A=A=A=A =! A#"=$#A&%=0'&0'2-=/ Q0 / Q1 / P2 0 1 d3 2 Q4 3 Q5 3 P6 4 5 .8 6 /: 6 10= '2> = j > ? h h ?j ? 2 2S  C Q Q 5S C 30F S0G F A/H *G ='I H =KJ V3K I J XO K 6 8 : S S `O C ;Q 70V '?2W V g W X g X 8=Y F90\ 'J2] \ a ] ^ a ^  O Y Y            . Q Y Q Q Q P :a a ^Y X ^ <e `^g g b`S e a j j abg Xh Ao aC0s 'c2t s  t u y y 2 G  }  _= j } H0 S0 A/ * =' =K V3 X 6 8 : J0 '2    UO     E   L0 '2    OO   MO   c Q c SQ   d Q     P   d W= j  E X=   E Y  D [PH ] d  e a  Eei0 '2    z0 '2  2       0 '%2    2       e e 0h '~2i h  i j j 2   n   n 0s S0t s A/u *t ='v u =Kw V3x v w X| x 6 8 : Q} | ~ }   ~ n  2      0 S0 A/ * =' =K V3 X 6 8 : Q       2      0 S0 A/ * =' =K V3 X 6 8 : Q  $    $   e  e  |e    2 {J   C C J  |0! S0" ! A/# *" ='$ # =K% V3& $ % X* & 6 8 : }5  / 2 2 O4 * * 5 / O1 * * 5 5 f1 / 4 2 ~Q: f; : Q@ fA @ J J A 5 $C {; 5 C 2 d  N ` ` d N 0S S0T S A/U *T ='V U =KW V3X V W X\ X 6 8 : Q] \ ^ $] d d ^ N $`   d  d  y{d |   2 j    r  k0 S0 A/ * =' =K V3 X 6 8 : lQ  $ mQ   nQ      $   x        wx y 2      0 S0 A/ * =' =K V3 X 6 8 : Q        O o o " dw# " ' ) '  . w2 ) " P3 2 2 2 4 . 3 0 ' 2     0 ';2     J J 0M 'y2N M  N O O 2D i D S e e i S 0X S0Y X A/Z *Y ='[ Z =K\ V3] [ \ Xa ] 6 8 : Qb a c b i i c S e 2H  H m    m 0r S0s r A/t *s ='u t =Kv V3w u v X{ w 6 8 : Q| { } !|   } m !   J  J    2< / <  + + /  0 S0  A/ * ='! =K" V3# ! " X' # 6 8 : Q( ' ) ( / / )  + 2@ I @ 3 E E I 3 08 S09 8 A/: *9 ='; : =K< V3= ; < XA = 6 8 : QB A C !B I I C 3 !E   I  I    28  8     0 S0 A/ * =' =K V3 X 6 8 : Q   Q  !    !         2 c     (  .    R 2V  V    0 S0 A/ * =' =K V3 X 6 8 : O     7   u D=v j w Ev   v4u # ou R Ww u ;4u 4 04u 7 u  -=QQPd QQP./10'2?22530S0A/*='=KV3X;70'?2  8=F90'J2 O      .QQQQP:<     XAC0'c2z2G{#xx_=yj{#H0&S0'&A/(*'=')(=K*V3+)*X/+J02'232\34UUUOW//XWZX [ EZ\4L07'287?89<<OO>//?9MO;//??;9><QACASQFCIFFJdIQLCOLLPJO Q PPTFLQ\\T?[UW=]j ^ E]X=_ ` E_Y c D^`[PHs_c]]vs{{v\yxa ~ Ei0'2az0'220'%22`  0'~2__2*&&*0S0A/*='=KV3X"Q#"$#**$&2D.@@D.03S043A/5*4='65=K7V3867X<8Q=<>=DD>.@2^HZZ^H0MS0NMA/O*N='PO=KQV3RPQXVRQWVX$W^^XH$Z__ ^ ^ ^`2{|0S0A/*='=KV3X}OO~QQ$2  0S0A/*='=KV3XQ$  $`` _ _ _a2jrk0S0A/*='=KV3XlQ$mQnQ$aa```2{eww{e0jS0kjA/l*k='ml=KnV3omnXsoQtsut{{uew Od P0' 2,0';2+0'y2**2  0S0A/*='=KV3XQ   2)%%)0S0A/*='=KV3X!Q"!#!")) #!%** ))+20S0A/*='=KV3XQ20S0A/*='=KV3XQ!!++**,20S0A/*='=KV3XQQ!!,,++2/cA/0A0 5 ( ; .5AA ,;0  2_I[[_I0NS0ONA/P*O='QP=KRV3SQRXWSOXWWYX__iYI[zD=j  Ezz4__~_m4_c4i_ _zo zv zo zW mz; cz0  z =0'c2A=O  EDy0{A=02GA*o=WA*)=WWHO!IQ$!Q&!'d&p)Q+P,$')+L2/$c20/2012125$d2226/51276978982<'c992=62<82>=@>?@?2C'd@@2D=9C?2EDGEFGF2K+JGG2LD@KF2MLOMNON2R+dOO2SLGRNUSTWWO=X[Z=K]\V^_[]Z c_,+aaUTMUUdTcWRhAjo=A(j=)(A*j?=+* A*y )=Wz y Q{ z O| { { Q} z O~ } } Q z O   PH | ~  +  E     E      F    + cd    + cd   + cd ^  + cd     d     P   d      !           "              #       ! # d ' ) h Ry D0{oUQ~QQQP~A)=  (>>>8