summaryrefslogtreecommitdiffstats
path: root/src/render/backend/renderview_p.h
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-11-23 15:27:48 +0100
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-11-26 17:36:04 +0000
commit653fdeb073a525a676bf0c12511c3f74bad2095e (patch)
tree9c4e2f2f29e63a12a0a0f7799235cad9b71c738e /src/render/backend/renderview_p.h
parent1324668b1b77c865c90a1352a61b0b3da3da39b1 (diff)
Lights phase 1: infrastructure
QAbstractLight becomes QLight and gets its own backend node. This way we can easily gather all lights for the scene and filter them when building render commands. Both the frontend and backend remain a subclass of (Q)ShaderData but will not be part of the ordinary ShaderData component list. This prevents mixing up ShaderDatas and Lights but allows reusing the same underlying infrastructure so that properties can automatically be transformed for example. It is worth noting that the position property for lights is now removed: the position is determined by the entity's (to which the light component belongs) position. A number of changes are made to ShaderData itself as backend subclassing with different managers is not straightforward. For now the distance between the rendered entity and the entity with the light component is calculated and lights will be chosen based on this distance. A framegraph node for controlling this will be added in future patches. No uniform setting or shader changes are included here. Task-number: QTBUG-48834 Change-Id: I43a6c5f9420d4254d798c558bd58680b2b09eceb Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/backend/renderview_p.h')
-rw-r--r--src/render/backend/renderview_p.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/render/backend/renderview_p.h b/src/render/backend/renderview_p.h
index bb324baf5..874b22b83 100644
--- a/src/render/backend/renderview_p.h
+++ b/src/render/backend/renderview_p.h
@@ -210,6 +210,7 @@ public:
void buildRenderCommands(Entity *preprocessedTreeRoot, const Plane *planes);
QVector<RenderCommand *> commands() const { return m_commands; }
+ void gatherLights(Entity *preprocessedTreeRoot);
void addRenderAttachment(Attachment attachment) { m_attachmentPack.addAttachment(attachment); }
void setDrawBuffers(const QList<QRenderAttachment::RenderAttachmentType> &drawBuffers) { m_attachmentPack.setDrawBuffers(drawBuffers); }
@@ -242,8 +243,17 @@ public:
UniformBlockValueBuilder m_uniformBlockBuilder;
};
+ struct LightSource {
+ LightSource() : entity(Q_NULLPTR), light(Q_NULLPTR) { }
+ LightSource(Entity *entity, Light *light)
+ : entity(entity), light(light) { }
+ Entity *entity;
+ Light *light;
+ };
+
private:
- void setShaderAndUniforms(RenderCommand *command, RenderPass *pass, ParameterInfoList &parameters, const QMatrix4x4 &worldTransform);
+ void setShaderAndUniforms(RenderCommand *command, RenderPass *pass, ParameterInfoList &parameters, const QMatrix4x4 &worldTransform,
+ const QVector<LightSource> &activeLightSources);
Renderer *m_renderer;
NodeManagers *m_manager;
@@ -266,6 +276,8 @@ private:
// the render thread is submitting these commands.
QVector<RenderCommand *> m_commands;
+ QVector<LightSource> m_lightSources;
+
typedef QHash<QString, QUniformValue* (RenderView::*)(const QMatrix4x4& model) const> StandardUniformsPFuncsHash;
static StandardUniformsPFuncsHash ms_standardUniformSetters;
static StandardUniformsPFuncsHash initializeStandardUniformSetters();