7#include <unordered_map>
8#include <unordered_set>
53using std::unordered_map;
54using std::unordered_set;
233 vector<ObjectParticleSystem*>
opses;
235 vector<ParticleSystemGroup*>
psgs;
494 const vector<Entity*>& entities,
495 DecomposedEntities& decomposedEntities,
496 bool decomposeAllEntities =
false
536 void resetLists(DecomposedEntities& decomposedEntites);
737 return uniqueShaderId;
739 return uniqueShaderIdIt->second;
755 static void registerShader(
ShaderType type,
const string& shaderId,
const map<string, ShaderParameter>& parameterDefaults = {});
771 auto shaderIt =
shaders.find(shaderId);
772 if (shaderIt ==
shaders.end()) {
773 Console::println(
"Engine::getDefaultShaderParameter(): no shader registered with id: " + shaderId);
776 auto& shader = shaderIt->second;
777 auto shaderParameterIt = shader.parameterDefaults.find(parameterName);
778 if (shaderParameterIt == shader.parameterDefaults.end()) {
779 Console::println(
"Engine::getDefaultShaderParameter(): no default for shader registered with id: " + shaderId +
", and parameter name: " + parameterName);
782 auto& shaderParameter = shaderParameterIt->second;
783 return shaderParameter;
797 auto& shaderParameterMap = shaderParameterIt->second;
798 auto shaderParameterParameterIt = shaderParameterMap.find(parameterName);
799 if (shaderParameterParameterIt == shaderParameterMap.end()) {
802 auto& shaderParameter = shaderParameterParameterIt->second;
803 return shaderParameter;
815 Console::println(
"Engine::setShaderParameter(): no parameter for shader registered with id: " + shaderId +
", and parameter name: " + parameterName);
818 if (currentShaderParameter.getType() != parameterValue.
getType()) {
819 Console::println(
"Engine::setShaderParameter(): parameter type mismatch for shader registered with id: " + shaderId +
", and parameter name: " + parameterName);
984 return entityByIdIt->second;
1077 particleSystemEntity
1150 bool makeScreenshot(
const string& pathName,
const string& fileName,
bool removeAlphaChannel =
true);
1204 DecomposedEntities& decomposedEntities,
1209 Node** object3DNode =
nullptr,
1224 DecomposedEntities& decomposedEntities,
1250 void doPostProcessing(PostProcessingProgram::RenderPass renderPass,
const array<FrameBuffer*, 2> postProcessingFrameBuffers,
FrameBuffer* targetFrameBuffer);
1267 void render(
FrameBuffer* renderFrameBuffer,
GeometryBuffer* renderGeometryBuffer, DecomposedEntities&
visibleDecomposedEntities, int32_t effectPass, int32_t renderPassMask,
const string& shaderPrefix,
bool useEZR,
bool applyShadowMapping,
bool applyPostProcessing,
bool doRenderLightSource,
bool doRenderParticleSystems, int32_t renderTypes);
Application base class, please make sure to allocate application on heap to have correct application ...
EngineThreadQueueElementPool()
Public constructor.
EngineThreadQueueElement * instantiate() override
Instantiate a transparent render face.
volatile int getProcessedElements()
TransparentRenderFacesPool * transparentRenderFacesPool
Queue< EngineThreadQueueElement > * queue
unordered_map< uint8_t, unordered_map< Model *, vector< Object3D * > > > objectsByShadersAndModels
void resetProcessedElements()
Reset processed element count.
volatile int elementsProcessed
TransparentRenderFacesPool * getTransparentRenderFacesPool()
EngineThread(int idx, Queue< EngineThreadQueueElement > *queue)
Constructor.
static void setShadowMapRenderLookUps(int32_t shadowMapRenderLookUps)
Set shadowmap look ups for each pixel when rendering.
static STATIC_DLL_IMPEXT Engine * currentEngine
bool renderLightSources(int width, int height)
Render light sources.
static FrameBufferRenderShader * getFrameBufferRenderShader()
void dumpShaders()
Print registered shaders and it default parameters to console.
bool removeEntity(const string &id)
Removes an entity.
static STATIC_DLL_IMPEXT MeshManager * meshManager
FrameBuffer * getFrameBuffer()
unordered_set< Entity * > needsPreRenderEntities
Renderer::RendererType getGraphicsRendererType()
bool renderingComputedTransformations
static STATIC_DLL_IMPEXT Renderer * renderer
map< string, map< string, ShaderParameter > > shaderParameters
static STATIC_DLL_IMPEXT EZRShader * ezrShader
static STATIC_DLL_IMPEXT int32_t environmentMappingWidth
static STATIC_DLL_IMPEXT TextureManager * textureManager
static STATIC_DLL_IMPEXT Queue< EngineThreadQueueElement > * engineThreadsQueue
void initRendering()
Initiates the rendering process updates timing, updates camera.
static STATIC_DLL_IMPEXT int32_t shadowMapHeight
void doPostProcessing(PostProcessingProgram::RenderPass renderPass, const array< FrameBuffer *, 2 > postProcessingFrameBuffers, FrameBuffer *targetFrameBuffer)
Do post processing.
void reshape(int32_t width, int32_t height)
Reshape.
void display()
Renders the scene.
static GUIShader * getGUIShader()
static STATIC_DLL_IMPEXT LightingShader * lightingShader
static STATIC_DLL_IMPEXT vector< EngineThread * > engineThreads
Partition * getPartition()
static SkinningShader * getSkinningShader()
void initialize()
Initialize render engine.
bool makeScreenshot(const string &pathName, const string &fileName, bool removeAlphaChannel=true)
Creates a PNG file from current screen( This does not seem to work with GLES2 and offscreen engines.
static ShadowMapRenderShader * getShadowMapRenderShader()
static MeshManager * getMeshManager()
static STATIC_DLL_IMPEXT int32_t shadowMapRenderLookUps
static STATIC_DLL_IMPEXT int threadCount
static const vector< string > getRegisteredShader(ShaderType type)
Returns registered shaders for given type.
static void setEnvironmentMappingSize(int32_t width, int32_t height)
Set environment mapping size.
void computeTransformationsFunction(vector< Object3D * > &objects, int threadIdx)
Computes visibility and transformations.
array< Light, LIGHTS_MAX > lights
GeometryBuffer * geometryBuffer
Light * getLightAt(int32_t idx)
Returns light at idx (0 <= idx < 8)
void render(FrameBuffer *renderFrameBuffer, GeometryBuffer *renderGeometryBuffer, DecomposedEntities &visibleDecomposedEntities, int32_t effectPass, int32_t renderPassMask, const string &shaderPrefix, bool useEZR, bool applyShadowMapping, bool applyPostProcessing, bool doRenderLightSource, bool doRenderParticleSystems, int32_t renderTypes)
Do a render/effect pass.
void setShaderParameter(const string &shaderId, const string ¶meterName, const ShaderParameter ¶meterValue)
Set shader parameter for given shader id and parameter name.
static STATIC_DLL_IMPEXT float transformationsComputingReduction2Distance
void enqueueAction(Action *action)
Add action to action queue to be executed before next engine update.
static STATIC_DLL_IMPEXT bool skinningShaderEnabled
unordered_set< Entity * > noFrustumCullingEntities
void decomposeEntityTypes(const vector< Entity * > &entities, DecomposedEntities &decomposedEntities, bool decomposeAllEntities=false)
Decompose entity types.
Vector3 computeWorldCoordinateByMousePosition(int32_t mouseX, int32_t mouseY, float z)
Compute world coordinate from mouse position and z value.
static STATIC_DLL_IMPEXT int32_t environmentMappingHeight
void setPartition(Partition *partition)
Set partition.
static STATIC_DLL_IMPEXT float transformationsComputingReduction1Distance
void addPostProcessingProgram(const string &programId)
Add post processing program.
Entity * getEntityContactPointByMousePosition(int32_t mouseX, int32_t mouseY, EntityPickingFilter *filter)
Retrieves object by mouse position.
static STATIC_DLL_IMPEXT AnimationProcessingTarget animationProcessingTarget
static float getTransformationsComputingReduction2Distance()
void doneGUIMode()
Set up GUI mode rendering.
void initGUIMode()
Set up GUI mode rendering.
static void setAnimationBlendingTime(float animationBlendingTime)
Set animation blending time.
void decomposeEntityType(Entity *entity, DecomposedEntities &decomposedEntities, bool decomposeAllEntities=false)
Decompose entity type.
Renderer::Renderer_Statistics getRendererStatistics()
static STATIC_DLL_IMPEXT ShadowMapRenderShader * shadowMappingShaderRender
@ SHADERTYPE_POSTPROCESSING
static void registerShader(ShaderType type, const string &shaderId, const map< string, ShaderParameter > ¶meterDefaults={})
Register shader.
FrameBuffer * postProcessingFrameBuffer1
static STATIC_DLL_IMPEXT LinesShader * linesShader
void removeFromDecomposedEntities(DecomposedEntities &decomposedEntities, Entity *entity)
Remove entity from decomposed entities.
ShadowMapping * getShadowMapping()
static STATIC_DLL_IMPEXT GUIShader * guiShader
static STATIC_DLL_IMPEXT ParticlesShader * particlesShader
@ EFFECTPASS_LIGHTSCATTERING
static Engine * createOffScreenInstance(int32_t width, int32_t height, bool enableShadowMapping, bool enableDepthBuffer, bool enableGeometryBuffer)
Creates an offscreen rendering instance Note:
Entity * getEntityByMousePosition(int32_t mouseX, int32_t mouseY, EntityPickingFilter *filter=nullptr, Node **object3DNode=nullptr, ParticleSystemEntity **particleSystemEntity=nullptr)
Retrieves entity by mouse position.
FrameBuffer * postProcessingTemporaryFrameBuffer
static STATIC_DLL_IMPEXT PostProcessingShader * postProcessingShader
void scale(int32_t width, int32_t height)
Scale which applies to main engine only.
static STATIC_DLL_IMPEXT unordered_map< string, uint8_t > uniqueShaderIds
static STATIC_DLL_IMPEXT Texture2DRenderShader * texture2DRenderShader
static constexpr int ENGINETHREADSQUEUE_COMPUTE_DISPATCH_COUNT
static TextureManager * getTextureManager()
bool shadowMappingEnabled
static int32_t getShadowMapWidth()
static const map< string, ShaderParameter > getShaderParameterDefaults(const string &shaderId)
Returns parameter defaults of shader with given id.
AnimationProcessingTarget
static STATIC_DLL_IMPEXT map< string, Shader > shaders
static void setTransformationsComputingReduction2Distance(float transformationsComputingReduction2Distance)
Set distance of animated object including skinned objects from camera which animation computation wil...
Engine()
Private constructor.
static ShadowMapCreationShader * getShadowMapCreationShader()
static LightingShader * getLightingShader()
void renderToScreen()
Render scaled main engine to screen.
static STATIC_DLL_IMPEXT DeferredLightingRenderShader * deferredLightingRenderShader
void setShadowMapLightEyeDistanceScale(float shadowMapLightEyeDistanceScale)
Set shadow map light eye distance scale.
static STATIC_DLL_IMPEXT PostProcessing * postProcessing
const string getGraphicsRenderer()
array< bool, EFFECTPASS_COUNT - 1 > effectPassSkip
EntityRenderer * entityRenderer
ShadowMapping * shadowMapping
static int32_t getShadowMapHeight()
static void setThreadCount(int threadCount)
Set engine thread count.
unordered_map< string, Entity * > entitiesById
void addEntity(Entity *entity)
Adds an entity by id.
static void setTransformationsComputingReduction1Distance(float transformationsComputingReduction1Distance)
Set distance of animated object including skinned objects from camera which animation computation wil...
const ShaderParameter getShaderParameter(const string &shaderId, const string ¶meterName)
Returns shader parameter for given shader id and parameter name, if the value does not exist,...
bool computeScreenCoordinateByWorldCoordinate(const Vector3 &worldCoordinate, Vector2 &screenCoordinate, int width=-1, int height=-1)
Convert screen coordinate by world coordinate.
static STATIC_DLL_IMPEXT SkinningShader * skinningShader
static STATIC_DLL_IMPEXT Engine * instance
static LinesShader * getLinesShader()
vector< string > postProcessingPrograms
static const ShaderParameter getDefaultShaderParameter(const string &shaderId, const string ¶meterName)
Returns shader parameter default value for given shader id and parameter name.
void resetPostProcessingPrograms()
Clear post processing programs.
void deregisterEntity(Entity *entity)
Removes a entity from internal lists, those entities can also be sub entities from entity hierarchy o...
void dispose()
Shutdown the engine.
void preRenderFunction(vector< Object3D * > &objects, int threadIdx)
Update vertex buffers and such before rendering.
static STATIC_DLL_IMPEXT EngineThreadQueueElementPool engineThreadQueueElementPool
EntityRenderer * getEntityRenderer()
static int32_t getShadowMapRenderLookUps()
static STATIC_DLL_IMPEXT FrameBufferRenderShader * frameBufferRenderShader
static int getThreadCount()
static void set4K(bool have4K)
Set if having 4k.
float shadowMapLightEyeDistanceScale
float getShadowMapLightEyeDistanceScale()
static STATIC_DLL_IMPEXT float animationBlendingTime
Entity * getEntity(const string &id)
Returns a entity by given id.
const string getGraphicsVendor()
static STATIC_DLL_IMPEXT ShadowMapCreationShader * shadowMappingShaderPre
static PostProcessingShader * getPostProcessingShader()
static STATIC_DLL_IMPEXT bool have4K
const Color4 & getSceneColor() const
void unscale()
Disable scaling, which applies to main engine only.
static void setShadowMapSize(int32_t width, int32_t height)
Set shadow map size.
unordered_set< Entity * > autoEmitParticleSystemEntities
static constexpr int LIGHTS_MAX
void reset()
Removes all entities and caches.
FrameBuffer * postProcessingFrameBuffer2
static float getAnimationBlendingTime()
static int32_t getEnvironmentMappingWidth()
void setSceneColor(const Color4 &sceneColor)
Set scene color.
static float getTransformationsComputingReduction1Distance()
static STATIC_DLL_IMPEXT VBOManager * vboManager
static constexpr int ENGINETHREADSQUEUE_PRERENDER_DISPATCH_COUNT
vector< Action * > actions
GeometryBuffer * getGeometryBuffer()
static Engine * getInstance()
Returns engine instance.
static STATIC_DLL_IMPEXT int32_t shadowMapWidth
void computeTransformations(Camera *camera, DecomposedEntities &decomposedEntites, bool autoEmit, bool computeTransformations)
Computes visibility and transformations.
static ParticlesShader * getParticlesShader()
static DeferredLightingRenderShader * getDeferredLightingRenderShader()
static int32_t getEnvironmentMappingHeight()
static STATIC_DLL_IMPEXT GUIRenderer * guiRenderer
FrameBuffer * frameBuffer
void removeEntityFromLists(Entity *entity)
Remove entity.
unordered_set< Entity * > needsComputeTransformationsEntities
static VBOManager * getVBOManager()
bool isUsingPostProcessingTemporaryFrameBuffer
DecomposedEntities visibleDecomposedEntities
void resetLists(DecomposedEntities &decomposedEntites)
Reset lists.
static uint8_t getUniqueShaderId(const string &shaderId)
void registerEntity(Entity *entity)
Adds a entity to internal lists, those entities can also be sub entities from entity hierarchy or par...
Entity * doRayCasting(const Vector3 &startPoint, const Vector3 &endPoint, Vector3 &contactPoint, EntityPickingFilter *filter=nullptr)
Does a ray casting of visible 3d object based entities.
int32_t getScaledHeight()
static constexpr int ENGINETHREADSQUEUE_RENDER_DISPATCH_COUNT
array< FrameBuffer *, EFFECTPASS_COUNT - 1 > effectPassFrameBuffers
Entity hierarchy to be used with engine class.
Environment mapping entity.
Fog particle system entity to be used with engine class.
Imposter object 3d to be used with engine class.
LOD object 3D + imposter to be used with engine class.
LOD object 3D to be used with engine class.
Object 3D to be used with engine class.
Object 3D render group for static objects that might be animated by shaders.
Object 3D to be used with engine class.
Object particle system entity to be used with engine class.
Particle system group, which combines several particle systems into a group, to be used with engine c...
Point particle system entity to be used with engine class.
Shader parameter model class.
Representation of a 3d model.
Early z rejection shader.
Deferred lighint render shader.
Frame buffer render shader.
Interface to lighting shader program.
Particles shader program.
Engine connector of GL2 renderer to other engine functionality.
Engine connector of GL3 renderer to other engine functionality.
Engine connector of GLES2 renderer to other engine functionality.
Engine connector of VK renderer to other engine functionality.
RendererType getRendererType()
virtual const Renderer_Statistics getStatistics()=0
Batch renderer for points.
Batch renderer for transparent triangles.
Object 3D node mesh specifically for rendering.
Object 3D node VBO renderer.
Object 3d node specifically for rendering.
Buffers used to transfer data between main memory to graphics board memory.
Transparent render faces group.
Transparent render faces pool.
Shadow mapping shader to create a shadow map.
Shadow mapping shader to render shadow maps.
Interface to compute shader skinning shader program.
Texture 2D render shader.
GUI Font A font implementation that will parse the output of the AngelCode font tool available at:
vector< Object3D * > needsComputeTransformationsEntities
vector< LODObject3D * > lodObjects
vector< Object3D * > objectsPostPostProcessing
vector< EntityHierarchy * > entityHierarchies
vector< LODObject3DImposter * > lodObjectsImposter
vector< LinesObject3D * > linesObjects
vector< Object3D * > objectsForwardShading
vector< EnvironmentMapping * > environmentMappingEntities
vector< ParticleSystemGroup * > psgs
vector< Object3D * > ezrObjects
vector< ObjectParticleSystem * > opses
vector< Object3DRenderGroup * > objectRenderGroups
vector< Object3D * > objects
vector< Object3D * > needsPreRenderEntities
vector< Entity * > noFrustumCullingEntities
vector< Object3D * > objectsNoDepthTest
Entity::RenderPass renderPass
bool computeTransformations
struct tdme::engine::Engine::EngineThreadQueueElement::@0 transformations
bool collectTransparentFaces
vector< Object3D * > objects
struct tdme::engine::Engine::EngineThreadQueueElement::@1 rendering
map< string, ShaderParameter > parameterDefaults
Particle system entity interface.
Entity renderer parameters.
#define STATIC_DLL_IMPEXT