Working stencil buffer for the shield.
This commit is contained in:
@@ -50,6 +50,7 @@ private:
|
||||
GLuint m_BloomTexture;
|
||||
GLuint m_SceneTexture;
|
||||
GLuint m_DepthBuffer;
|
||||
GLuint m_StencilBuffer;
|
||||
|
||||
const IRenderer* m_Renderer;
|
||||
const LightCullingPass* m_LightCullingPass;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define RenderState_h__
|
||||
|
||||
#include <functional>
|
||||
#include <boost/range/adaptor/reversed.hpp>
|
||||
#include "../Common.h"
|
||||
#include "../OpenGL.h"
|
||||
#include "../GLM.h"
|
||||
|
||||
@@ -188,7 +188,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="2918.14111" Z="0"/>
|
||||
<Orientation X="0" Y="2918.14136" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -683,7 +683,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="1217.6123" Z="0"/>
|
||||
<Orientation X="0" Y="1217.61243" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -730,7 +730,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="1217.6123" Z="0"/>
|
||||
<Orientation X="0" Y="1217.61243" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -790,7 +790,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="1217.6123" Z="0"/>
|
||||
<Orientation X="0" Y="1217.61243" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -837,7 +837,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="1217.6123" Z="0"/>
|
||||
<Orientation X="0" Y="1217.61243" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -883,7 +883,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="1217.6123" Z="0"/>
|
||||
<Orientation X="0" Y="1217.61243" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -930,7 +930,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="1217.6123" Z="0"/>
|
||||
<Orientation X="0" Y="1217.61243" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -977,7 +977,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="1217.6123" Z="0"/>
|
||||
<Orientation X="0" Y="1217.61243" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -1390,7 +1390,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="1750.85364" Z="0"/>
|
||||
<Orientation X="0" Y="1750.85376" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -1399,7 +1399,7 @@
|
||||
<c:ExplosionEffect>
|
||||
<ColorByDistance>true</ColorByDistance>
|
||||
<Velocity X="0.800000012" Y="0.0379999988" Z="0"/>
|
||||
<TimeSinceDeath>1.3668564709912516</TimeSinceDeath>
|
||||
<TimeSinceDeath>1.3671759474185377</TimeSinceDeath>
|
||||
<ExplosionDuration>3.7999999523162842</ExplosionDuration>
|
||||
<EndColor A="0" B="23.5294113" G="11.7647057" R="0"/>
|
||||
<Randomness>true</Randomness>
|
||||
@@ -1446,7 +1446,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="1750.85364" Z="0"/>
|
||||
<Orientation X="0" Y="1750.85376" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -1455,7 +1455,7 @@
|
||||
<c:ExplosionEffect>
|
||||
<Velocity X="0.5" Y="1" Z="0"/>
|
||||
<ExplosionOrigin X="0" Y="0.900000036" Z="0"/>
|
||||
<TimeSinceDeath>0.316796204374441</TimeSinceDeath>
|
||||
<TimeSinceDeath>0.31711568080172703</TimeSinceDeath>
|
||||
</c:ExplosionEffect>
|
||||
<c:Model>
|
||||
<Resource>Models/Assault.mesh</Resource>
|
||||
@@ -1498,7 +1498,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="1750.85364" Z="0"/>
|
||||
<Orientation X="0" Y="1750.85376" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -1513,7 +1513,7 @@
|
||||
<ColorByDistance>true</ColorByDistance>
|
||||
<Velocity X="0.300000012" Y="2" Z="0"/>
|
||||
<ExplosionOrigin X="0" Y="1.30000007" Z="-0.200000003"/>
|
||||
<TimeSinceDeath>0.316796204374441</TimeSinceDeath>
|
||||
<TimeSinceDeath>0.31711568080172703</TimeSinceDeath>
|
||||
<EndColor A="0" B="0.333333343" G="0.933333337" R="3.92156863"/>
|
||||
<Randomness>true</Randomness>
|
||||
</c:ExplosionEffect>
|
||||
@@ -1558,7 +1558,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="857.983582" Z="0"/>
|
||||
<Orientation X="0" Y="857.983765" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -1568,7 +1568,7 @@
|
||||
<ColorByDistance>true</ColorByDistance>
|
||||
<Velocity X="0" Y="0.699999988" Z="0"/>
|
||||
<ExplosionOrigin X="0" Y="-1.10000002" Z="0"/>
|
||||
<TimeSinceDeath>0.95015514958004132</TimeSinceDeath>
|
||||
<TimeSinceDeath>0.95047462600732735</TimeSinceDeath>
|
||||
<ExplosionDuration>10</ExplosionDuration>
|
||||
<EndColor A="1" B="0" G="0" R="1"/>
|
||||
<RandomnessScalar>3</RandomnessScalar>
|
||||
@@ -1616,7 +1616,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="456.135437" Z="0"/>
|
||||
<Orientation X="0" Y="456.13559" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -1626,7 +1626,7 @@
|
||||
<ColorByDistance>true</ColorByDistance>
|
||||
<Velocity X="6" Y="0.100000001" Z="0"/>
|
||||
<ExplosionOrigin X="0" Y="-10" Z="0"/>
|
||||
<TimeSinceDeath>1.3501834109561059</TimeSinceDeath>
|
||||
<TimeSinceDeath>1.350502887383392</TimeSinceDeath>
|
||||
<ExponentialAccelaration>true</ExponentialAccelaration>
|
||||
<ExplosionDuration>5</ExplosionDuration>
|
||||
<Randomness>true</Randomness>
|
||||
@@ -1712,7 +1712,8 @@
|
||||
<c:Collidable/>
|
||||
<c:Health/>
|
||||
<c:Physics>
|
||||
<Velocity X="2.30999646e-23" Y="-16286.3516" Z="1.05272533e-23"/>
|
||||
<Velocity X="2.30999646e-23" Y="0" Z="1.05272533e-23"/>
|
||||
<Gravity>false</Gravity>
|
||||
</c:Physics>
|
||||
<c:Player>
|
||||
<MovementSpeed>5</MovementSpeed>
|
||||
@@ -1723,7 +1724,7 @@
|
||||
</Team>
|
||||
</c:Team>
|
||||
<c:Transform>
|
||||
<Position X="-1.56735241" Y="-13504349" Z="0.929739475"/>
|
||||
<Position X="-1.56735241" Y="0.527999997" Z="0.929739475"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -1806,7 +1807,7 @@
|
||||
<c:ExplosionEffect>
|
||||
<ColorByDistance>true</ColorByDistance>
|
||||
<Velocity X="0.800000012" Y="0.0379999988" Z="0"/>
|
||||
<TimeSinceDeath>1.3668564709912516</TimeSinceDeath>
|
||||
<TimeSinceDeath>1.3671759474185377</TimeSinceDeath>
|
||||
<ExplosionDuration>3.7999999523162842</ExplosionDuration>
|
||||
<EndColor A="0" B="23.5294113" G="11.7647057" R="0"/>
|
||||
<Randomness>true</Randomness>
|
||||
@@ -1859,6 +1860,7 @@
|
||||
<Resource>Models/AssaultAnimated.mesh</Resource>
|
||||
<Color A="1" B="0" G="0" R="1"/>
|
||||
</c:Model>
|
||||
<c:Shielded/>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
<Children/>
|
||||
|
||||
@@ -9,7 +9,7 @@ out vec4 fragmentColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
fragmentColor = vec4(0.5, 0.5, 0.5, 1.0);
|
||||
fragmentColor = vec4(0.5, 0.5, 0.5, 0.2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,17 +21,18 @@ void DrawFinalPass::InitializeFrameBuffers()
|
||||
{
|
||||
glGenRenderbuffers(1, &m_DepthBuffer);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBuffer);
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
|
||||
GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||
//GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||
GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||
//GenerateMipMapTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_FLOAT, 4);
|
||||
|
||||
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new RenderBuffer(&m_DepthBuffer, GL_DEPTH_ATTACHMENT)));
|
||||
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new RenderBuffer(&m_DepthBuffer, GL_DEPTH_STENCIL_ATTACHMENT)));
|
||||
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SceneTexture, GL_COLOR_ATTACHMENT0)));
|
||||
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_BloomTexture, GL_COLOR_ATTACHMENT1)));
|
||||
m_FinalPassFrameBuffer.Generate();
|
||||
GLERROR("FBO generation");
|
||||
|
||||
}
|
||||
|
||||
@@ -74,8 +75,10 @@ void DrawFinalPass::Draw(RenderScene& scene)
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
//TODO: Do we need check for this or will it be per scene always?
|
||||
glClearStencil(0x00);
|
||||
glClear(GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
state->StencilMask(0x00);
|
||||
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
|
||||
GLERROR("OpaqueObjects");
|
||||
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene);
|
||||
@@ -89,11 +92,13 @@ void DrawFinalPass::Draw(RenderScene& scene)
|
||||
GLERROR("StencilPass");
|
||||
|
||||
//Draw Opaque shielded objects
|
||||
//DrawShieldedModelRenderQueue(scene.Jobs.OpaqueShieldedObjects, scene);
|
||||
state->StencilFunc(GL_NOTEQUAL, 1, 0xFF);
|
||||
glStencilMask(0x00);
|
||||
DrawShieldedModelRenderQueue(scene.Jobs.OpaqueShieldedObjects, scene);
|
||||
GLERROR("Shielded Opaque object");
|
||||
|
||||
//Draw Transparen Shielded objects
|
||||
//DrawShieldedModelRenderQueue(scene.Jobs.TransparentShieldedObjects, scene);
|
||||
DrawShieldedModelRenderQueue(scene.Jobs.TransparentShieldedObjects, scene);
|
||||
GLERROR("Shielded Transparent objects");
|
||||
|
||||
GLERROR("END");
|
||||
|
||||
@@ -12,7 +12,7 @@ DrawFinalPassState::DrawFinalPassState(GLuint frameBuffer)
|
||||
Enable(GL_STENCIL_TEST);
|
||||
StencilFunc(GL_NOTEQUAL, 1, 0xFF);
|
||||
StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
||||
StencilMask(0x00);
|
||||
StencilMask(0xFF);
|
||||
ClearColor(glm::vec4(0.f, 0.f, 0.f, 0.f));
|
||||
}
|
||||
|
||||
|
||||
@@ -57,17 +57,17 @@ void FrameBuffer::Generate()
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if ((*it)->m_Attachment != GL_DEPTH_ATTACHMENT) {
|
||||
if ((*it)->m_Attachment != GL_DEPTH_ATTACHMENT || (*it)->m_Attachment != GL_STENCIL_ATTACHMENT || (*it)->m_Attachment != GL_DEPTH_STENCIL_ATTACHMENT) {
|
||||
attachments.push_back((*it)->m_Attachment);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GLenum* bufferTextures = &attachments[0];
|
||||
glDrawBuffers(attachments.size(), bufferTextures);
|
||||
|
||||
if (GLenum frameBufferStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
||||
LOG_ERROR("FrameBuffer incomplete: 0x%x\n", frameBufferStatus);
|
||||
GLERROR("Framebuffer incomplete");
|
||||
//LOG_ERROR("FrameBuffer incomplete: 0x%x\n", frameBufferStatus);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ bool RenderState::DepthMask(GLboolean flag)
|
||||
|
||||
RenderState::~RenderState()
|
||||
{
|
||||
for (auto& f : m_ResetFunctions) {
|
||||
for (auto& f : boost::adaptors::reverse(m_ResetFunctions)) {
|
||||
f();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user