Now render water through it's own buffer. Not currently visable through finaltexture. Also added a white texture to render the water.
This commit is contained in:
+16
-4
@@ -347,8 +347,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Add LightLoadShit
|
||||
|
||||
auto pointLightComponent = m_World->GetComponent<Components::PointLight>(entity);
|
||||
if (pointLightComponent)
|
||||
{
|
||||
@@ -359,6 +357,19 @@ public:
|
||||
pointLightComponent->Radius);
|
||||
}
|
||||
|
||||
auto parent = m_World->GetEntityParent(entity);
|
||||
if(parent != 0) {
|
||||
auto waterParticleComponent = m_World->GetComponent<Components::WaterVolume>(parent);
|
||||
if (waterParticleComponent) {
|
||||
//TODO: Remove hardcoded color.
|
||||
//TODO: Do i even need modelMatrix?
|
||||
Components::Transform absoluteTransform = m_TransformSystem->AbsoluteTransform(entity);
|
||||
glm::mat4 modelMatrix = glm::translate(absoluteTransform.Position)
|
||||
* glm::scale(absoluteTransform.Scale);
|
||||
EnqueueWaterParticles(absoluteTransform.Position, glm::vec4(1.f, 1.f, 1.f, 1.f), modelMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
auto spriteComponent = m_World->GetComponent<Components::Sprite>(entity);
|
||||
if (spriteComponent)
|
||||
@@ -440,13 +451,14 @@ public:
|
||||
|
||||
}
|
||||
|
||||
void EnqueueWaterParticles(glm::vec3 position, glm::vec4 color)
|
||||
void EnqueueWaterParticles(glm::vec3 position, glm::vec4 color, glm::mat4 modelMatrix)
|
||||
{
|
||||
WaterParticleJob job;
|
||||
job.Position = position;
|
||||
job.Color = color;
|
||||
job.ModelMatrix = modelMatrix;
|
||||
|
||||
m_RendererQueue.Deferred.Add(job);
|
||||
m_RendererQueue.Water.Add(job);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -119,6 +119,12 @@ struct WaterParticleJob : RenderJob
|
||||
{
|
||||
glm::vec3 Position;
|
||||
glm::vec4 Color;
|
||||
glm::mat4 ModelMatrix;
|
||||
|
||||
void CalculateHash() override
|
||||
{
|
||||
Hash = 0;
|
||||
}
|
||||
};
|
||||
|
||||
class RenderQueue
|
||||
@@ -129,6 +135,7 @@ public:
|
||||
{
|
||||
job.CalculateHash();
|
||||
Jobs.push_front(std::shared_ptr<T>(new T(job)));
|
||||
m_Size++;
|
||||
}
|
||||
|
||||
void Sort()
|
||||
@@ -139,8 +146,11 @@ public:
|
||||
void Clear()
|
||||
{
|
||||
Jobs.clear();
|
||||
m_Size = 0;
|
||||
}
|
||||
|
||||
int Size() const { return m_Size; }
|
||||
|
||||
std::forward_list<std::shared_ptr<RenderJob>>::const_iterator begin()
|
||||
{
|
||||
return Jobs.begin();
|
||||
@@ -152,6 +162,9 @@ public:
|
||||
}
|
||||
|
||||
std::forward_list<std::shared_ptr<RenderJob>> Jobs;
|
||||
|
||||
private:
|
||||
int m_Size = 0;
|
||||
};
|
||||
|
||||
struct RenderQueueCollection
|
||||
|
||||
@@ -79,6 +79,7 @@ private:
|
||||
Model* m_UnitQuad = nullptr;
|
||||
Texture* m_StandardNormal;
|
||||
Texture* m_StandardSpecular;
|
||||
Texture* t_m_WhiteSphereTexture;
|
||||
|
||||
GLuint m_rbDepthBuffer = 0;
|
||||
GLuint m_fbDeferred1 = 0;
|
||||
@@ -90,21 +91,23 @@ private:
|
||||
GLuint m_tLighting = 0;
|
||||
GLuint m_fbDeferred3 = 0;
|
||||
GLuint m_tFinal = 0;
|
||||
//Water "Diffuse" texture
|
||||
GLuint t_m_GWater = 0;
|
||||
//Water GTexture
|
||||
GLuint t_m_Gwater = 0;
|
||||
//Water blur texture
|
||||
GLuint t_m_tWater;
|
||||
//WAterpass Framebuffer
|
||||
GLuint t_m_fbWater;
|
||||
|
||||
|
||||
GLuint m_CurrentScreenBuffer = 0;
|
||||
void LoadShaders();
|
||||
void CreateBuffers();
|
||||
GLuint CreateQuad();
|
||||
GLuint CreateWaterParticleVAO(RenderQueue &particles);
|
||||
|
||||
static bool DepthSort(const std::shared_ptr<RenderJob> &i, const std::shared_ptr<RenderJob> &j) { return (i->Depth < j->Depth); }
|
||||
|
||||
void DrawDeferred(RenderQueue &objects, RenderQueue &lights);
|
||||
void DrawDeferred(RenderQueue &objects, RenderQueue &lights, RenderQueue &waterParticles);
|
||||
void DrawForward(RenderQueue &objects, RenderQueue &lights);
|
||||
void DrawScene(RenderQueue &objects, ShaderProgram &program);
|
||||
void DrawLightSpheres(RenderQueue &lights);
|
||||
|
||||
Reference in New Issue
Block a user