1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef SHADERS_COMMON_3D_DEFAULT_MATERIAL_FRAGMENT_LAYOUT_COMMON_H 17 #define SHADERS_COMMON_3D_DEFAULT_MATERIAL_FRAGMENT_LAYOUT_COMMON_H 18 19 #include "3d/shaders/common/3d_dm_structures_common.h" 20 #include "render/shaders/common/render_compatibility_common.h" 21 #include "render/shaders/common/render_post_process_structs_common.h" 22 23 #ifdef VULKAN 24 25 // sets 26 27 // Set 0 for general, camera, and lighting data 28 // UBOs visible in both VS and FS 29 layout(set = 0, binding = 0, std140) uniform uCameraMatrices 30 { 31 DefaultCameraMatrixStruct uCameras[CORE_DEFAULT_MATERIAL_MAX_CAMERA_COUNT]; 32 }; 33 layout(set = 0, binding = 1, std140) uniform uGeneralStructData 34 { 35 DefaultMaterialGeneralDataStruct uGeneralData; 36 }; 37 layout(set = 0, binding = 2, std140) uniform uEnvironmentStructData 38 { 39 DefaultMaterialEnvironmentStruct uEnvironmentData; 40 }; 41 layout(set = 0, binding = 3, std140) uniform uFogStructData 42 { 43 DefaultMaterialFogStruct uFogData; 44 }; 45 layout(set = 0, binding = 4, std140) uniform uLightStructData 46 { 47 DefaultMaterialLightStruct uLightData; 48 }; 49 layout(set = 0, binding = 5, std140) uniform uPostProcessStructData 50 { 51 GlobalPostProcessStruct uPostProcessData; 52 }; 53 layout(set = 0, binding = 6, std430) buffer uLightClusterIndexData 54 { 55 DefaultMaterialLightClusterData uLightClusterData[CORE_DEFAULT_MATERIAL_MAX_CLUSTERS_COUNT]; 56 }; 57 layout(set = 0, binding = 7) uniform CORE_RELAXEDP sampler2D uSampColorPrePass; 58 layout(set = 0, binding = 8) uniform sampler2D uSampColorShadow; // VSM or other 59 layout(set = 0, binding = 9) uniform sampler2DShadow uSampDepthShadow; // PCF 60 layout(set = 0, binding = 10) uniform samplerCube uSampRadiance; 61 62 // disable set 1 and 2 for environment 63 #ifndef CORE3D_ENVIRONMENT_FRAG_LAYOUT 64 65 // set 1 for dynamic uniform buffers 66 // UBOs visible in both VS and FS 67 layout(set = 1, binding = 0, std140) uniform uMeshStructData 68 { 69 DefaultMaterialMeshStruct uMeshMatrix; 70 }; 71 layout(set = 1, binding = 1, std140) uniform uObjectSkinStructData 72 { 73 DefaultMaterialSkinStruct uSkinData; 74 }; 75 layout(set = 1, binding = 2, std140) uniform uMaterialStructData 76 { 77 DefaultMaterialMaterialStruct uMaterialData; 78 }; 79 layout(set = 1, binding = 3, std140) uniform uMaterialTransformStructData 80 { 81 DefaultMaterialTransformMaterialStruct uMaterialTransformData; 82 }; 83 layout(set = 1, binding = 4, std140) uniform uMaterialUserStructData 84 { 85 DefaultMaterialUserMaterialStruct uMaterialUserData; 86 }; 87 88 // set 2 is for material data (base color separated for e.g. automatic hardware buffer static sampler support) 89 layout(set = 2, binding = 0) uniform CORE_RELAXEDP sampler2D uSampTextureBase; 90 layout(set = 2, binding = 1) uniform CORE_RELAXEDP sampler2D uSampTextures[CORE_MATERIAL_SAMPTEX_COUNT]; 91 92 #endif // CORE3D_ENVIRONMENT_FRAG_LAYOUT 93 94 layout(constant_id = CORE_DM_CONSTANT_ID_MATERIAL_TYPE) const uint CORE_MATERIAL_TYPE = 0; 95 layout(constant_id = CORE_DM_CONSTANT_ID_MATERIAL_FLAGS) const uint CORE_MATERIAL_FLAGS = 0; 96 layout(constant_id = CORE_DM_CONSTANT_ID_LIGHTING_FLAGS) const uint CORE_LIGHTING_FLAGS = 0; 97 layout(constant_id = CORE_DM_CONSTANT_ID_POST_PROCESS_FLAGS) const uint CORE_POST_PROCESS_FLAGS = 0; 98 layout(constant_id = CORE_DM_CONSTANT_ID_CAMERA_FLAGS) const uint CORE_CAMERA_FLAGS = 0; 99 100 #else 101 102 #endif 103 104 #endif // SHADERS_COMMON_3D_DEFAULT_MATERIAL_STRUCTURES_COMMON_H 105