#  GLSL.std.450mainm rend3-pbr/shaders/src/opaque.vert rend3-pbr/shaders/src/structures.glsl1// OpModuleProcessed entry-point main // OpModuleProcessed client vulkan100 // OpModuleProcessed target-env vulkan1.0 // OpModuleProcessed entry-point main #line 1 #version 440 #extension GL_GOOGLE_include_directive : require #include "structures.glsl" layout(location = 0) in vec3 i_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) in uint i_material; #ifdef GPU_MODE layout(location = 7) in uint i_object_idx; #endif layout(location = 0) out vec4 o_view_position; layout(location = 1) out vec3 o_normal; layout(location = 2) out vec3 o_tangent; layout(location = 3) out vec2 o_coords0; layout(location = 4) out vec2 o_coords1; layout(location = 5) out vec4 o_color; layout(location = 6) flat out uint o_material; layout(set = 1, binding = 0, std430) restrict readonly buffer ObjectOutputDataBuffer { ObjectOutputData object_output[]; }; layout(set = 3, binding = 0) uniform UniformBuffer { UniformData uniforms; }; #ifdef GPU_MODE layout(set = 4, binding = 0, std430) readonly buffer MaterialBuffer { GPUMaterialData materials[]; }; #endif #ifdef CPU_MODE layout(set = 4, binding = 10) uniform TextureData { CPUMaterialData material; }; #endif void main() { #ifdef GPU_MODE GPUMaterialData material = materials[i_material]; #endif #ifdef CPU_MODE uint object_idx = gl_InstanceIndex; #else uint object_idx = i_object_idx; #endif ObjectOutputData data = object_output[object_idx]; o_material = data.material_idx; o_view_position = data.model_view * vec4(i_position, 1.0); o_normal = data.inv_trans_model_view * i_normal; o_tangent = data.inv_trans_model_view * i_tangent; o_color = i_color; o_coords0 = i_coords0; o_coords1 = i_coords1; #ifdef BAKING vec2 coord1_adj = vec2(material.uv_transform1 * vec3(i_coords1, 1.0)); gl_Position = vec4(coord1_adj * 2.0 - 1.0, 0.0, 1.0); #else gl_Position = data.model_view_proj * vec4(i_position, 1.0); #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  GL_GOOGLE_cpp_style_line_directiveGL_GOOGLE_include_directivemainGPUMaterialDataalbedo_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_materialmi_object_idxsObjectOutputDatasmodel_viewsmodel_view_proj sinv_trans_model_viewsmaterial_idxuObjectOutputDataBufferuobject_outputwo_materialo_view_positioni_positiono_normali_normalo_tangenti_tangento_colori_coloro_coords0i_coords0o_coords1i_coords1gl_PerVertexgl_Positiongl_PointSizegl_ClipDistanceH#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#GHH#GG"G!GGmHsHs#HsHsHs#@HsHsHs#HsHs#GtHuHuHu#GuGw"Gw!GGGGGGGGGGGGGGH H H G!       ; + ; ;mo soo tsut vu;vw ys ;  ;  ;+ ?  ;;;;;  ;  ; ;;;+  ;+ @+ ,  + o++ +6-=A=A= 3=nm6Ayzwn=Az=oAz= Az=8>:= Q Q Q P  ><=  >>=  >@= >B=>C=>FQ Q P  Q Q PGQ Q P A>8