#   GLSL.std.450  main8\qv  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_GOOGLE_cpp_style_line_directiveGL_GOOGLE_include_directive maini_coords0"albedo_tex8i_color\i_normaljnormal_texi_tangentroughness_texNambient_occlusion_texmetallic_texreflectance_texclear_coat_tex .clear_coat_roughness_texemissive_texprimary_samplerPlaneinnerFrustumleftrighttopbottomnearUniformDataviewview_projinv_view inv_origin_view_projfrustumambientUniformBufferuniformsDCPUMaterialDataDuv_transform0Duv_transform1DalbedoDemissiveDroughnessDmetallicDreflectanceDclear_coat Dclear_coat_roughnessD anisotropyD ambient_occlusionD alpha_cutoutD material_flagsD texture_enableETextureDataEmaterialGqo_colorvi_view_position DirectionalLightBufferHeadertotal_lightsDirectionalLightview_projcolordirectionDirectionalLightBuffer directional_light_headerdirectional_lightsshadowshadow_sampleri_coords1i_materialGG""G"!G8G\Gj"Gj!GG"G!GN"GN! G"G!G"G!G"G!G."G.!G"G!G"G!H#H#H#H# H#0H#@HH#HHH#@HHH#HHH#HH#H#PH#GG"G!HDHD#HDHDHD#0HDHD#`HD#pHD#|HD#HD#HD#HD#HD #HD #HD #HD #HD #HE#GEGG"GG! GqGvH#HH#HH#@H#PG`HHH#HHH#GG"G!G"G!G"G!GGG !  AB E FEQ+]+^?+g%=+rGa=+x@,yxxx+I@+@+>+?+ #> + ;+  +B+B  ! ;!"% ,-^^^^+B1 7;78+B<,J]]]^+L+BU+Z [;[\+c;!j+Bt+B{+@;[+B ;!++++B@+B+F ;!N+B`;!;!+B;!++B ;!.+B@;!;FQQQQ ; Q+'7+A,DAABBED FE;FG ID iB p;pq;7vBQ ; +  ;;F,]] ; B;f  , ggg, rrr, ^^^, ^^, + =, + or?, . + '  A  +B   +B +B +B +B +B +B 6  ;AIJG=A J=A A J1= A J = A J<= A J = A J = A J = A Jt= A J = Ai J =B Ai J =B -==Q>=Q?=P@>?^A @QBAQCAPDBC.FD/HD1BK LKuLMsM2BP BQPRQ^RS\S3= T"=EUV%VTUXZVDFH^\5^^B ZS-\7Ba 1barbcrc8=d89Bg <hglhili Odd      y  .QdQQQP:ll@ dci<pB @ rrD B ^plus?uuC D rJsAzC CB~ U~D=\  EGB cBH= j=EV%XDFHJB tLB {MOOOE QE  SQ^Q  PUO  EF W=\  EX=  EY  D[PA]F _=\G a  EG iB jB LBk= =EV%XDFHlQ mQ nQ r    Z  zB B d{B" LB#"$#L$%E%|= &=E'V%(&'X,(DFH}7141O3,,74O6,,77H 3164~Q<H = <QBH C BLELL C7 E] =7 EBO FBPOQPcQR_R= UN=EVV%WUVX[WDFHQ\[] \c_cc ]R _dBg `hghiiBl LBmlnmno|o= r=EsV%trsXxtDFHQyxz y| zo |B ZB= =EV%XDFHQ i  B FB= N=EV%XDFHQ    f d  f d ^ f di  c  c [ ] c^     Y Z [ B B= =EV%XDFHQ j   Ozz^Y j j  Y PB jB B= =EV%XDFHQ Q   l  jB i4B B      = =EV%XDFHQ o   B B ! 3!"/"= %.=E&V%'%&X+'DFHQ,+- ,3/33 -" /i4B7 @87h89h9B< B=<>=P>?L?= B=ECV%DBCXHDDFHQIHJ IPLPP J? LBS BTSUTgUVcV= Y.=EZV%[YZX_[DFHQ`_a `gcgg aV chh f 4 gp f 4 gii 3 hm o 3p hjj  ik l m imk ]mnn s (  y . sk  jyn B B= =EV%XDFHO   X  Q f 9       f  =AijG =BkjBlkUmlomntn>>qzotA=wvOxww y ExzyDu  tBt tAi=Bt GAct =QAL=QQwHO  IQQ^pt QPL]^]^^MO==EVZ | ^R| Act =A = A 1=  A=QQOQOQOPA" #" $ E# )z$ * E)-9 z . -/.29 $ i +2]^69 * m +6]^:$* q +:]^>  u +>]^|Q Q m|mm^ | Puuu ^q   !i|ii|  /" .|//|  i#PRP!VX #ZR^[VZ'_[ die_dRu eDBt cUQ zQ u Q u Q u P    A=z  (>qoo8