Initial work on texture arrays
This commit is contained in:
@@ -8,10 +8,12 @@ class BufferResource
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BufferResource(GLuint* resourceHandle, GLenum resourceType, GLenum attachment);
|
BufferResource(GLuint* resourceHandle, GLenum resourceType, GLenum attachment);
|
||||||
|
BufferResource(GLuint* resourceHandle, GLenum resourceType, GLenum attachment, GLuint layers);
|
||||||
|
|
||||||
GLuint* m_ResourceHandle;
|
GLuint* m_ResourceHandle;
|
||||||
GLenum m_ResourceType;
|
GLenum m_ResourceType;
|
||||||
GLenum m_Attachment;
|
GLenum m_Attachment;
|
||||||
|
GLuint m_Layers;
|
||||||
private:
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -22,6 +24,9 @@ class ResourceType : public BufferResource
|
|||||||
public:
|
public:
|
||||||
ResourceType(GLuint* resourceHandle, GLenum attachment)
|
ResourceType(GLuint* resourceHandle, GLenum attachment)
|
||||||
: BufferResource(resourceHandle, RESOURCETYPE, attachment) { }
|
: BufferResource(resourceHandle, RESOURCETYPE, attachment) { }
|
||||||
|
|
||||||
|
ResourceType(GLuint* resourceHandle, GLenum attachment, GLuint layers)
|
||||||
|
: BufferResource(resourceHandle, RESOURCETYPE, attachment, layers) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
class Texture2D : public ResourceType<GL_TEXTURE_2D>
|
class Texture2D : public ResourceType<GL_TEXTURE_2D>
|
||||||
@@ -43,6 +48,15 @@ public:
|
|||||||
~RenderBuffer();
|
~RenderBuffer();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Texture2DArray : public ResourceType<GL_TEXTURE_2D_ARRAY>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Texture2DArray(GLuint* resourceHandle, GLenum attachment, GLuint layers)
|
||||||
|
: ResourceType(resourceHandle, attachment, layers) { };
|
||||||
|
|
||||||
|
~Texture2DArray();
|
||||||
|
};
|
||||||
|
|
||||||
class FrameBuffer
|
class FrameBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ public:
|
|||||||
void ClearBuffer();
|
void ClearBuffer();
|
||||||
void Draw(RenderScene& scene);
|
void Draw(RenderScene& scene);
|
||||||
|
|
||||||
GLuint DepthMap(int level) const { return m_DepthMap[level]; }
|
//GLuint DepthMap(int level) const { return m_DepthMap[level]; }
|
||||||
|
GLuint DepthMap() const { return m_DepthMap; }
|
||||||
std::array<glm::mat4, MAX_SPLITS> LightP() const { return m_LightProjection; }
|
std::array<glm::mat4, MAX_SPLITS> LightP() const { return m_LightProjection; }
|
||||||
std::array<glm::mat4, MAX_SPLITS> LightV() const { return m_LightView; }
|
std::array<glm::mat4, MAX_SPLITS> LightV() const { return m_LightView; }
|
||||||
std::array<float, MAX_SPLITS> FarDistance() const { return { m_shadowFrusta[0].FarClip, m_shadowFrusta[1].FarClip, m_shadowFrusta[2].FarClip, m_shadowFrusta[3].FarClip }; }
|
std::array<float, MAX_SPLITS> FarDistance() const { return { m_shadowFrusta[0].FarClip, m_shadowFrusta[1].FarClip, m_shadowFrusta[2].FarClip, m_shadowFrusta[3].FarClip }; }
|
||||||
@@ -55,8 +56,10 @@ private:
|
|||||||
EventBroker* m_EventBroker;
|
EventBroker* m_EventBroker;
|
||||||
const IRenderer* m_Renderer;
|
const IRenderer* m_Renderer;
|
||||||
|
|
||||||
std::array<GLuint, MAX_SPLITS> m_DepthMap;
|
//std::array<GLuint, MAX_SPLITS> m_DepthMap;
|
||||||
std::array<FrameBuffer, MAX_SPLITS> m_DepthBuffer;
|
//std::array<FrameBuffer, MAX_SPLITS> m_DepthBuffer;
|
||||||
|
GLuint m_DepthMap;
|
||||||
|
FrameBuffer m_DepthBuffer;
|
||||||
|
|
||||||
std::array<glm::mat4, MAX_SPLITS> m_LightProjection;
|
std::array<glm::mat4, MAX_SPLITS> m_LightProjection;
|
||||||
std::array<glm::mat4, MAX_SPLITS> m_LightView;
|
std::array<glm::mat4, MAX_SPLITS> m_LightView;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
|
||||||
#define MAX_SPLITS 3
|
#define MAX_SPLITS 4
|
||||||
|
|
||||||
uniform mat4 M;
|
uniform mat4 M;
|
||||||
uniform mat4 V;
|
uniform mat4 V;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
|
||||||
#define MAX_SPLITS 3
|
#define MAX_SPLITS 4
|
||||||
|
|
||||||
uniform mat4 M;
|
uniform mat4 M;
|
||||||
uniform mat4 V;
|
uniform mat4 V;
|
||||||
@@ -17,9 +17,8 @@ layout (binding = 0) uniform sampler2D DiffuseTexture;
|
|||||||
layout (binding = 1) uniform sampler2D NormalMapTexture;
|
layout (binding = 1) uniform sampler2D NormalMapTexture;
|
||||||
layout (binding = 2) uniform sampler2D SpecularMapTexture;
|
layout (binding = 2) uniform sampler2D SpecularMapTexture;
|
||||||
layout (binding = 3) uniform sampler2D GlowMapTexture;
|
layout (binding = 3) uniform sampler2D GlowMapTexture;
|
||||||
layout (binding = 4) uniform sampler2DShadow DepthMap0;
|
layout (binding = 4) uniform sampler2DShadow DepthMap[MAX_SPLITS];
|
||||||
layout (binding = 5) uniform sampler2DShadow DepthMap1;
|
|
||||||
layout (binding = 6) uniform sampler2DShadow DepthMap2;
|
|
||||||
|
|
||||||
#define TILE_SIZE 16
|
#define TILE_SIZE 16
|
||||||
|
|
||||||
@@ -209,36 +208,8 @@ int getShadowIndex(float far_distance[MAX_SPLITS])
|
|||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
//sampler2DShadow whichDepthMap(int DepthMapIndex)
|
|
||||||
//{
|
|
||||||
// if( DepthMapIndex == 0 )
|
|
||||||
// {
|
|
||||||
// return DepthMap0;
|
|
||||||
// }
|
|
||||||
// else if( DepthMapIndex == 1 )
|
|
||||||
// {
|
|
||||||
// return DepthMap1;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// return DepthMap2;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
//sampler2DShadow DepthMaps[3] = { sampler2DShadow(DepthMap0), sampler2DShadow(DepthMap1), sampler2DShadow(DepthMap2) };
|
|
||||||
//sampler2DShadow DepthMaps[3] = { DepthMap0, DepthMap1, DepthMap2 };
|
|
||||||
//sampler2DShadow DepthMaps[3] = sampler2DShadow[]( DepthMap0, DepthMap1, DepthMap2 );
|
|
||||||
//sampler2DShadow DepthMaps[3] = sampler2DShadow[3]( DepthMap0, DepthMap1, DepthMap2 );
|
|
||||||
//sampler2DShadow DepthMaps[3];
|
|
||||||
|
|
||||||
//sampler2DShadow DepthMapOne = DepthMap0;
|
|
||||||
|
|
||||||
//DepthMaps[0] = DepthMap0;
|
|
||||||
//DepthMaps[1] = DepthMap1;
|
|
||||||
//DepthMaps[2] = DepthMap2;
|
|
||||||
|
|
||||||
vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate);
|
vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate);
|
||||||
vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate);
|
vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate);
|
||||||
vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate);
|
vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate);
|
||||||
@@ -271,24 +242,22 @@ void main()
|
|||||||
if(light.Type == 1) { // point
|
if(light.Type == 1) { // point
|
||||||
light_result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, position, normal, light.Falloff);
|
light_result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, position, normal, light.Falloff);
|
||||||
} else if (light.Type == 2) { //Directional
|
} else if (light.Type == 2) { //Directional
|
||||||
int DepthMapIndex = getShadowIndex(FarDistance);
|
//int DepthMapIndex = getShadowIndex(FarDistance);
|
||||||
//sampler2DShadow WhichDepthMap = whichDepthMap(DepthMapIndex);
|
|
||||||
|
|
||||||
light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal);
|
light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal);
|
||||||
|
|
||||||
//shadowFactor = CalcShadowValue(Input.PositionLightSpace[0], Input.Normal, vec3(light.Direction), DepthMap0);
|
//if( DepthMapIndex == 0 )
|
||||||
if( DepthMapIndex == 0 )
|
//{
|
||||||
{
|
shadowFactor = CalcShadowValue(Input.PositionLightSpace[0], Input.Normal, vec3(light.Direction), DepthMap[0]);
|
||||||
shadowFactor = CalcShadowValue(Input.PositionLightSpace[DepthMapIndex], Input.Normal, vec3(light.Direction), DepthMap0);
|
//}
|
||||||
}
|
//else if( DepthMapIndex == 1 )
|
||||||
else if( DepthMapIndex == 1 )
|
//{
|
||||||
{
|
// shadowFactor = CalcShadowValue(Input.PositionLightSpace[DepthMapIndex], Input.Normal, vec3(light.Direction), DepthMap1);
|
||||||
shadowFactor = CalcShadowValue(Input.PositionLightSpace[DepthMapIndex], Input.Normal, vec3(light.Direction), DepthMap1);
|
//}
|
||||||
}
|
//else
|
||||||
else
|
//{
|
||||||
{
|
// shadowFactor = CalcShadowValue(Input.PositionLightSpace[DepthMapIndex], Input.Normal, vec3(light.Direction), DepthMap2);
|
||||||
shadowFactor = CalcShadowValue(Input.PositionLightSpace[DepthMapIndex], Input.Normal, vec3(light.Direction), DepthMap2);
|
//}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
totalLighting.Diffuse += light_result.Diffuse;
|
totalLighting.Diffuse += light_result.Diffuse;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
|
||||||
#define MAX_SPLITS 3
|
#define MAX_SPLITS 4
|
||||||
|
|
||||||
uniform mat4 M;
|
uniform mat4 M;
|
||||||
uniform mat4 V;
|
uniform mat4 V;
|
||||||
|
|||||||
@@ -320,15 +320,15 @@ void DrawFinalPass::BindModelTextures(std::shared_ptr<ModelJob>& job)
|
|||||||
glBindTexture(GL_TEXTURE_2D, m_BlackTexture->m_Texture);
|
glBindTexture(GL_TEXTURE_2D, m_BlackTexture->m_Texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < m_ShadowPass->CurrentNrOfSplits(); i++)
|
//for (int i = 0; i < m_ShadowPass->CurrentNrOfSplits(); i++)
|
||||||
{
|
//{
|
||||||
glActiveTexture(GL_TEXTURE4 + i);
|
glActiveTexture(GL_TEXTURE4);
|
||||||
if (m_ShadowPass->DepthMap(i) != NULL) {
|
if (m_ShadowPass->DepthMap() != NULL) {
|
||||||
glBindTexture(GL_TEXTURE_2D, m_ShadowPass->DepthMap(i));
|
glBindTexture(GL_TEXTURE_2D_ARRAY, m_ShadowPass->DepthMap());
|
||||||
} else {
|
} else {
|
||||||
glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture);
|
glBindTexture(GL_TEXTURE_2D_ARRAY, m_WhiteTexture->m_Texture);
|
||||||
}
|
}
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,14 @@ BufferResource::BufferResource(GLuint* resourceHandle, GLenum resourceType, GLen
|
|||||||
m_Attachment = attachment;
|
m_Attachment = attachment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BufferResource::BufferResource(GLuint* resourceHandle, GLenum resourceType, GLenum attachment, GLuint layers)
|
||||||
|
{
|
||||||
|
m_ResourceHandle = resourceHandle;
|
||||||
|
m_ResourceType = resourceType;
|
||||||
|
m_Attachment = attachment;
|
||||||
|
m_Layers = layers;
|
||||||
|
}
|
||||||
|
|
||||||
Texture2D::~Texture2D()
|
Texture2D::~Texture2D()
|
||||||
{
|
{
|
||||||
if (m_ResourceHandle != 0) {
|
if (m_ResourceHandle != 0) {
|
||||||
@@ -16,6 +24,12 @@ Texture2D::~Texture2D()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Texture2DArray::~Texture2DArray()
|
||||||
|
{
|
||||||
|
if (m_ResourceHandle != 0) {
|
||||||
|
glDeleteTextures(1, m_ResourceHandle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RenderBuffer::~RenderBuffer()
|
RenderBuffer::~RenderBuffer()
|
||||||
{
|
{
|
||||||
@@ -48,18 +62,22 @@ void FrameBuffer::Generate()
|
|||||||
switch ((*it)->m_ResourceType) {
|
switch ((*it)->m_ResourceType) {
|
||||||
case GL_TEXTURE_2D:
|
case GL_TEXTURE_2D:
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle, 0);
|
||||||
|
attachments.push_back((*it)->m_Attachment);
|
||||||
GLERROR("FrameBuffer generate: glFramebufferTexture2D");
|
GLERROR("FrameBuffer generate: glFramebufferTexture2D");
|
||||||
break;
|
break;
|
||||||
case GL_RENDERBUFFER:
|
case GL_RENDERBUFFER:
|
||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle);
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle);
|
||||||
GLERROR("FrameBuffer generate: glFramebufferRenderbuffer");
|
GLERROR("FrameBuffer generate: glFramebufferRenderbuffer");
|
||||||
break;
|
break;
|
||||||
|
case GL_TEXTURE_2D_ARRAY:
|
||||||
|
glFramebufferTexture(GL_FRAMEBUFFER, (*it)->m_Attachment, *(*it)->m_ResourceHandle, 0);
|
||||||
|
attachments.push_back((*it)->m_Attachment);
|
||||||
|
GLERROR("FrameBuffer generate: GL_TEXTURE_2D_ARRAY");
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ((*it)->m_ResourceType == GL_TEXTURE_2D) {
|
|
||||||
attachments.push_back((*it)->m_Attachment);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLenum* bufferTextures = &attachments[0];
|
GLenum* bufferTextures = &attachments[0];
|
||||||
|
|||||||
@@ -136,9 +136,9 @@ void Renderer::Draw(RenderFrame& frame)
|
|||||||
if (m_DebugTextureToDraw == 4) {
|
if (m_DebugTextureToDraw == 4) {
|
||||||
m_DrawScreenQuadPass->Draw(m_PickingPass->PickingTexture());
|
m_DrawScreenQuadPass->Draw(m_PickingPass->PickingTexture());
|
||||||
}
|
}
|
||||||
if (m_DebugTextureToDraw == 5) {
|
//if (m_DebugTextureToDraw == 5) {
|
||||||
m_DrawScreenQuadPass->Draw(m_ShadowPass->DepthMap(0));
|
// m_DrawScreenQuadPass->Draw(m_ShadowPass->DepthMap());
|
||||||
}
|
//}
|
||||||
|
|
||||||
m_ImGuiRenderPass->Draw();
|
m_ImGuiRenderPass->Draw();
|
||||||
glfwSwapBuffers(m_Window);
|
glfwSwapBuffers(m_Window);
|
||||||
|
|||||||
@@ -106,26 +106,37 @@ float ShadowPass::FindRadius(Frustum& frustum)
|
|||||||
|
|
||||||
void ShadowPass::InitializeFrameBuffers()
|
void ShadowPass::InitializeFrameBuffers()
|
||||||
{
|
{
|
||||||
// Depth texture
|
GLERROR("depthMap failed PRE");
|
||||||
glGenTextures(m_CurrentNrOfSplits, m_DepthMap.data());
|
// Depth texture
|
||||||
|
glGenTextures(1, &m_DepthMap);
|
||||||
|
|
||||||
for (int i = 0; i < m_CurrentNrOfSplits; i++) {
|
GLERROR("depthMap failed1");
|
||||||
glBindTexture(GL_TEXTURE_2D, m_DepthMap[i]);
|
glBindTexture(GL_TEXTURE_2D_ARRAY, m_DepthMap);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, m_ResolutionSizeWidth / (1 /*+ i*/), m_ResolutionSizeHeigth + (1 /*+ i*/), 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr);
|
GLERROR("depthMap failed2");
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_DEPTH_COMPONENT16, m_ResolutionSizeWidth, m_ResolutionSizeHeigth, m_CurrentNrOfSplits);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
GLERROR("depthMap failed3");
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
|
|
||||||
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, glm::vec4(1.f).data);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
|
|
||||||
//glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY);
|
|
||||||
|
|
||||||
m_DepthBuffer[i].AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_DepthMap[i], GL_DEPTH_ATTACHMENT)));
|
glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, m_ResolutionSizeWidth, m_ResolutionSizeHeigth, m_CurrentNrOfSplits, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr);
|
||||||
m_DepthBuffer[i].Generate();
|
GLERROR("depthMap failed4");
|
||||||
}
|
|
||||||
|
|
||||||
GLERROR("depthMap failed");
|
//for (int i = 0; i < m_CurrentNrOfSplits; i++) {
|
||||||
|
// glBindTexture(GL_TEXTURE_2D, m_DepthMap[i]);
|
||||||
|
// glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, m_ResolutionSizeWidth / (1 /*+ i*/), m_ResolutionSizeHeigth + (1 /*+ i*/), 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
|
||||||
|
glTexParameterfv(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_BORDER_COLOR, glm::vec4(1.f).data);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
|
||||||
|
//glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY);
|
||||||
|
GLERROR("depthMap failed5");
|
||||||
|
|
||||||
|
m_DepthBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2DArray(&m_DepthMap, GL_DEPTH_ATTACHMENT, m_CurrentNrOfSplits)));
|
||||||
|
m_DepthBuffer.Generate();
|
||||||
|
//}
|
||||||
|
|
||||||
|
GLERROR("depthMap failed END");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShadowPass::InitializeShaderPrograms()
|
void ShadowPass::InitializeShaderPrograms()
|
||||||
@@ -141,10 +152,10 @@ void ShadowPass::InitializeShaderPrograms()
|
|||||||
void ShadowPass::ClearBuffer()
|
void ShadowPass::ClearBuffer()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_CurrentNrOfSplits; i++) {
|
for (int i = 0; i < m_CurrentNrOfSplits; i++) {
|
||||||
m_DepthBuffer[i].Bind();
|
m_DepthBuffer.Bind();
|
||||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
m_DepthBuffer[i].Unbind();
|
m_DepthBuffer.Unbind();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +203,7 @@ void ShadowPass::Draw(RenderScene & scene)
|
|||||||
UpdateFrustumPoints(m_shadowFrusta[i], scene.Camera->Position(), scene.Camera->Forward(), scene.Camera->ProjectionMatrix(), scene.Camera->ViewMatrix());
|
UpdateFrustumPoints(m_shadowFrusta[i], scene.Camera->Position(), scene.Camera->Forward(), scene.Camera->ProjectionMatrix(), scene.Camera->ViewMatrix());
|
||||||
//float test = FindRadius(m_shadFrusta[i]);
|
//float test = FindRadius(m_shadFrusta[i]);
|
||||||
|
|
||||||
ShadowPassState* state = new ShadowPassState(m_DepthBuffer[i].GetHandle());
|
ShadowPassState* state = new ShadowPassState(m_DepthBuffer.GetHandle());
|
||||||
|
|
||||||
GLuint shaderHandle = m_ShadowProgram->GetHandle();
|
GLuint shaderHandle = m_ShadowProgram->GetHandle();
|
||||||
m_ShadowProgram->Bind();
|
m_ShadowProgram->Bind();
|
||||||
@@ -230,7 +241,7 @@ void ShadowPass::Draw(RenderScene & scene)
|
|||||||
GLERROR("Shadow Draw ERROR");
|
GLERROR("Shadow Draw ERROR");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_DepthBuffer[i].Unbind();
|
m_DepthBuffer.Unbind();
|
||||||
|
|
||||||
delete state;
|
delete state;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user