1 /*
2  * Copyright (c) 2024 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 API_3D_RENDER_RENDER_DATA_DEFINES_H
17 #define API_3D_RENDER_RENDER_DATA_DEFINES_H
18 
19 #include <cstdint>
20 
21 #include <3d/ecs/components/mesh_component.h>
22 #include <3d/render/default_material_constants.h>
23 #include <base/containers/fixed_string.h>
24 #include <base/containers/string.h>
25 #include <base/math/matrix.h>
26 #include <base/math/quaternion.h>
27 #include <base/math/vector.h>
28 #include <core/namespace.h>
29 #include <render/render_data_structures.h>
30 
CORE3D_BEGIN_NAMESPACE()31 CORE3D_BEGIN_NAMESPACE()
32 /** \addtogroup group_render_renderdatadefines
33  *  @{
34  */
35 /** Render data constants */
36 namespace RenderSceneDataConstants {
37 /** Max morph target count */
38 static constexpr uint32_t MAX_MORPH_TARGET_COUNT { 64u };
39 
40 /** Mesh indices in index */
41 static constexpr uint32_t MESH_INDEX_INDEX { 5u };
42 /** Mesh weights in index */
43 static constexpr uint32_t MESH_WEIGHT_INDEX { 6u };
44 
45 /** Max vec3 count for 3 bands */
46 static constexpr uint32_t MAX_SH_VEC3_COUNT { 9u };
47 
48 /** Max camera target buffer count */
49 static constexpr uint32_t MAX_CAMERA_COLOR_TARGET_COUNT { 8u };
50 
51 /** Max custom push constant data size */
52 static constexpr uint32_t MAX_CUSTOM_PUSH_CONSTANT_DATA_SIZE {
53     RENDER_NS::PipelineLayoutConstants::MAX_PUSH_CONSTANT_BYTE_SIZE
54 };
55 
56 /** Max default material env custom resources */
57 static constexpr uint32_t MAX_ENV_CUSTOM_RESOURCE_COUNT { 4u };
58 
59 /** Additional custom data size which is bind with render mesh structure to shader
60  * Should match api/shaders/common/3d_dm_structures_common.h DefaultMaterialSingleMeshStruct userData
61  */
62 static constexpr uint32_t MESH_CUSTOM_DATA_VEC4_COUNT { 2u };
63 
64 /** Max multi-view layer camera count. Max layers is 4 -> additional cameras 3 */
65 static constexpr uint32_t MAX_MULTI_VIEW_LAYER_CAMERA_COUNT { 3u };
66 
67 /** Invalid index with default material indices */
68 static constexpr uint32_t INVALID_INDEX { ~0u };
69 
70 /** Invalid 64 bit id */
71 static constexpr uint64_t INVALID_ID { 0xFFFFFFFFffffffff };
72 
73 /** Default render sort layer id */
74 static constexpr uint8_t DEFAULT_RENDER_SORT_LAYER_ID { 32u };
75 
76 /** Default layer mask */
77 static constexpr uint64_t DEFAULT_LAYER_MASK { 0x1 };
78 } // namespace RenderSceneDataConstants
79 
80 /** Render draw command */
81 struct RenderDrawCommand {
82     /** Vertex count */
83     uint32_t vertexCount { 0 };
84     /** Index count */
85     uint32_t indexCount { 0 };
86     /** Instance count */
87     uint32_t instanceCount { 1 };
88 };
89 
90 /** Render vertex buffer */
91 struct RenderVertexBuffer {
92     /** Buffer handle */
93     RENDER_NS::RenderHandleReference bufferHandle {};
94     /** Buffer offset */
95     uint32_t bufferOffset { 0 };
96     /** Byte size */
97     uint32_t byteSize { RENDER_NS::PipelineStateConstants::GPU_BUFFER_WHOLE_SIZE };
98 };
99 
100 /** Render index buffer */
101 struct RenderIndexBuffer {
102     /** Buffer handle */
103     RENDER_NS::RenderHandleReference bufferHandle {};
104     /** Buffer offset */
105     uint32_t bufferOffset { 0 };
106     /** Byte size */
107     uint32_t byteSize { 0 };
108     /** Index type */
109     RENDER_NS::IndexType indexType { RENDER_NS::IndexType::CORE_INDEX_TYPE_UINT32 };
110 };
111 
112 /** Convert RenderVertexBuffer to Renderer VertexBuffer */
ConvertVertexBuffer(const RenderVertexBuffer & rvb)113 inline RENDER_NS::VertexBuffer ConvertVertexBuffer(const RenderVertexBuffer& rvb)
114 {
115     return RENDER_NS::VertexBuffer { rvb.bufferHandle.GetHandle(), rvb.bufferOffset, rvb.byteSize };
116 }
117 
118 /** Convert RenderIndexBuffer to Renderer IndexBuffer */
ConvertIndexBuffer(const RenderIndexBuffer & rib)119 inline RENDER_NS::IndexBuffer ConvertIndexBuffer(const RenderIndexBuffer& rib)
120 {
121     return RENDER_NS::IndexBuffer { rib.bufferHandle.GetHandle(), rib.bufferOffset, rib.byteSize, rib.indexType };
122 }
123 
124 /** Render mesh data
125  * In default material pipeline created by:
126  * RenderMeshComponent creates RenderMeshData for every mesh.
127  */
128 struct RenderMeshData {
129     /** Regular world matrix. */
130     BASE_NS::Math::Mat4X4 world;
131     /** Normal world matrix. */
132     BASE_NS::Math::Mat4X4 normalWorld;
133     /** Regular previous frame world matrix. */
134     BASE_NS::Math::Mat4X4 prevWorld;
135 
136     /** 64 bit id for render instance. Can be used for rendering time identification. RenderMeshComponent entity. */
137     uint64_t id { RenderSceneDataConstants::INVALID_ID };
138     /** 64 bit id for mesh instance. MeshComponent entity. */
139     uint64_t meshId { RenderSceneDataConstants::INVALID_ID };
140 
141     /** layer mask. */
142     uint64_t layerMask { 1 };
143     /** Unused offset. */
144     uint64_t additional { 0 };
145 
146     /** Custom data. */
147     BASE_NS::Math::UVec4 customData[RenderSceneDataConstants::MESH_CUSTOM_DATA_VEC4_COUNT] {};
148 };
149 
150 /** The rendering material specialization flag bits
151  */
152 enum RenderMaterialFlagBits : uint32_t {
153     /** Defines whether this material receives shadow */
154     RENDER_MATERIAL_SHADOW_RECEIVER_BIT = (1 << 0),
155     /** Defines whether this material is a shadow caster */
156     RENDER_MATERIAL_SHADOW_CASTER_BIT = (1 << 1),
157     /** Defines whether this material has a normal map enabled */
158     RENDER_MATERIAL_NORMAL_MAP_BIT = (1 << 2),
159     /** Defines whether this material as one or many texture transforms */
160     RENDER_MATERIAL_TEXTURE_TRANSFORM_BIT = (1 << 3),
161     /** Defines whether to use clear-coat parameters to simulate multi-layer material */
162     RENDER_MATERIAL_CLEAR_COAT_BIT = (1 << 4),
163     /** Defines whether to use transmission parameters to simulate optically transparent materials. */
164     RENDER_MATERIAL_TRANSMISSION_BIT = (1 << 5),
165     /** Defines whether to use sheen parameters to simulate e.g. cloth and fabric materials. */
166     RENDER_MATERIAL_SHEEN_BIT = (1 << 6),
167     /** Defines and additional shader discard bit. e.g. alpha mask discard */
168     RENDER_MATERIAL_SHADER_DISCARD_BIT = (1 << 7),
169     /** Defines if object is opaque and alpha is ignored */
170     RENDER_MATERIAL_OPAQUE_BIT = (1 << 8),
171     /** Defines whether to use specular color and strength parameters. */
172     RENDER_MATERIAL_SPECULAR_BIT = (1 << 9),
173     /** Defines whether this material will receive light from punctual lights (points, spots, directional) */
174     RENDER_MATERIAL_PUNCTUAL_LIGHT_RECEIVER_BIT = (1 << 10),
175     /** Defines whether this material will receive indirect light from SH and cubemaps */
176     RENDER_MATERIAL_INDIRECT_LIGHT_RECEIVER_BIT = (1 << 11),
177     /** Defines if this material is "basic" in default material pipeline
178      * NOTE: used in render node graph to discard materials
179      */
180     RENDER_MATERIAL_BASIC_BIT = (1 << 12),
181     /** Defines if this material is "complex" in default material pipeline
182      * NOTE: used in render node graph to discard materials
183      */
184     RENDER_MATERIAL_COMPLEX_BIT = (1 << 13),
185     /** Defines whether this material uses GPU instancing and needs dynamic UBO indices.
186      * Spesializes the shader, and therefore needs to be setup
187      */
188     RENDER_MATERIAL_GPU_INSTANCING_BIT = (1 << 14),
189 };
190 /** Container for material flag bits */
191 using RenderMaterialFlags = uint32_t;
192 
193 /** Render material type enumeration */
194 enum class RenderMaterialType : uint8_t {
195     /** Enumeration for Metallic roughness workflow */
196     METALLIC_ROUGHNESS = 0,
197     /** Enumumeration for Specular glossiness workflow */
198     SPECULAR_GLOSSINESS = 1,
199     /** Enumumeration for KHR materials unlit workflow */
200     UNLIT = 2,
201     /** Enumumeration for special unlit shadow receiver */
202     UNLIT_SHADOW_ALPHA = 3,
203     /** Custom material. Could be used with custom material model e.g. with shader graph.
204      * Disables automatic factor based modifications for flags.
205      * Note: that base color is always automatically pre-multiplied in all cases
206      */
207     CUSTOM = 4,
208     /** Custom complex material. Could be used with custom material model e.g. with shader graph.
209      * Disables automatic factor based modifications for flags.
210      * Does not use deferred rendering path in any case due to complex material model.
211      * Note: that base color is always automatically pre-multiplied in all cases
212      */
213     CUSTOM_COMPLEX = 5,
214 };
215 
216 /** The rendering submesh specialization flag bits
217  */
218 enum RenderSubmeshFlagBits : uint32_t {
219     /** Defines whether to use tangents with this submesh. */
220     RENDER_SUBMESH_TANGENTS_BIT = (1 << 0),
221     /** Defines whether to use vertex colors with this submesh. */
222     RENDER_SUBMESH_VERTEX_COLORS_BIT = (1 << 1),
223     /** Defines whether to use skinning with this submesh. */
224     RENDER_SUBMESH_SKIN_BIT = (1 << 2),
225     /** Defines whether the submesh has second texcoord set available. */
226     RENDER_SUBMESH_SECOND_TEXCOORD_BIT = (1 << 3),
227     /** Defines whether to use inverse winding with this submesh. */
228     RENDER_SUBMESH_INVERSE_WINDING_BIT = (1 << 4),
229     /** Defines whether to calculate correct velocity in shader. */
230     RENDER_SUBMESH_VELOCITY_BIT = (1 << 5),
231 };
232 /** Container for submesh flag bits */
233 using RenderSubmeshFlags = uint32_t;
234 
235 /** Rendering flags (specialized rendering flags) */
236 enum RenderExtraRenderingFlagBits : uint32_t {
237     /** Is an additional flag which can be used to discard some materials from rendering from render node graph */
238     RENDER_EXTRA_RENDERING_DISCARD_BIT = (1 << 0),
239 };
240 /** Container for extra material rendering flag bits */
241 using RenderExtraRenderingFlags = uint32_t;
242 
243 /** Render submesh */
244 struct RenderSubmesh {
245     /** 64 bit id for render instance. Can be used for rendering time identification. RenderMeshComponent entity. */
246     uint64_t id { RenderSceneDataConstants::INVALID_ID };
247     /** 64 bit id for mesh instance. MeshComponent entity. */
248     uint64_t meshId { RenderSceneDataConstants::INVALID_ID };
249     /** Submesh index. */
250     uint32_t subMeshIndex { 0 };
251 
252     /** Layer mask. */
253     uint64_t layerMask { RenderSceneDataConstants::DEFAULT_LAYER_MASK };
254 
255     /** Render sort layer id. Valid values are 0 - 63 */
256     uint8_t renderSortLayer { RenderSceneDataConstants::DEFAULT_RENDER_SORT_LAYER_ID };
257     /** Render sort layer id. Valid values are 0 - 255 */
258     uint8_t renderSortLayerOrder { 0 };
259 
260     /** A valid index to material. Get from AddMaterial() */
261     uint32_t materialIndex { RenderSceneDataConstants::INVALID_INDEX };
262     /** A valid index to mesh (matrix). Get from AddMeshData() */
263     uint32_t meshIndex { RenderSceneDataConstants::INVALID_INDEX };
264     /** A valid index to skin joint matrices if has skin. Get from AddSkinJointMatrices() */
265     uint32_t skinJointIndex { RenderSceneDataConstants::INVALID_INDEX };
266     /** A valid index to material custom resources if any. Get from AddMaterialCustomResources() */
267     uint32_t customResourcesIndex { RenderSceneDataConstants::INVALID_INDEX };
268 
269     /** World center vector */
270     BASE_NS::Math::Vec3 worldCenter { 0.0f, 0.0f, 0.0f };
271     /** World radius */
272     float worldRadius { 0.0f };
273 
274     /** Index buffer */
275     RenderIndexBuffer indexBuffer;
276     /** Vertex buffers */
277     RenderVertexBuffer vertexBuffers[RENDER_NS::PipelineStateConstants::MAX_VERTEX_BUFFER_COUNT];
278     /** Vertex buffer count */
279     uint32_t vertexBufferCount { 0 };
280 
281     /* Optional indirect args buffer for indirect draw. */
282     RenderVertexBuffer indirectArgsBuffer;
283 
284     /** Draw command */
285     RenderDrawCommand drawCommand;
286 
287     /** Submesh flags */
288     RenderSubmeshFlags submeshFlags { 0 };
289 };
290 
291 /** Render light */
292 struct RenderLight {
293     /** Light usage flag bits */
294     enum LightUsageFlagBits {
295         /** Directional light bit */
296         LIGHT_USAGE_DIRECTIONAL_LIGHT_BIT = (1 << 0),
297         /** Point light bit */
298         LIGHT_USAGE_POINT_LIGHT_BIT = (1 << 1),
299         /** Spot light bit */
300         LIGHT_USAGE_SPOT_LIGHT_BIT = (1 << 2),
301         /** Shadow light bit */
302         LIGHT_USAGE_SHADOW_LIGHT_BIT = (1 << 3),
303     };
304     /** Light usage flags */
305     using LightUsageFlags = uint32_t;
306 
307     /** Unique id. */
308     uint64_t id { RenderSceneDataConstants::INVALID_ID };
309 
310     /** Layer mask (light affect mask). All enabled by default */
311     uint64_t layerMask { RenderSceneDataConstants::INVALID_ID };
312 
313     /** Position */
314     BASE_NS::Math::Vec4 pos { 0.0f, 0.0f, 0.0f, 0.0f };
315     /** Direction */
316     BASE_NS::Math::Vec4 dir { 0.0f, 0.0f, 0.0f, 0.0f };
317     /** Color, w is intensity */
318     BASE_NS::Math::Vec4 color { 0.0f, 0.0f, 0.0f, 0.0f };
319 
320     /* Spot light params. .x = angleScale, .y = angleOffset, .z = innerAngle, .w = outerAngle */
321     BASE_NS::Math::Vec4 spotLightParams { 0.0f, 0.0f, 0.0f, 0.0f };
322     /* Point and spot params. */
323     float range { 0.0f };
324     // .x = shadow factor, .y = depth bias, .z = normal bias, .w = empty (filled later with step size)
325     BASE_NS::Math::Vec4 shadowFactors { 1.0f, 0.005f, 0.02f, 0.0f };
326 
327     /** Object ID */
328     uint32_t objectId { ~0u };
329     /** Light usage flags */
330     LightUsageFlags lightUsageFlags { 0u };
331 
332     /** Shadow camera index in render lights */
333     uint32_t shadowCameraIndex { ~0u };
334     /** Filled by the data store */
335     uint32_t shadowIndex { ~0u };
336 };
337 
338 /** Render camera */
339 struct RenderCamera {
340     enum CameraFlagBits : uint32_t {
341         /** Clear depth. Overrides camera RNG loadOp with clear. */
342         CAMERA_FLAG_CLEAR_DEPTH_BIT = (1 << 0),
343         /** Clear color. Overrides camera RNG loadOp with clear. */
344         CAMERA_FLAG_CLEAR_COLOR_BIT = (1 << 1),
345         /** Shadow camera */
346         CAMERA_FLAG_SHADOW_BIT = (1 << 2),
347         /** MSAA enabled */
348         CAMERA_FLAG_MSAA_BIT = (1 << 3),
349         /** Reflection camera */
350         CAMERA_FLAG_REFLECTION_BIT = (1 << 4),
351         /** Main scene camera. I.e. the final main camera which might try to render to swapchain */
352         CAMERA_FLAG_MAIN_BIT = (1 << 5),
353         /** This is a pre-pass color camera. */
354         CAMERA_FLAG_COLOR_PRE_PASS_BIT = (1 << 6),
355         /** Render only opaque. */
356         CAMERA_FLAG_OPAQUE_BIT = (1 << 7),
357         /** Use and flip history */
358         CAMERA_FLAG_HISTORY_BIT = (1 << 8),
359         /** Jitter camera. */
360         CAMERA_FLAG_JITTER_BIT = (1 << 9),
361         /** Output samplable velocity normal */
362         CAMERA_FLAG_OUTPUT_VELOCITY_NORMAL_BIT = (1 << 10),
363         /** Disable FW velocity */
364         CAMERA_FLAG_INVERSE_WINDING_BIT = (1 << 11),
365         /** Samplable depth target */
366         CAMERA_FLAG_OUTPUT_DEPTH_BIT = (1 << 12),
367         /** Custom targets */
368         CAMERA_FLAG_CUSTOM_TARGETS_BIT = (1 << 13),
369         /** Multi-view camera */
370         CAMERA_FLAG_MULTI_VIEW_ONLY_BIT = (1 << 14),
371         /** Dynamic cubemap */
372         CAMERA_FLAG_DYNAMIC_CUBEMAP_BIT = (1 << 15),
373         /** Allow reflection */
374         CAMERA_FLAG_ALLOW_REFLECTION_BIT = (1 << 16),
375     };
376     using Flags = uint32_t;
377 
378     enum ShaderFlagBits : uint32_t {
379         /** Fog enabled in the shader. Changed based on render slots and rendering types. */
380         CAMERA_SHADER_FOG_BIT = (1 << 0),
381     };
382     using ShaderFlags = uint32_t;
383 
384     enum class RenderPipelineType : uint32_t {
385         /** Forward */
386         LIGHT_FORWARD = 0,
387         /** Forward */
388         FORWARD = 1,
389         /** Deferred */
390         DEFERRED = 2,
391         /** Custom */
392         CUSTOM = 3,
393     };
394 
395     enum class CameraCullType : uint8_t {
396         /** None */
397         CAMERA_CULL_NONE = 0,
398         /** Front to back */
399         CAMERA_CULL_VIEW_FRUSTUM = 1,
400     };
401 
402     /** Matrices */
403     struct Matrices {
404         /** View matrix */
405         BASE_NS::Math::Mat4X4 view;
406         /** Projection matrix */
407         BASE_NS::Math::Mat4X4 proj;
408 
409         /** Previous view matrix */
410         BASE_NS::Math::Mat4X4 viewPrevFrame;
411         /** Previous projection matrix */
412         BASE_NS::Math::Mat4X4 projPrevFrame;
413     };
414 
415     /** Environment setup */
416     struct Environment {
417         /** Background type for env node */
418         enum BackgroundType {
419             /** None */
420             BG_TYPE_NONE = 0,
421             /** Image (2d) */
422             BG_TYPE_IMAGE = 1,
423             /** Cubemap */
424             BG_TYPE_CUBEMAP = 2,
425             /** Equirectangular */
426             BG_TYPE_EQUIRECTANGULAR = 3,
427         };
428 
429         /** Unique id. */
430         uint64_t id { RenderSceneDataConstants::INVALID_ID };
431 
432         /** Layer mask (camera render mask). All enabled by default */
433         uint64_t layerMask { RenderSceneDataConstants::INVALID_ID };
434 
435         /** Radiance cubemap resource handle */
436         RENDER_NS::RenderHandleReference radianceCubemap;
437         /** Radiance cubemap mip count. Zero indicates that full mipchain is available */
438         uint32_t radianceCubemapMipCount { 0u };
439 
440         /** Environment map resource handle */
441         RENDER_NS::RenderHandleReference envMap;
442         /** Environment map lod level for sampling */
443         float envMapLodLevel { 0.0f };
444 
445         /** Spherical harmonic coefficients for indirect diffuse (irradiance)
446          * Prescaled with 1.0 / PI. */
447         BASE_NS::Math::Vec4 shIndirectCoefficients[RenderSceneDataConstants::MAX_SH_VEC3_COUNT];
448 
449         /** Indirect diffuse color factor (.rgb = tint, .a = intensity) */
450         BASE_NS::Math::Vec4 indirectDiffuseFactor { 1.0f, 1.0f, 1.0f, 1.0f };
451         /** Indirect specular color factor (.rgb = tint, .a = intensity) */
452         BASE_NS::Math::Vec4 indirectSpecularFactor { 1.0f, 1.0f, 1.0f, 1.0f };
453         /** Env map color factor (.rgb = tint, .a = intensity) */
454         BASE_NS::Math::Vec4 envMapFactor { 1.0f, 1.0f, 1.0f, 1.0f };
455         /** Additional blend factor */
456         BASE_NS::Math::Vec4 blendFactor { 0.0f, 0.0f, 0.0f, 0.0f };
457 
458         /** Environment rotation */
459         BASE_NS::Math::Quat rotation { 0.0f, 0.0f, 0.0f, 1.0f };
460 
461         /** Background type */
462         BackgroundType backgroundType { BackgroundType::BG_TYPE_NONE };
463 
464         /** Custom shader handle */
465         RENDER_NS::RenderHandleReference shader;
466         /** invalid handles if not given */
467         RENDER_NS::RenderHandleReference customResourceHandles[RenderSceneDataConstants::MAX_ENV_CUSTOM_RESOURCE_COUNT];
468     };
469 
470     /** Fog setup */
471     struct Fog {
472         /** Unique id. */
473         uint64_t id { RenderSceneDataConstants::INVALID_ID };
474 
475         /** Layer mask (camera render mask). All enabled by default */
476         uint64_t layerMask { RenderSceneDataConstants::INVALID_ID };
477 
478         /** .x = density, .y = heightFalloff, .z = heightFogOffset */
479         BASE_NS::Math::Vec4 firstLayer { 1.0f, 1.0f, 1.0f, 0.0f };
480         /** .x = density, .y = heightFalloff, .z = heightFogOffset */
481         BASE_NS::Math::Vec4 secondLayer { 1.0f, 1.0f, 1.0f, 0.0f };
482 
483         /** .x = startDistance, .y = cutoffDistance, .z = maxOpacity */
484         BASE_NS::Math::Vec4 baseFactors { 1.0f, -1.0f, 1.0f, 0.0f };
485 
486         /** Primary color for the fog (.rgb = tint, .a = intensity) */
487         BASE_NS::Math::Vec4 inscatteringColor { 1.0f, -1.0f, 1.0f, 0.0f };
488         /** Env map color factor (.rgb = tint, .a = intensity) */
489         BASE_NS::Math::Vec4 envMapFactor { 1.0f, -1.0f, 1.0f, 0.0f };
490 
491         /** Additional factor */
492         BASE_NS::Math::Vec4 additionalFactor { 0.0f, 0.0f, 0.0f, 0.0f };
493     };
494 
495     /** Unique id. */
496     uint64_t id { RenderSceneDataConstants::INVALID_ID };
497     /** Shadow id. (Can be invalid) */
498     uint64_t shadowId { RenderSceneDataConstants::INVALID_ID };
499 
500     /** Layer mask (camera render mask). All enabled by default */
501     uint64_t layerMask { RenderSceneDataConstants::INVALID_ID };
502 
503     /** Main camera to this camera id. (e.g. reflection camera has info of the main camera) */
504     uint64_t mainCameraId { RenderSceneDataConstants::INVALID_ID };
505 
506     /** Matrices (Contains view, projection, view of previous frame and projection of previous frame) */
507     Matrices matrices;
508 
509     /** Viewport (relative to render resolution) */
510     BASE_NS::Math::Vec4 viewport { 0.0f, 0.0f, 1.0f, 1.0f };
511     /** Scissor (relative to render resolution) */
512     BASE_NS::Math::Vec4 scissor { 0.0f, 0.0f, 1.0f, 1.0f };
513     /** Render resolution */
514     BASE_NS::Math::UVec2 renderResolution { 0u, 0u };
515 
516     /** Z near value */
517     float zNear { 0.0f };
518     /** Z far value */
519     float zFar { 0.0f };
520 
521     /** Custom depth target */
522     RENDER_NS::RenderHandleReference depthTarget {};
523     /** Custom color targets */
524     RENDER_NS::RenderHandleReference colorTargets[RenderSceneDataConstants::MAX_CAMERA_COLOR_TARGET_COUNT];
525 
526     /** Custom pre-pass color target. Can be tried to fetch with a name if handle is not given. */
527     BASE_NS::fixed_string<RENDER_NS::RenderDataConstants::MAX_DEFAULT_NAME_LENGTH> prePassColorTargetName;
528 
529     /** Flags for camera */
530     Flags flags { 0u };
531     /** Shader flags for camera */
532     ShaderFlags shaderFlags { 0u };
533 
534     /** Flags for camera render pipeline */
535     RenderPipelineType renderPipelineType { RenderPipelineType::FORWARD };
536 
537     /** Clear depth / stencil values. Clear enabled if flags set. */
538     RENDER_NS::ClearDepthStencilValue clearDepthStencil { 1.0f, 0u };
539     /** Clear color values. Clear enabled if flags set */
540     RENDER_NS::ClearColorValue clearColorValues { 0.0f, 0.0f, 0.0f, 0.0f };
541 
542     /** Camera cull type */
543     CameraCullType cullType { CameraCullType::CAMERA_CULL_VIEW_FRUSTUM };
544 
545     /** Default environment setup for camera */
546     Environment environment;
547 
548     /** Fog setup for camera */
549     Fog fog;
550 
551     /** Custom render node graph from camera component (WILL BE DEPRECATED) */
552     RENDER_NS::RenderHandleReference customRenderNodeGraph;
553 
554     /** Custom render node graph file from camera component */
555     BASE_NS::string customRenderNodeGraphFile;
556 
557     /** Custom render node graph file from post process configuration component */
558     BASE_NS::string customPostProcessRenderNodeGraphFile;
559 
560     /** Target customization */
561     struct TargetUsage {
562         /** Target format */
563         BASE_NS::Format format { BASE_NS::Format::BASE_FORMAT_UNDEFINED };
564         /** Usage flags hints for optimizing resource creation */
565         RENDER_NS::ImageUsageFlags usageFlags { 0 };
566     };
567 
568     /** Depth target customization */
569     TargetUsage depthTargetCustomization;
570     /** Color target customization */
571     TargetUsage colorTargetCustomization[RenderSceneDataConstants::MAX_CAMERA_COLOR_TARGET_COUNT];
572 
573     /** Unique camera name for getting named camera. */
574     BASE_NS::fixed_string<RENDER_NS::RenderDataConstants::MAX_DEFAULT_NAME_LENGTH> name;
575 
576     /** Camera post process name. Can be empty */
577     BASE_NS::fixed_string<RENDER_NS::RenderDataConstants::MAX_DEFAULT_NAME_LENGTH> postProcessName;
578 
579     /** Multi-view extra camera count. */
580     uint32_t multiViewCameraCount { 0U };
581     /** 64bit camera id of multi-view layer cameras. */
582     uint64_t multiViewCameraIds[RenderSceneDataConstants::MAX_MULTI_VIEW_LAYER_CAMERA_COUNT] {
583         RenderSceneDataConstants::INVALID_ID, RenderSceneDataConstants::INVALID_ID, RenderSceneDataConstants::INVALID_ID
584     };
585     uint64_t multiViewParentCameraId { RenderSceneDataConstants::INVALID_ID };
586 
587     /** Environment count. */
588     uint32_t environmentCount { 0U };
589     /** 64bit environment id of environments. */
590     uint64_t environmentIds[DefaultMaterialCameraConstants::MAX_ENVIRONMENT_COUNT] {
591         RenderSceneDataConstants::INVALID_ID, RenderSceneDataConstants::INVALID_ID,
592         RenderSceneDataConstants::INVALID_ID, RenderSceneDataConstants::INVALID_ID,
593         RenderSceneDataConstants::INVALID_ID, RenderSceneDataConstants::INVALID_ID,
594         RenderSceneDataConstants::INVALID_ID, RenderSceneDataConstants::INVALID_ID
595     };
596 };
597 
598 /** Render scene */
599 struct RenderScene {
600     /** Unique id. */
601     uint64_t id { RenderSceneDataConstants::INVALID_ID };
602     /** Unique scene name (If name is empty a default id/name is created with index) */
603     BASE_NS::fixed_string<RENDER_NS::RenderDataConstants::MAX_DEFAULT_NAME_LENGTH> name;
604 
605     /** Scene render data store name needs to be known */
606 
607     /** Camera render data store name */
608     BASE_NS::fixed_string<RENDER_NS::RenderDataConstants::MAX_DEFAULT_NAME_LENGTH> dataStoreNameCamera;
609     /** Light render data store name */
610     BASE_NS::fixed_string<RENDER_NS::RenderDataConstants::MAX_DEFAULT_NAME_LENGTH> dataStoreNameLight;
611     /** Material data store name */
612     BASE_NS::fixed_string<RENDER_NS::RenderDataConstants::MAX_DEFAULT_NAME_LENGTH> dataStoreNameMaterial;
613     /** Morphing data store name */
614     BASE_NS::fixed_string<RENDER_NS::RenderDataConstants::MAX_DEFAULT_NAME_LENGTH> dataStoreNameMorph;
615     /** Data store name prefix */
616     BASE_NS::fixed_string<RENDER_NS::RenderDataConstants::MAX_DEFAULT_NAME_LENGTH> dataStoreNamePrefix;
617 
618     /** World scene center */
619     BASE_NS::Math::Vec3 worldSceneCenter { 0.0f, 0.0f, 0.0f };
620     /** World scene bounding sphere radius */
621     float worldSceneBoundingSphereRadius { 0.0f };
622 
623     /** Index of scene camera in rendering cameras */
624     uint32_t cameraIndex { RenderSceneDataConstants::INVALID_INDEX };
625 
626     /** Scene delta time in milliseconds */
627     float sceneDeltaTime { 0 };
628     /** Real total tick time in seconds */
629     float totalTime { 0u };
630     /** Real delta tick time in milliseconds */
631     float deltaTime { 0u };
632     /** Render scene frame index */
633     uint32_t frameIndex { 0u };
634 
635     /** Custom render node graph file from scene component */
636     BASE_NS::string customRenderNodeGraphFile;
637     /** Custom post scene render node graph file from scene component */
638     BASE_NS::string customPostSceneRenderNodeGraphFile;
639 };
640 
641 struct SlotSubmeshIndex {
642     uint32_t submeshIndex { 0 };
643 
644     uint32_t sortLayerKey { 0 };
645     uint64_t sortKey { 0 };
646     uint32_t renderMaterialSortHash { 0 };
647     RENDER_NS::RenderHandle shaderHandle;
648     RENDER_NS::RenderHandle gfxStateHandle;
649 };
650 
651 enum RenderSceneFlagBits : uint32_t {
652     RENDER_SCENE_DIRECT_POST_PROCESS_BIT = (1 << 0),
653     RENDER_SCENE_FLIP_WINDING_BIT = (1 << 1),
654     RENDER_SCENE_DISCARD_MATERIAL_BIT = (1 << 2),
655     RENDER_SCENE_ENABLE_FOG_BIT = (1 << 3),
656     RENDER_SCENE_DISABLE_FOG_BIT = (1 << 4),
657 };
658 using RenderSceneFlags = uint32_t;
659 /** @} */
660 CORE3D_END_NAMESPACE()
661 
662 #endif // API_3D_RENDER_RENDER_DATA_DEFINES_H
663