Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions engine/includes/commandbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,6 @@ struct Global {
class ENGINE_EXPORT CommandBuffer: public Object {
A_OBJECT(CommandBuffer, Object, System)

public:
enum LayerTypes {
DEFAULT = (1<<0),
RAYCAST = (1<<1),
SHADOWCAST = (1<<2),
LIGHT = (1<<3),
TRANSLUCENT = (1<<4),
UI = (1<<6)
};

public:
CommandBuffer();

Expand Down
5 changes: 0 additions & 5 deletions engine/includes/components/actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ class ENGINE_EXPORT Actor : public Object {
bool isStatic() const;
void setStatic(const bool flag);

int layers() const;
void setLayers(const int layers);

void setParent(Object *parent, int32_t position = -1, bool force = false) override;

bool isInstance() const;
Expand Down Expand Up @@ -116,8 +113,6 @@ class ENGINE_EXPORT Actor : public Object {

Scene *m_scene;

int32_t m_layers;

int m_flags;

bool m_hierarchyEnable;
Expand Down
2 changes: 1 addition & 1 deletion engine/includes/components/effectrender.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ENGINE_EXPORT EffectRender : public Renderable {
private:
AABBox localBound() const override;

Mesh *meshToDraw() const override;
Mesh *meshToDraw(int instance) const override;

void update() override;

Expand Down
4 changes: 1 addition & 3 deletions engine/includes/components/meshrender.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ class ENGINE_EXPORT MeshRender : public Renderable {

AABBox localBound() const override;

Mesh *meshToDraw() const override;

void composeComponent() override;
Mesh *meshToDraw(int instance) const override;

void setProperty(const char *name, const Variant &value) override;

Expand Down
12 changes: 6 additions & 6 deletions engine/includes/components/renderable.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,27 @@ class ENGINE_EXPORT Renderable : public NativeBehaviour {

virtual AABBox bound() const;

virtual int priority() const;

Material *material() const;
virtual void setMaterial(Material *material);

MaterialInstance *materialInstance() const;
int32_t materialsCount() const;
MaterialInstance *materialInstance(int index) const;

protected:
virtual Mesh *meshToDraw() const;
virtual Mesh *meshToDraw(int instance) const;

virtual uint32_t subMesh(int instance) const;

virtual AABBox localBound() const;

virtual void setMaterialsList(const std::list<Material *> &materials);

private:
uint32_t instanceHash(int index) const;

void setSystem(ObjectSystem *system) override;

protected:
friend class PipelineContext;
friend class PipelineTask;

std::vector<MaterialInstance *> m_materials;

Expand Down
2 changes: 0 additions & 2 deletions engine/includes/components/skinnedmeshrender.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ class ENGINE_EXPORT SkinnedMeshRender : public MeshRender {

AABBox localBound() const override;

void setMaterial(Material *material) override;

void onReferenceDestroyed() override;

private:
Expand Down
6 changes: 2 additions & 4 deletions engine/includes/components/spriterender.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,14 @@ class ENGINE_EXPORT SpriteRender : public Renderable {
static Mesh *composeMesh(Sprite *sprite, int key, Vector2 &size, int mode, bool resetSize, float scale = 1.0f);

private:
Mesh *meshToDraw() const override;
Mesh *meshToDraw(int instance) const override;

void setMaterialsList(const std::list<Material *> &materials) override;

AABBox localBound() const override;

void composeComponent() override;

int priority() const override;

void composeMesh(bool resetSize = false);

static bool composeSliced(Mesh *mesh, Vector2 &size, Vector3 &delta, float scale);
Expand All @@ -101,7 +99,7 @@ class ENGINE_EXPORT SpriteRender : public Renderable {

int m_drawMode;

int m_layer;
int m_priority;

};

Expand Down
2 changes: 1 addition & 1 deletion engine/includes/components/textrender.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ENGINE_EXPORT TextRender : public Renderable {
static Vector2 cursorPosition(Font *font, int size, const TString &text, bool kerning, const Vector2 &boundaries);

private:
Mesh *meshToDraw() const override;
Mesh *meshToDraw(int instance) const override;

AABBox localBound() const override;

Expand Down
7 changes: 2 additions & 5 deletions engine/includes/components/tilemaprender.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,16 @@ class ENGINE_EXPORT TileMapRender : public Renderable {
private:
AABBox localBound() const override;

Mesh *meshToDraw() const override;
Mesh *meshToDraw(int instance) const override;

void setMaterialsList(const std::list<Material *> &materials) override;

void composeComponent() override;

int priority() const override;

private:
TileMap *m_tileMap;

int m_layer;

int m_priority;
};

#endif // TILEMAPRENDER_H
2 changes: 1 addition & 1 deletion engine/includes/editor/viewport/tasks/debugrender.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class DebugRender : public PipelineTask {
}
it.second->setTransform(m);

buffer->drawMesh(m_mesh, 0, CommandBuffer::UI, *it.second);
buffer->drawMesh(m_mesh, 0, Material::Opaque, *it.second);
i++;
}

Expand Down
4 changes: 2 additions & 2 deletions engine/includes/editor/viewport/tasks/gizmorender.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ class GizmoRender : public PipelineTask {

buffer->setViewport(m_width-gNaviCubeSize, m_height-gNaviCubeSize, gNaviCubeSize, gNaviCubeSize);
buffer->setViewProjection(m_camera->viewMatrix(), m_camera->projectionMatrix());
buffer->drawMesh(PipelineContext::defaultCube(), 0, CommandBuffer::UI, *m_cubeMaterial);
buffer->drawMesh(PipelineContext::defaultCube(), 0, Material::Opaque, *m_cubeMaterial);

if(m_side != -1) {
buffer->drawMesh(m_solidCube, m_side, CommandBuffer::UI, *m_solidMaterial);
buffer->drawMesh(m_solidCube, m_side, Material::Opaque, *m_solidMaterial);
}

buffer->setViewport(0, 0, m_width, m_height);
Expand Down
2 changes: 1 addition & 1 deletion engine/includes/editor/viewport/tasks/gridrender.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class GridRender : public PipelineTask {
buffer->beginDebugMarker("GridRender");

buffer->setRenderTarget(m_resultTarget);
buffer->drawMesh(m_plane, 0, CommandBuffer::TRANSLUCENT, *m_grid);
buffer->drawMesh(m_plane, 0, Material::Translucent, *m_grid);

buffer->endDebugMarker();
}
Expand Down
33 changes: 22 additions & 11 deletions engine/includes/editor/viewport/tasks/outlinerender.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,13 @@ class Outline : public PipelineTask {
buffer->beginDebugMarker("Outline");

buffer->setRenderTarget(m_outlineTarget);
RenderList filter;
for(auto actor : m_controller->selected()) {
for(auto it : m_context->culledComponents()) {
Renderable *component = dynamic_cast<Renderable *>(it);
if(component && component->actor()->isInHierarchy(static_cast<Actor *>(actor))) {
filter.push_back(component);
}
}

for(auto &it : m_outline) {
buffer->drawMesh(it.mesh, it.subMesh, Material::Visibility, *it.instance);
}
m_context->drawRenderers(filter, CommandBuffer::RAYCAST);

buffer->setRenderTarget(m_resultTarget);
buffer->drawMesh(PipelineContext::defaultPlane(), 0, CommandBuffer::UI, *m_combineMaterial);
buffer->drawMesh(PipelineContext::defaultPlane(), 0, Material::Opaque, *m_combineMaterial);

buffer->endDebugMarker();
}
Expand All @@ -113,10 +107,25 @@ class Outline : public PipelineTask {
PipelineTask::resize(width, height);
}

void analyze(World *world) override {
RenderList outline;

for(auto actor : m_controller->selected()) {
for(auto it : m_context->culledRenderables()) {
if(it->actor()->isInHierarchy(static_cast<Actor *>(actor))) {
outline.push_back(it);
}
}
}

m_outline.clear();
filterByLayer(outline, m_outline, Material::Visibility);
}

protected:
Vector4 m_color;

float m_width;
GroupList m_outline;

Texture *m_outlineMap;
Texture *m_outlineDepth;
Expand All @@ -128,6 +137,8 @@ class Outline : public PipelineTask {

CameraController *m_controller;

float m_width;

};

#endif // OUTLINERENDER_H
18 changes: 8 additions & 10 deletions engine/includes/pipelinecontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class InstancingBatch;
class Frustum;

typedef std::list<Renderable *> RenderList;
typedef std::list<BaseLight *> LightList;

class ENGINE_EXPORT PipelineContext : public Object {
A_OBJECT(PipelineContext, Object, System)
Expand All @@ -44,8 +45,6 @@ class ENGINE_EXPORT PipelineContext : public Object {

void cameraReset();

void drawRenderers(const RenderList &list, uint32_t layer, uint32_t flags = 0);

World *world();
void setWorld(World *world);

Expand All @@ -59,9 +58,10 @@ class ENGINE_EXPORT PipelineContext : public Object {

StringList renderTextures() const;

RenderList &sceneComponents();
RenderList &culledComponents();
std::list<BaseLight *> &sceneLights();
RenderList &sceneRenderables();
RenderList &culledRenderables();

LightList &sceneLights();

std::list<std::pair<const PostProcessSettings *, float> > &culledPostEffectSettings();

Expand Down Expand Up @@ -103,10 +103,10 @@ class ENGINE_EXPORT PipelineContext : public Object {

AABBox m_worldBound;

RenderList m_sceneComponents;
RenderList m_culledComponents;
RenderList m_sceneRenderables;
RenderList m_culledRenderables;

std::list<BaseLight *> m_sceneLights;
LightList m_sceneLights;

std::list<std::pair<const PostProcessSettings *, float>> m_culledPostProcessSettings;

Expand All @@ -131,8 +131,6 @@ class ENGINE_EXPORT PipelineContext : public Object {

bool m_frustumCulling;

bool m_renderablesSorting;

};

#endif // PIPELINECONTEXT
21 changes: 19 additions & 2 deletions engine/includes/pipelinetask.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@

#include <stdint.h>

#include <pipelinecontext.h>
#include <engine.h>

class Texture;
class PipelineContext;
class PostProcessSettings;

class ENGINE_EXPORT PipelineTask : public Object {
A_OBJECT(PipelineTask, Object, System)
Expand All @@ -34,6 +33,24 @@ class ENGINE_EXPORT PipelineTask : public Object {
void setEnabled(bool enable);
bool isEnabled() const;

protected:
struct Group {
MaterialInstance *instance = nullptr;

Mesh *mesh = nullptr;

uint32_t subMesh = 0;

uint32_t hash = 0;

ByteArray buffer;
};
typedef std::list<Group> GroupList;

void filterByLayer(const RenderList &in, GroupList &out, int layer) const;

void group(const GroupList &in, GroupList &out) const;

protected:
std::vector<TString> m_inputs;
std::vector<std::pair<TString, Texture *>> m_outputs;
Expand Down
4 changes: 4 additions & 0 deletions engine/includes/pipelinetasks/gbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ class GBuffer : public PipelineTask {
private:
void exec() override;

void analyze(World *world) override;

private:
GroupList m_opaque;

RenderTarget *m_gbuffer;

};
Expand Down
10 changes: 5 additions & 5 deletions engine/includes/pipelinetasks/shadowmap.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef SHADOWMAP_H
#define SHADOWMAP_H

#include "pipelinecontext.h"
#include "pipelinetask.h"

class CommandBuffer;
Expand All @@ -14,7 +15,6 @@ class AreaLight;
class DirectLight;
class SpotLight;
class PointLight;
class Renderable;

class ShadowMap : public PipelineTask {
A_OBJECT(ShadowMap, PipelineTask, Pipeline)
Expand All @@ -25,10 +25,10 @@ class ShadowMap : public PipelineTask {
private:
void exec() override;

void areaLightUpdate(AreaLight *light, std::list<Renderable *> &components);
void directLightUpdate(DirectLight *light, std::list<Renderable *> &components);
void pointLightUpdate(PointLight *light, std::list<Renderable *> &components);
void spotLightUpdate(SpotLight *light, std::list<Renderable *> &components);
void areaLightUpdate(AreaLight *light, const RenderList &components);
void directLightUpdate(DirectLight *light, const RenderList &components);
void pointLightUpdate(PointLight *light, const RenderList &components);
void spotLightUpdate(SpotLight *light, const RenderList &components);

void cleanShadowCache();

Expand Down
4 changes: 4 additions & 0 deletions engine/includes/pipelinetasks/translucent.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ class Translucent : public PipelineTask {
private:
void exec() override;

void analyze(World *world) override;

void setInput(int index, Texture *texture) override;

private:
GroupList m_translucent;

RenderTarget *m_translucentPass;

};
Expand Down
Loading
Loading