// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved. #pragma once #include "Engine/Core/Types/BaseTypes.h" #include "Engine/Core/Config.h" /// /// Graphics rendering backend system types. /// API_ENUM() enum class RendererType { /// /// Unknown type /// Unknown = 0, /// /// DirectX 10 /// DirectX10 = 1, /// /// DirectX 10.1 /// DirectX10_1 = 2, /// /// DirectX 11 /// DirectX11 = 3, /// /// DirectX 12 /// DirectX12 = 4, /// /// OpenGL 4.1 /// OpenGL4_1 = 5, /// /// OpenGL 4.4 /// OpenGL4_4 = 6, /// /// OpenGL ES 3 /// OpenGLES3 = 7, /// /// OpenGL ES 3.1 /// OpenGLES3_1 = 8, /// /// Null backend /// Null = 9, /// /// Vulkan /// Vulkan = 10, /// /// PlayStation 4 /// PS4 = 11, /// /// PlayStation 5 /// PS5 = 12, API_ENUM(Attributes="HideInEditor") MAX }; const Char* ToString(RendererType value); /// /// Shader profile types define the version and type of the shading language used by the graphics backend. /// API_ENUM() enum class ShaderProfile { /// /// Unknown /// Unknown = 0, /// /// DirectX (Shader Model 4 compatible) /// DirectX_SM4 = 1, /// /// DirectX (Shader Model 5 compatible) /// DirectX_SM5 = 2, /// /// GLSL 410 /// GLSL_410 = 3, /// /// GLSL 440 /// GLSL_440 = 4, /// /// Vulkan (Shader Model 5 compatible) /// Vulkan_SM5 = 5, /// /// PlayStation 4 /// PS4 = 6, /// /// DirectX (Shader Model 6 compatible) /// DirectX_SM6 = 7, /// /// PlayStation 5 /// PS5 = 8, API_ENUM(Attributes="HideInEditor") MAX }; const Char* ToString(ShaderProfile value); /// /// Graphics feature levels indicates what level of support can be relied upon. /// They are named after the graphics API to indicate the minimum level of the features set to support. /// Feature levels are ordered from the lowest to the most high-end so feature level enum can be used to switch between feature levels (e.g. don't use geometry shader if not supported). /// API_ENUM() enum class FeatureLevel { /// /// The features set defined by the core capabilities of OpenGL ES2. /// ES2 = 0, /// /// The features set defined by the core capabilities of OpenGL ES3. /// ES3 = 1, /// /// The features set defined by the core capabilities of OpenGL ES3.1. /// ES3_1 = 2, /// /// The features set defined by the core capabilities of DirectX 10 Shader Model 4. /// SM4 = 3, /// /// The features set defined by the core capabilities of DirectX 11 Shader Model 5. /// SM5 = 4, /// /// The features set defined by the core capabilities of DirectX 12 Shader Model 6. /// SM6 = 5, API_ENUM(Attributes="HideInEditor") MAX }; const Char* ToString(FeatureLevel value); /// /// Multisample count level. /// API_ENUM() enum class MSAALevel : int32 { /// /// Disabled multisampling. /// None = 1, /// /// Two samples per pixel. /// X2 = 2, /// /// Four samples per pixel. /// X4= 4, /// /// Eight samples per pixel. /// X8 = 8, }; const Char* ToString(MSAALevel value); /// /// Shadows casting modes by visual elements. /// API_ENUM(Attributes="Flags") enum class ShadowsCastingMode { /// /// Never render shadows. /// None = 0, /// /// Render shadows only in static views (env probes, lightmaps, etc.). /// StaticOnly = 1, /// /// Render shadows only in dynamic views (game, editor, etc.). /// DynamicOnly = 2, /// /// Always render shadows. /// All = StaticOnly | DynamicOnly, }; DECLARE_ENUM_OPERATORS(ShadowsCastingMode); /// /// The partitioning mode for shadow cascades. /// API_ENUM() enum class PartitionMode { /// /// Internally defined cascade splits. /// Manual = 0, /// /// Logarithmic cascade splits. /// Logarithmic = 1, /// /// Parallel-Split Shadow Maps cascade splits. /// PSSM = 2, }; /// /// Identifies expected GPU resource use during rendering. The usage directly reflects whether a resource is accessible by the CPU and/or the GPU. /// API_ENUM() enum class GPUResourceUsage { /// /// A resource that requires read and write access by the GPU. /// This is likely to be the most common usage choice. /// Memory will be used on device only, so fast access from the device is preferred. /// It usually means device-local GPU (video) memory. /// /// /// Usage: /// - Resources written and read by device, e.g. images used as render targets. /// - Resources transferred from host once (immutable) or infrequently and read by /// device multiple times, e.g. textures to be sampled, vertex buffers, constant /// buffers, and majority of other types of resources used on GPU. /// Default = 0, /// /// A resource that is accessible by both the GPU (read only) and the CPU (write only). /// A dynamic resource is a good choice for a resource that will be updated by the CPU at least once per frame. /// Dynamic buffers or textures are usually used to upload data to GPU and use it within a single frame. /// /// /// Usage: /// - Resources written frequently by CPU (dynamic), read by device. /// E.g. textures, vertex buffers, uniform buffers updated every frame or every draw call. /// Dynamic = 1, /// /// A resource that supports data transfer (copy) from the CPU to the GPU. /// It usually means CPU (system) memory. Resources created in this pool may still be accessible to the device, but access to them can be slow. /// /// /// Usage: /// - Staging copy of resources used as transfer source. /// StagingUpload = 2, /// /// A resource that supports data transfer (copy) from the GPU to the CPU. /// /// /// Usage: /// - Resources written by device, read by host - results of some computations, e.g. screen capture, average scene luminance for HDR tone mapping. /// - Any resources read or accessed randomly on host, e.g. CPU-side copy of vertex buffer used as source of transfer, but also used for collision detection. /// StagingReadback = 3, /// /// A resource that supports both read and write from the CPU. /// This is likely to be the common choice for read-write buffers to transfer data between GPU compute buffers and CPU memory. /// It usually means CPU (system) memory. /// /// /// Usage: /// - Staging memory to upload to GPU for compute and gather results back after processing. /// Staging = 4, }; /// /// Describes how a mapped GPU resource will be accessed. /// API_ENUM(Attributes="Flags") enum class GPUResourceMapMode { /// /// The resource is mapped for reading. /// Read = 0x01, /// /// The resource is mapped for writing. /// Write = 0x02, /// /// The resource is mapped for reading and writing. /// ReadWrite = Read | Write, }; /// /// Primitives types. /// API_ENUM() enum class PrimitiveTopologyType { /// /// Unknown topology. /// Undefined = 0, /// /// Points list. /// Point = 1, /// /// Line list. /// Line = 2, /// /// Triangle list. /// Triangle = 3, }; /// /// Primitives culling mode. /// API_ENUM() enum class CullMode : byte { /// /// Cull back-facing primitives only. /// Normal = 0, /// /// Cull front-facing primitives only. /// Inverted = 1, /// /// Disable face culling. /// TwoSided = 2, }; /// /// Render target blending mode descriptor. /// API_STRUCT() struct FLAXENGINE_API BlendingMode { DECLARE_SCRIPTING_TYPE_MINIMAL(BlendingMode); /// /// Blending mode. /// API_ENUM() enum class Blend { // The blend factor is (0, 0, 0, 0). No pre-blend operation. Zero = 1, // The blend factor is (1, 1, 1, 1). No pre-blend operation. One = 2, // The blend factor is (Rs, Gs, Bs, As), that is color data (RGB) from a pixel shader. No pre-blend operation. SrcColor = 3, // The blend factor is (1 - Rs, 1 - Gs, 1 - Bs, 1 - As), that is color data (RGB) from a pixel shader. The pre-blend operation inverts the data, generating 1 - RGB. InvSrcColor = 4, // The blend factor is (As, As, As, As), that is alpha data (A) from a pixel shader. No pre-blend operation. SrcAlpha = 5, // The blend factor is ( 1 - As, 1 - As, 1 - As, 1 - As), that is alpha data (A) from a pixel shader. The pre-blend operation inverts the data, generating 1 - A. InvSrcAlpha = 6, // The blend factor is (Ad Ad Ad Ad), that is alpha data from a render target. No pre-blend operation. DestAlpha = 7, // The blend factor is (1 - Ad 1 - Ad 1 - Ad 1 - Ad), that is alpha data from a render target. The pre-blend operation inverts the data, generating 1 - A. InvDestAlpha = 8, // The blend factor is (Rd, Gd, Bd, Ad), that is color data from a render target. No pre-blend operation. DestColor = 9, // The blend factor is (1 - Rd, 1 - Gd, 1 - Bd, 1 - Ad), that is color data from a render target. The pre-blend operation inverts the data, generating 1 - RGB. InvDestColor = 10, // The blend factor is (f, f, f, 1); where f = min(As, 1 - Ad). The pre-blend operation clamps the data to 1 or less. SrcAlphaSat = 11, // The blend factor is the blend factor set with GPUContext::SetBlendFactor. No pre-blend operation. BlendFactor = 14, // The blend factor is the blend factor set with GPUContext::SetBlendFactor. The pre-blend operation inverts the blend factor, generating 1 - blend_factor. BlendInvFactor = 15, // The blend factor is data sources both as color data output by a pixel shader. There is no pre-blend operation. This blend factor supports dual-source color blending. Src1Color = 16, // The blend factor is data sources both as color data output by a pixel shader. The pre-blend operation inverts the data, generating 1 - RGB. This blend factor supports dual-source color blending. InvSrc1Color = 17, // The blend factor is data sources as alpha data output by a pixel shader. There is no pre-blend operation. This blend factor supports dual-source color blending. Src1Alpha = 18, // The blend factor is data sources as alpha data output by a pixel shader. The pre-blend operation inverts the data, generating 1 - A. This blend factor supports dual-source color blending. InvSrc1Alpha = 19, API_ENUM(Attributes="HideInEditor") MAX }; /// /// Blending operation. /// API_ENUM() enum class Operation { // Add source 1 and source 2. Add = 1, // Subtract source 1 from source 2. Subtract = 2, // Subtract source 2 from source 1. RevSubtract = 3, // Find the minimum of source 1 and source 2. Min = 4, // Find the maximum of source 1 and source 2. Max = 5, API_ENUM(Attributes="HideInEditor") MAX }; /// /// Render target write mask /// API_ENUM() enum class ColorWrite { // No color writing. None = 0, // Allow data to be stored in the red component. Red = 1, // Allow data to be stored in the green component. Green = 2, // Allow data to be stored in the blue component. Blue = 4, // Allow data to be stored in the alpha component. Alpha = 8, // Allow data to be stored in all components. All = Red | Green | Blue | Alpha, // Allow data to be stored in red and green components. RG = Red | Green, // Allow data to be stored in red, green and blue components. RGB = Red | Green | Blue, // Allow data to be stored in all components. RGBA = Red | Green | Blue | Alpha, }; public: /// /// Render target blending mode descriptor. /// API_FIELD() bool AlphaToCoverageEnable; /// /// Render target blending mode descriptor. /// API_FIELD() bool BlendEnable; /// /// Render target blending mode descriptor. /// API_FIELD() Blend SrcBlend; /// /// Render target blending mode descriptor. /// API_FIELD() Blend DestBlend; /// /// Render target blending mode descriptor. /// API_FIELD() Operation BlendOp; /// /// Render target blending mode descriptor. /// API_FIELD() Blend SrcBlendAlpha; /// /// Render target blending mode descriptor. /// API_FIELD() Blend DestBlendAlpha; /// /// Render target blending mode descriptor. /// API_FIELD() Operation BlendOpAlpha; /// /// Render target blending mode descriptor. /// API_FIELD() ColorWrite RenderTargetWriteMask; public: bool operator==(const BlendingMode& other) const; public: /// /// Gets the opaque rendering (default). No blending is being performed. /// API_FIELD(ReadOnly) static BlendingMode Opaque; /// /// Gets the additive rendering. Adds the color and the alpha channel. Source color is multiplied by the alpha. /// API_FIELD(ReadOnly) static BlendingMode Additive; /// /// Gets the alpha blending. Source alpha controls the output color (0 - use destination color, 1 - use source color). /// API_FIELD(ReadOnly) static BlendingMode AlphaBlend; /// /// Gets the additive blending with pre-multiplied color. /// API_FIELD(ReadOnly) static BlendingMode Add; /// /// Gets the multiply blending (multiply output color with texture color). /// API_FIELD(ReadOnly) static BlendingMode Multiply; }; uint32 GetHash(const BlendingMode& key); /// /// Comparison function modes /// API_ENUM() enum class ComparisonFunc : byte { // Never pass the comparison. Never = 1, // If the source data is less than the destination data, the comparison passes. Less = 2, // If the source data is equal to the destination data, the comparison passes. Equal = 3, // If the source data is less than or equal to the destination data, the comparison passes. LessEqual = 4, // If the source data is greater than the destination data, the comparison passes. Greater = 5, // If the source data is not equal to the destination data, the comparison passes. NotEqual = 6, // If the source data is greater than or equal to the destination data, the comparison passes. GreaterEqual = 7, // Always pass the comparison. Always = 8, API_ENUM(Attributes="HideInEditor") MAX }; /// /// Rendering quality levels. /// API_ENUM() enum class Quality : byte { /// /// The low quality. /// Low = 0, /// /// The medium quality. /// Medium = 1, /// /// The high quality. /// High = 2, /// /// The ultra, mega, fantastic quality! /// Ultra = 3, API_ENUM(Attributes="HideInEditor") MAX }; /// /// Post Fx material rendering locations. /// API_ENUM() enum class MaterialPostFxLocation : byte { /// /// Render the material after the post processing pass using *LDR* input frame. /// AfterPostProcessingPass = 0, /// /// Render the material before the post processing pass using *HDR* input frame. /// BeforePostProcessingPass = 1, /// /// Render the material before the forward pass but after *GBuffer* with *HDR* input frame. /// BeforeForwardPass = 2, /// /// Render the material after custom post effects (scripted). /// AfterCustomPostEffects = 3, /// /// Render the material before the reflections pass but after the lighting pass using *HDR* input frame. It can be used to implement a custom light types that accumulate lighting to the light buffer. /// BeforeReflectionsPass = 4, /// /// Render the material after anti-aliasing into the output backbuffer. /// AfterAntiAliasingPass = 5, /// /// Render the material after the forward pass but before any post processing. /// AfterForwardPass = 6, API_ENUM(Attributes="HideInEditor") MAX, }; /// /// The Post Process effect rendering location within the rendering pipeline. /// API_ENUM() enum class PostProcessEffectLocation { /// /// The default location after the in-build PostFx pass (bloom, color grading, etc.) but before anti-aliasing effect. /// Default = 0, /// /// The 'before' in-build PostFx pass (bloom, color grading, etc.). After Forward Pass (transparency) and fog effects. /// BeforePostProcessingPass = 1, /// /// The 'before' Forward pass (transparency) and fog effects. After the Light pass and Reflections pass. /// BeforeForwardPass = 2, /// /// The 'before' Reflections pass. After the Light pass. Can be used to implement a custom light types that accumulate lighting to the light buffer. /// BeforeReflectionsPass = 3, /// /// The 'after' AA filter pass. /// AfterAntiAliasingPass = 4, /// /// The custom frame up-scaling that replaces default implementation. Rendering is done to the output backbuffer (use OutputView and OutputViewport as render destination). /// CustomUpscale = 5, /// /// The 'after' GBuffer rendering pass. Can be used to render custom geometry into GBuffer. Output is light buffer, single-target only (no output). /// AfterGBufferPass = 6, /// /// The 'after' forward pass but before any post processing. /// AfterForwardPass = 7, API_ENUM(Attributes="HideInEditor") MAX, }; /// /// The objects drawing pass types. Used as a flags for objects drawing masking. /// API_ENUM(Attributes="Flags") enum class DrawPass : int32 { /// /// The none. /// None = 0, /// /// The hardware depth rendering to the depth buffer (used for shadow maps rendering). /// Depth = 1, /// /// The base pass rendering to the GBuffer (for opaque materials). /// API_ENUM(Attributes="EditorDisplay(name: \"GBuffer\")") GBuffer = 1 << 1, /// /// The forward pass rendering (for transparent materials). /// Forward = 1 << 2, /// /// The transparent objects distortion vectors rendering (with blending). /// Distortion = 1 << 3, /// /// The motion vectors (velocity) rendering pass (for movable objects). /// MotionVectors = 1 << 4, /// /// The Global Sign Distance Field (SDF) rendering pass. Used for software raytracing though the scene on a GPU. /// GlobalSDF = 1 << 5, /// /// The Global Surface Atlas rendering pass. Used for software raytracing though the scene on a GPU to evaluate the object surface material properties. /// GlobalSurfaceAtlas = 1 << 6, /// /// The debug quad overdraw rendering (editor-only). /// API_ENUM(Attributes="HideInEditor") QuadOverdraw = 1 << 20, /// /// The default set of draw passes for the scene objects. /// API_ENUM(Attributes="HideInEditor") Default = Depth | GBuffer | Forward | Distortion | MotionVectors | GlobalSDF | GlobalSurfaceAtlas, /// /// The all draw passes combined into a single mask. /// API_ENUM(Attributes="HideInEditor") All = Depth | GBuffer | Forward | Distortion | MotionVectors | GlobalSDF | GlobalSurfaceAtlas, }; DECLARE_ENUM_OPERATORS(DrawPass); /// /// Describes frame rendering modes. /// API_ENUM() enum class ViewMode { /// /// Full rendering /// Default = 0, /// /// Without post-process pass /// NoPostFx = 1, /// /// Draw Diffuse /// Diffuse = 2, /// /// Draw Normals /// Normals = 3, /// /// Draw Emissive /// Emissive = 4, /// /// Draw Depth /// Depth = 5, /// /// Draw Ambient Occlusion /// AmbientOcclusion = 6, /// /// Draw Material's Metalness /// Metalness = 7, /// /// Draw Material's Roughness /// Roughness = 8, /// /// Draw Material's Specular /// Specular = 9, /// /// Draw Material's Specular Color /// SpecularColor = 10, /// /// Draw Shading Model /// ShadingModel = 11, /// /// Draw Lights buffer /// LightBuffer = 12, /// /// Draw reflections buffer /// Reflections = 13, /// /// Draw scene objects in wireframe mode /// Wireframe = 14, /// /// Draw motion vectors debug view /// MotionVectors = 15, /// /// Draw materials subsurface color debug view /// SubsurfaceColor = 16, /// /// Draw materials colors with ambient occlusion /// Unlit = 17, /// /// Draw meshes lightmaps coordinates density /// LightmapUVsDensity = 18, /// /// Draw meshes vertex colors /// VertexColors = 19, /// /// Draw physics colliders debug view /// PhysicsColliders = 20, /// /// Draw Level Of Detail number as colors to debug LOD switches. /// LODPreview = 21, /// /// Draw material shaders complexity to visualize performance of pixels rendering. /// MaterialComplexity = 22, /// /// Draw geometry overdraw to visualize performance of pixels rendering. /// QuadOverdraw = 23, /// /// Draw Global Sign Distant Field (SDF) preview. /// GlobalSDF = 24, /// /// Draw Global Surface Atlas preview. /// GlobalSurfaceAtlas = 25, /// /// Draw Global Illumination debug preview (eg. irradiance probes). /// GlobalIllumination = 26, }; /// /// Frame rendering flags used to switch between graphics features. /// API_ENUM(Attributes="Flags") enum class ViewFlags : uint64 { /// /// Nothing. /// None = 0, /// /// Shows/hides the debug shapes rendered using Debug Draw. /// DebugDraw = 1, /// /// Shows/hides Editor sprites /// EditorSprites = 1 << 1, /// /// Shows/hides reflections /// Reflections = 1 << 2, /// /// Shows/hides Screen Space Reflections /// SSR = 1 << 3, /// /// Shows/hides Ambient Occlusion effect /// AO = 1 << 4, /// /// Shows/hides Global Illumination effect /// GI = 1 << 5, /// /// Shows/hides directional lights /// DirectionalLights = 1 << 6, /// /// Shows/hides point lights /// PointLights = 1 << 7, /// /// Shows/hides spot lights /// SpotLights = 1 << 8, /// /// Shows/hides sky lights /// SkyLights = 1 << 9, /// /// Shows/hides shadows /// Shadows = 1 << 10, /// /// Shows/hides specular light rendering /// SpecularLight = 1 << 11, /// /// Shows/hides Anti-Aliasing /// AntiAliasing = 1 << 12, /// /// Shows/hides custom Post-Process effects /// CustomPostProcess = 1 << 13, /// /// Shows/hides bloom effect /// Bloom = 1 << 14, /// /// Shows/hides tone mapping effect /// ToneMapping = 1 << 15, /// /// Shows/hides eye adaptation effect /// EyeAdaptation = 1 << 16, /// /// Shows/hides camera artifacts /// CameraArtifacts = 1 << 17, /// /// Shows/hides lens flares /// LensFlares = 1 << 18, /// /// Shows/hides deferred decals. /// Decals = 1 << 19, /// /// Shows/hides depth of field effect /// DepthOfField = 1 << 20, /// /// Shows/hides physics debug shapes. /// PhysicsDebug = 1 << 21, /// /// Shows/hides fogging effects. /// Fog = 1 << 22, /// /// Shows/hides the motion blur effect. /// MotionBlur = 1 << 23, /// /// Shows/hides the contact shadows effect. /// ContactShadows = 1 << 24, /// /// Shows/hides the Global Sign Distant Fields rendering. /// GlobalSDF = 1 << 25, /// /// Shows/hides the Sky/Skybox rendering. /// Sky = 1 << 26, /// /// Shows/hides light debug shapes. /// LightsDebug = 1 << 27, /// /// Default flags for Game. /// DefaultGame = Reflections | DepthOfField | Fog | Decals | MotionBlur | SSR | AO | GI | DirectionalLights | PointLights | SpotLights | SkyLights | Shadows | SpecularLight | AntiAliasing | CustomPostProcess | Bloom | ToneMapping | EyeAdaptation | CameraArtifacts | LensFlares | ContactShadows | GlobalSDF | Sky, /// /// Default flags for Editor. /// DefaultEditor = Reflections | Fog | Decals | DebugDraw | SSR | AO | GI | DirectionalLights | PointLights | SpotLights | SkyLights | Shadows | SpecularLight | AntiAliasing | CustomPostProcess | Bloom | ToneMapping | EyeAdaptation | CameraArtifacts | LensFlares | EditorSprites | ContactShadows | GlobalSDF | Sky, /// /// Default flags for materials/models previews generating. /// DefaultAssetPreview = Reflections | Decals | DirectionalLights | PointLights | SpotLights | SkyLights | SpecularLight | AntiAliasing | Bloom | ToneMapping | EyeAdaptation | CameraArtifacts | LensFlares | ContactShadows | Sky, }; DECLARE_ENUM_OPERATORS(ViewFlags); /// /// Describes the different tessellation methods supported by the graphics system. /// API_ENUM() enum class TessellationMethod { /// /// No tessellation. /// None = 0, /// /// Flat tessellation. Also known as dicing tessellation. /// Flat = 1, /// /// Point normal tessellation. /// PointNormal = 2, /// /// Geometric version of Phong normal interpolation, not applied on normals but on the vertex positions. /// Phong = 3, }; /// /// Describes the shader function flags used for shader compilation. /// enum class ShaderFlags : uint32 { /// /// The default set for flags. /// Default = 0, /// /// Hides the shader. It will exist in source and will be parsed but won't be compiled for the rendering. /// Hidden = 1, /// /// Disables any fast-math optimizations performed by the shader compiler. /// NoFastMath = 2, /// /// Indicates that vertex shader function outputs data for the geometry shader. /// VertexToGeometryShader = 4, }; DECLARE_ENUM_OPERATORS(ShaderFlags); /// /// The environment probes cubemap texture resolutions. /// API_ENUM() enum class ProbeCubemapResolution { // Graphics Settings default option. UseGraphicsSettings = 0, // Cubemap with 32x32. _32 = 32, // Cubemap with 64x64. _64 = 64, // Cubemap with 128x128. _128 = 128, // Cubemap with 256x256. _256 = 256, // Cubemap with 512x512. _512 = 512, // Cubemap with 1024x1024. _1024 = 1024, // Cubemap with 2048x2048. _2048 = 2048, };