Merge remote-tracking branch 'upstream/master' into new_login

This commit is contained in:
hiker 2014-02-11 22:36:13 +11:00
commit 07a5d90aa0
19 changed files with 235 additions and 120 deletions

View File

@ -1,14 +1,18 @@
#version 130
uniform sampler2D ntex;
uniform sampler2D dtex;
uniform sampler2DShadow shadowtex;
uniform sampler2DShadow shadowtex0;
uniform sampler2DShadow shadowtex1;
uniform sampler2DShadow shadowtex2;
//uniform sampler2D warpx;
///uniform sampler2D warpy;
uniform vec3 direction;
uniform vec3 col;
uniform mat4 invproj;
uniform mat4 shadowmat;
uniform mat4 shadowmat0;
uniform mat4 shadowmat1;
uniform mat4 shadowmat2;
//uniform int hasclouds;
//uniform vec2 wind;
//uniform float shadowoffset;
@ -24,20 +28,47 @@ vec3 DecodeNormal(vec2 n)
return vec3(xy,z);
}
float getShadowFactor(vec3 pos, float bias)
{
if (pos.z < 10.)
{
vec4 shadowcoord = (shadowmat0 * vec4(pos, 1.0));
shadowcoord /= shadowcoord.w;
vec2 shadowtexcoord = shadowcoord.xy * 0.5 + 0.5;
// shadowcoord = (shadowcoord * 0.5) + vec3(0.5);
// float movex = decdepth(texture(warpx, shadowcoord.xy));
// float movey = decdepth(texture(warpy, shadowcoord.xy));
// float dx = movex * 2.0 - 1.0;
// float dy = movey * 2.0 - 1.0;
// shadowcoord.xy += vec2(dx, dy);*/
//float shadowmapz = 2. * texture(shadowtex, vec3(shadowtexcoord, shadowcoord.z).x - 1.;
// bias += smoothstep(0.001, 0.1, moved) * 0.014; // According to the warping
return texture(shadowtex0, vec3(shadowtexcoord, 0.5 * (shadowcoord.z + bias * 0.001) + 0.5));
}
else if (pos.z < 60)
{
vec4 shadowcoord = (shadowmat1 * vec4(pos, 1.0));
shadowcoord /= shadowcoord.w;
vec2 shadowtexcoord = shadowcoord.xy * 0.5 + 0.5;
return texture(shadowtex1, vec3(shadowtexcoord, 0.5 * (shadowcoord.z + bias * 0.001) + 0.5));
}
else
{
vec4 shadowcoord = (shadowmat2 * vec4(pos, 1.0));
shadowcoord /= shadowcoord.w;
vec2 shadowtexcoord = shadowcoord.xy * 0.5 + 0.5;
return texture(shadowtex2, vec3(shadowtexcoord, 0.5 * (shadowcoord.z + bias) + 0.5));
}
}
void main() {
float z = texture(dtex, uv).x;
vec4 xpos = 2.0 * vec4(uv, z, 1.0) - 1.0;
xpos = invproj * xpos;
xpos.xyz /= xpos.w;
if (z < 0.03)
{
// Skyboxes are fully lit
Diff = vec4(1.0);
Spec = vec4(1.0);
return;
}
vec3 norm = normalize(DecodeNormal(2. * texture(ntex, uv).xy - 1.));
// Normalized on the cpu
@ -60,23 +91,9 @@ void main() {
// }
// Shadows
vec4 shadowcoord = (shadowmat * vec4(xpos.xyz, 1.0));
shadowcoord /= shadowcoord.w;
vec2 shadowtexcoord = shadowcoord.xy * 0.5 + 0.5;
// shadowcoord = (shadowcoord * 0.5) + vec3(0.5);
// float movex = decdepth(texture(warpx, shadowcoord.xy));
// float movey = decdepth(texture(warpy, shadowcoord.xy));
// float dx = movex * 2.0 - 1.0;
// float dy = movey * 2.0 - 1.0;
// shadowcoord.xy += vec2(dx, dy);*/
//float shadowmapz = 2. * texture(shadowtex, vec3(shadowtexcoord, shadowcoord.z).x - 1.;
float bias = 0.002 * tan(acos(NdotL)); // According to the slope
// bias += smoothstep(0.001, 0.1, moved) * 0.014; // According to the warping
bias = clamp(bias, 0.001, 0.014);
float factor = texture(shadowtex, vec3(shadowtexcoord, 0.5 * (shadowcoord.z + bias) + 0.5));
float factor = getShadowFactor(xpos.xyz, bias);
Diff = vec4(factor * NdotL * col, 1.);
Spec = vec4(factor * Specular * col, 1.);
return;

View File

@ -181,6 +181,9 @@ void* NewsManager::downloadNews(void *obj)
xml = NULL;
} // hadDownloadError
if(xml) delete xml;
xml = NULL;
// Process new.xml now.
if(file_manager->fileExists(xml_file))
{

View File

@ -335,8 +335,8 @@ void SunLightProvider::OnSetConstants(IMaterialRendererServices *srv, int)
tex = 5;
srv->setVertexShaderConstant("warpy", &tex, 1);
const float shadowoffset = 1.0f / irr_driver->getRTT(RTT_SHADOW)->getSize().Width;
srv->setVertexShaderConstant("shadowoffset", &shadowoffset, 1);
// const float shadowoffset = 1.0f / irr_driver->getRTT(RTT_SHADOW)->getSize().Width;
// srv->setVertexShaderConstant("shadowoffset", &shadowoffset, 1);
firstdone = true;
}

View File

@ -54,6 +54,11 @@ PFNGLTEXBUFFERPROC glTexBuffer;
PFNGLBUFFERSUBDATAPROC glBufferSubData;
PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer;
PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB;
PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture;
PFNGLTEXIMAGE3DPROC glTexImage3D;
PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
#endif
static bool is_gl_init = false;
@ -177,6 +182,11 @@ void initGL()
glUniform4fv = (PFNGLUNIFORM4FVPROC)IRR_OGL_LOAD_EXTENSION("glUniform4fv");
glBufferSubData = (PFNGLBUFFERSUBDATAPROC)IRR_OGL_LOAD_EXTENSION("glBufferSubData");
glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)IRR_OGL_LOAD_EXTENSION("glVertexAttribIPointer");
glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)IRR_OGL_LOAD_EXTENSION("glGenFramebuffers");
glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)IRR_OGL_LOAD_EXTENSION("glBindFramebuffer");
glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC)IRR_OGL_LOAD_EXTENSION("glFramebufferTexture");
glTexImage3D = (PFNGLTEXIMAGE3DPROC)IRR_OGL_LOAD_EXTENSION("glTexImage3D");
glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)IRR_OGL_LOAD_EXTENSION("glCheckFramebufferStatus");
#ifdef DEBUG
glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)IRR_OGL_LOAD_EXTENSION("glDebugMessageCallbackARB");
#endif

View File

@ -75,6 +75,11 @@ extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays;
extern PFNGLTEXBUFFERPROC glTexBuffer;
extern PFNGLBUFFERSUBDATAPROC glBufferSubData;
extern PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer;
extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
extern PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture;
extern PFNGLTEXIMAGE3DPROC glTexImage3D;
extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
#ifdef DEBUG
extern PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB;
#endif

View File

@ -102,7 +102,7 @@ private:
RTT *m_rtts;
/** Shadow importance. */
ShadowImportance *m_shadow_importance;
core::matrix4 sun_ortho_matrix;
core::matrix4 sun_ortho_matrix[3];
/** Additional details to be shown in case that a texture is not found.
* This is used to specify details like: "while loading kart '...'" */

View File

@ -346,7 +346,7 @@ void PostProcessing::renderSunlight()
glBindVertexArray(0);
}
void PostProcessing::renderShadowedSunlight(const core::matrix4 &sun_ortho_matrix)
void PostProcessing::renderShadowedSunlight(const core::matrix4 &sun_ortho_matrix0, const core::matrix4 &sun_ortho_matrix1, const core::matrix4 &sun_ortho_matrix2)
{
SunLightProvider * const cb = (SunLightProvider *)irr_driver->getCallback(ES_SUNLIGHT);
@ -359,10 +359,16 @@ void PostProcessing::renderShadowedSunlight(const core::matrix4 &sun_ortho_matri
glBindVertexArray(FullScreenShader::ShadowedSunLightShader::vao);
setTexture(0, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH))->getOpenGLTextureName(), GL_NEAREST, GL_NEAREST);
setTexture(1, static_cast<irr::video::COpenGLFBOTexture*>(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH))->DepthBufferTexture, GL_NEAREST, GL_NEAREST);
setTexture(2, static_cast<irr::video::COpenGLFBOTexture*>(irr_driver->getRTT(RTT_SHADOW))->DepthBufferTexture, GL_LINEAR, GL_LINEAR);
setTexture(2, static_cast<irr::video::COpenGLFBOTexture*>(irr_driver->getRTT(RTT_SHADOW0))->DepthBufferTexture, GL_LINEAR, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
FullScreenShader::ShadowedSunLightShader::setUniforms(sun_ortho_matrix, cb->getPosition(), irr_driver->getInvProjMatrix(), cb->getRed(), cb->getGreen(), cb->getBlue(), 0, 1, 2);
setTexture(3, static_cast<irr::video::COpenGLFBOTexture*>(irr_driver->getRTT(RTT_SHADOW1))->DepthBufferTexture, GL_LINEAR, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
setTexture(4, static_cast<irr::video::COpenGLFBOTexture*>(irr_driver->getRTT(RTT_SHADOW2))->DepthBufferTexture, GL_LINEAR, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
FullScreenShader::ShadowedSunLightShader::setUniforms(sun_ortho_matrix0, sun_ortho_matrix1, sun_ortho_matrix2, cb->getPosition(), irr_driver->getInvProjMatrix(), cb->getRed(), cb->getGreen(), cb->getBlue(), 0, 1, 2, 3, 4);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0);
}
@ -849,7 +855,7 @@ void PostProcessing::render()
else if (irr_driver->getSSAOViz())
renderPassThrough(irr_driver->getRTT(RTT_SSAO));
else if (irr_driver->getShadowViz())
renderPassThrough(static_cast<irr::video::COpenGLFBOTexture*>(irr_driver->getRTT(RTT_SHADOW))->DepthBufferTexture);
renderPassThrough(static_cast<irr::video::COpenGLFBOTexture*>(irr_driver->getRTT(RTT_SHADOW0))->DepthBufferTexture);
else
renderColorLevel(in);
}

View File

@ -75,7 +75,7 @@ public:
/** Generate diffuse and specular map */
void renderPointlight(const std::vector<float> &positions, const std::vector<float> &colors, const std::vector<float> &energy);
void renderSunlight();
void renderShadowedSunlight(const core::matrix4 &sun_ortho_matrix);
void renderShadowedSunlight(const core::matrix4 &sun_ortho_matrix0, const core::matrix4 &sun_ortho_matrix1, const core::matrix4 &sun_ortho_matrix2);
void renderFog(const core::matrix4 &ipvmat);
void renderSSAO(const core::matrix4 &invprojm, const core::matrix4 &projm);

View File

@ -470,60 +470,112 @@ void IrrDriver::renderShadows(//ShadowImportanceProvider * const sicb,
Camera * const camera)
{
m_scene_manager->setCurrentRendertime(scene::ESNRP_SOLID);
static u8 tick = 0;
const Vec3 *vmin, *vmax;
World::getWorld()->getTrack()->getAABB(&vmin, &vmax);
core::aabbox3df trackbox(vmin->toIrrVector(), vmax->toIrrVector() -
core::vector3df(0, 30, 0));
ITexture *ShadowRTT[] = {
m_rtts->getRTT(RTT_SHADOW0),
m_rtts->getRTT(RTT_SHADOW1),
m_rtts->getRTT(RTT_SHADOW2)
};
unsigned rtt_size[] = {
2048,
1024,
512,
};
const float oldfar = camnode->getFarValue();
camnode->setFarValue(std::min(100.0f, oldfar));
camnode->render();
const core::aabbox3df smallcambox = camnode->
getViewFrustum()->getBoundingBox();
const float oldnear = camnode->getNearValue();
float FarValues[] =
{
10.,
60.,
oldfar,
};
float NearValues[] =
{
oldnear,
10.,
60.,
};
const core::matrix4 &SunCamViewMatrix = m_suncam->getViewMatrix();
// Build the 3 ortho projection (for the 3 shadow resolution levels)
for (unsigned i = 0; i < 3; i++)
{
camnode->setFarValue(FarValues[i]);
camnode->setNearValue(NearValues[i]);
camnode->render();
const core::aabbox3df smallcambox = camnode->
getViewFrustum()->getBoundingBox();
core::aabbox3df trackbox(vmin->toIrrVector(), vmax->toIrrVector() -
core::vector3df(0, 30, 0));
// Set up a nice ortho projection that contains our camera frustum
core::aabbox3df box = smallcambox;
box = box.intersect(trackbox);
SunCamViewMatrix.transformBoxEx(trackbox);
SunCamViewMatrix.transformBoxEx(box);
core::vector3df extent = trackbox.getExtent();
const float w = fabsf(extent.X);
const float h = fabsf(extent.Y);
float z = box.MaxEdge.Z;
// Snap to texels
const float units_per_w = w / rtt_size[i];
const float units_per_h = h / rtt_size[i];
float left = box.MinEdge.X;
float right = box.MaxEdge.X;
float up = box.MaxEdge.Y;
float down = box.MinEdge.Y;
left -= fmodf(left, units_per_w);
right -= fmodf(right, units_per_w);
up -= fmodf(up, units_per_h);
down -= fmodf(down, units_per_h);
z -= fmodf(z, 0.5f);
// FIXME: quick and dirt (and wrong) workaround to avoid division by zero
if (left == right) right += 0.1f;
if (up == down) down += 0.1f;
if (z == 30) z += 0.1f;
core::matrix4 tmp_matrix;
tmp_matrix.buildProjectionMatrixOrthoLH(left, right,
up, down,
30, z);
m_suncam->setProjectionMatrix(tmp_matrix, true);
m_scene_manager->setActiveCamera(m_suncam);
m_suncam->render();
sun_ortho_matrix[i] = getVideoDriver()->getTransform(video::ETS_PROJECTION);
sun_ortho_matrix[i] *= getVideoDriver()->getTransform(video::ETS_VIEW);
sun_ortho_matrix[i] *= getInvViewMatrix();
irr_driver->setPhase(SHADOW_PASS);
glDisable(GL_BLEND);
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
m_video_driver->setRenderTarget(ShadowRTT[i], true, true);
glDrawBuffer(GL_NONE);
m_scene_manager->drawAll(scene::ESNRP_SOLID);
glCullFace(GL_BACK);
}
camnode->setNearValue(oldnear);
camnode->setFarValue(oldfar);
camnode->render();
camera->activate();
m_scene_manager->drawAll(scene::ESNRP_CAMERA);
// Set up a nice ortho projection that contains our camera frustum
core::aabbox3df box = smallcambox;
box = box.intersect(trackbox);
m_suncam->getViewMatrix().transformBoxEx(box);
m_suncam->getViewMatrix().transformBoxEx(trackbox);
core::vector3df extent = trackbox.getExtent();
const float w = fabsf(extent.X);
const float h = fabsf(extent.Y);
float z = box.MaxEdge.Z;
// Snap to texels
const float units_per_w = w / m_rtts->getRTT(RTT_SHADOW)->getSize().Width;
const float units_per_h = h / m_rtts->getRTT(RTT_SHADOW)->getSize().Height;
float left = box.MinEdge.X;
float right = box.MaxEdge.X;
float up = box.MaxEdge.Y;
float down = box.MinEdge.Y;
left -= fmodf(left, units_per_w);
right -= fmodf(right, units_per_w);
up -= fmodf(up, units_per_h);
down -= fmodf(down, units_per_h);
z -= fmodf(z, 0.5f);
// FIXME: quick and dirt (and wrong) workaround to avoid division by zero
if (left == right) right += 0.1f;
if (up == down) down += 0.1f;
if (z == 30) z += 0.1f;
sun_ortho_matrix.buildProjectionMatrixOrthoLH(left, right,
up, down,
30, z);
m_suncam->setProjectionMatrix(sun_ortho_matrix, true);
m_scene_manager->setActiveCamera(m_suncam);
m_suncam->render();
//sun_ortho_matrix *= m_suncam->getViewMatrix();
/* ((SunLightProvider *) m_shaders->m_callbacks[ES_SUNLIGHT])->setShadowMatrix(ortho);
@ -608,24 +660,11 @@ void IrrDriver::renderShadows(//ShadowImportanceProvider * const sicb,
overridemat.Material.TextureLayer[2].AnisotropicFilter = 0;
overridemat.Material.Wireframe = 1;
overridemat.Enabled = true;*/
sun_ortho_matrix = getVideoDriver()->getTransform(video::ETS_PROJECTION);
sun_ortho_matrix *= getVideoDriver()->getTransform(video::ETS_VIEW);
irr_driver->setPhase(SHADOW_PASS);
glDisable(GL_BLEND);
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_SHADOW), true, true);
glDrawBuffer(GL_NONE);
m_scene_manager->drawAll(scene::ESNRP_SOLID);
glCullFace(GL_BACK);
// overridemat.EnablePasses = 0;
// overridemat.Enabled = false;
camera->activate();
m_scene_manager->drawAll(scene::ESNRP_CAMERA);
tick++;
tick %= 2;
}
// ----------------------------------------------------------------------------
@ -731,7 +770,6 @@ void IrrDriver::renderLights(const core::aabbox3df& cambox,
video::SOverrideMaterial &overridemat,
int cam, float dt)
{
sun_ortho_matrix *= getInvViewMatrix();
core::array<video::IRenderTarget> rtts;
// Diffuse
rtts.push_back(m_rtts->getRTT(RTT_TMP1));
@ -754,7 +792,7 @@ void IrrDriver::renderLights(const core::aabbox3df& cambox,
{
m_lights[i]->render();
if (UserConfigParams::m_shadows)
m_post_processing->renderShadowedSunlight(sun_ortho_matrix);
m_post_processing->renderShadowedSunlight(sun_ortho_matrix[0], sun_ortho_matrix[1], sun_ortho_matrix[2]);
else
m_post_processing->renderSunlight();
continue;

View File

@ -24,6 +24,7 @@
RTT::RTT()
{
initGL();
using namespace video;
using namespace core;
@ -36,8 +37,10 @@ RTT::RTT()
const dimension2du ssaosize = UserConfigParams::m_ssao == 2 ? res : quarter;
const u16 shadowside = 8192;
dimension2du shadowsize(shadowside, shadowside);
const u16 shadowside = 2048;
const dimension2du shadowsize0(shadowside, shadowside);
const dimension2du shadowsize1(shadowside / 2, shadowside / 2);
const dimension2du shadowsize2(shadowside / 4, shadowside / 4);
const dimension2du warpvsize(1, 512);
const dimension2du warphsize(512, 1);
@ -87,13 +90,9 @@ RTT::RTT()
rtts[RTT_SSAO] = drv->addRenderTargetTexture(ssaosize, "rtt.ssao", ECF_R8, stencil);
rtts[RTT_SHADOW] = drv->addRenderTargetTexture(shadowsize, "rtt.shadow", ECF_A8R8G8B8, stencil);
if(!rtts[RTT_SHADOW])
{
int n = UserConfigParams::m_shadows == 2 ? 2048 : 512;
shadowsize.set(n, n);
rtts[RTT_SHADOW] = drv->addRenderTargetTexture(shadowsize, "rtt.shadow", ECF_A8R8G8B8, stencil);
}
rtts[RTT_SHADOW0] = drv->addRenderTargetTexture(shadowsize0, "rtt.shadow0", ECF_A8R8G8B8, stencil);
rtts[RTT_SHADOW1] = drv->addRenderTargetTexture(shadowsize1, "rtt.shadow1", ECF_A8R8G8B8, stencil);
rtts[RTT_SHADOW2] = drv->addRenderTargetTexture(shadowsize2, "rtt.shadow2", ECF_A8R8G8B8, stencil);
rtts[RTT_WARPV] = drv->addRenderTargetTexture(warpvsize, "rtt.warpv", ECF_A8R8G8B8, stencil);
rtts[RTT_WARPH] = drv->addRenderTargetTexture(warphsize, "rtt.warph", ECF_A8R8G8B8, stencil);
@ -102,7 +101,7 @@ RTT::RTT()
if (((COpenGLDriver *) drv)->queryOpenGLFeature(COpenGLDriver::IRR_ARB_texture_rg))
{
// Use optimized formats if supported
rtts[RTT_COLLAPSE] = drv->addRenderTargetTexture(shadowsize, "rtt.collapse", ECF_R8, stencil);
rtts[RTT_COLLAPSE] = drv->addRenderTargetTexture(shadowsize0, "rtt.collapse", ECF_R8, stencil);
rtts[RTT_COLLAPSEV] = drv->addRenderTargetTexture(warpvsize, "rtt.collapsev", ECF_R8, stencil);
rtts[RTT_COLLAPSEH] = drv->addRenderTargetTexture(warphsize, "rtt.collapseh", ECF_R8, stencil);
@ -112,7 +111,7 @@ RTT::RTT()
rtts[RTT_HALF_SOFT] = drv->addRenderTargetTexture(half, "rtt.halfsoft", ECF_R8, stencil);
} else
{
rtts[RTT_COLLAPSE] = drv->addRenderTargetTexture(shadowsize, "rtt.collapse", ECF_A8R8G8B8, stencil);
rtts[RTT_COLLAPSE] = drv->addRenderTargetTexture(shadowsize0, "rtt.collapse", ECF_A8R8G8B8, stencil);
rtts[RTT_COLLAPSEV] = drv->addRenderTargetTexture(warpvsize, "rtt.collapsev", ECF_A8R8G8B8, stencil);
rtts[RTT_COLLAPSEH] = drv->addRenderTargetTexture(warphsize, "rtt.collapseh", ECF_A8R8G8B8, stencil);
@ -142,6 +141,19 @@ RTT::RTT()
drv->setRenderTarget(0, false, false);
drv->endScene();
glGenFramebuffers(1, &shadowFBO);
glBindFramebuffer(GL_FRAMEBUFFER, shadowFBO);
glGenTextures(1, &shadowColorTex);
glBindTexture(GL_TEXTURE_2D_ARRAY, shadowColorTex);
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_R8, 1024, 1024, 3, 0, GL_RED, GL_UNSIGNED_BYTE, 0);
glGenTextures(1, &shadowDepthTex);
glBindTexture(GL_TEXTURE_2D_ARRAY, shadowDepthTex);
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_DEPTH_COMPONENT24, 1024, 1024, 3, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0);
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, shadowColorTex, 0);
glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, shadowDepthTex, 0);
GLenum result = glCheckFramebufferStatus(GL_FRAMEBUFFER);
assert(result == GL_FRAMEBUFFER_COMPLETE_EXT);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
RTT::~RTT()

View File

@ -51,7 +51,9 @@ enum TypeRTT
RTT_SSAO,
RTT_SHADOW,
RTT_SHADOW0,
RTT_SHADOW1,
RTT_SHADOW2,
RTT_COLLAPSE,
RTT_COLLAPSEH,
RTT_COLLAPSEV,
@ -77,6 +79,7 @@ public:
private:
ITexture *rtts[RTT_COUNT];
unsigned shadowFBO, shadowColorTex, shadowDepthTex;
};
#endif

View File

@ -1289,8 +1289,12 @@ namespace FullScreenShader
GLuint ShadowedSunLightShader::Program;
GLuint ShadowedSunLightShader::uniform_ntex;
GLuint ShadowedSunLightShader::uniform_dtex;
GLuint ShadowedSunLightShader::uniform_shadowtex;
GLuint ShadowedSunLightShader::uniform_shadowmat;
GLuint ShadowedSunLightShader::uniform_shadowtex0;
GLuint ShadowedSunLightShader::uniform_shadowmat0;
GLuint ShadowedSunLightShader::uniform_shadowtex1;
GLuint ShadowedSunLightShader::uniform_shadowmat1;
GLuint ShadowedSunLightShader::uniform_shadowtex2;
GLuint ShadowedSunLightShader::uniform_shadowmat2;
GLuint ShadowedSunLightShader::uniform_direction;
GLuint ShadowedSunLightShader::uniform_col;
GLuint ShadowedSunLightShader::uniform_invproj;
@ -1301,23 +1305,31 @@ namespace FullScreenShader
Program = LoadProgram(file_manager->getAsset("shaders/screenquad.vert").c_str(), file_manager->getAsset("shaders/sunlightshadow.frag").c_str());
uniform_ntex = glGetUniformLocation(Program, "ntex");
uniform_dtex = glGetUniformLocation(Program, "dtex");
uniform_shadowtex = glGetUniformLocation(Program, "shadowtex");
uniform_shadowmat = glGetUniformLocation(Program, "shadowmat"),
uniform_shadowtex0 = glGetUniformLocation(Program, "shadowtex0");
uniform_shadowmat0 = glGetUniformLocation(Program, "shadowmat0");
uniform_shadowtex1 = glGetUniformLocation(Program, "shadowtex1");
uniform_shadowmat1 = glGetUniformLocation(Program, "shadowmat1");
uniform_shadowtex2 = glGetUniformLocation(Program, "shadowtex2");
uniform_shadowmat2 = glGetUniformLocation(Program, "shadowmat2");
uniform_direction = glGetUniformLocation(Program, "direction");
uniform_col = glGetUniformLocation(Program, "col");
uniform_invproj = glGetUniformLocation(Program, "invproj");
vao = createVAO(Program);
}
void ShadowedSunLightShader::setUniforms(const core::matrix4 &shadowmat, const core::vector3df &direction, const core::matrix4 &InvProjMatrix, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_shadowtex)
void ShadowedSunLightShader::setUniforms(const core::matrix4 &shadowmat0, const core::matrix4 &shadowmat1, const core::matrix4 &shadowmat2, const core::vector3df &direction, const core::matrix4 &InvProjMatrix, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_shadowtex0, unsigned TU_shadowtex1, unsigned TU_shadowtex2)
{
glUniformMatrix4fv(uniform_shadowmat, 1, GL_FALSE, shadowmat.pointer());
glUniformMatrix4fv(uniform_shadowmat0, 1, GL_FALSE, shadowmat0.pointer());
glUniformMatrix4fv(uniform_shadowmat1, 1, GL_FALSE, shadowmat1.pointer());
glUniformMatrix4fv(uniform_shadowmat2, 1, GL_FALSE, shadowmat2.pointer());
glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, InvProjMatrix.pointer());
glUniform3f(uniform_direction, direction.X, direction.Y, direction.Z);
glUniform3f(uniform_col, r, g, b);
glUniform1i(uniform_ntex, TU_ntex);
glUniform1i(uniform_dtex, TU_dtex);
glUniform1i(uniform_shadowtex, TU_shadowtex);
glUniform1i(uniform_shadowtex0, TU_shadowtex0);
glUniform1i(uniform_shadowtex1, TU_shadowtex1);
glUniform1i(uniform_shadowtex2, TU_shadowtex2);
}
GLuint Gaussian6HBlurShader::Program;

View File

@ -389,11 +389,11 @@ class ShadowedSunLightShader
{
public:
static GLuint Program;
static GLuint uniform_ntex, uniform_dtex, uniform_shadowtex, uniform_shadowmat, uniform_direction, uniform_col, uniform_invproj;
static GLuint uniform_ntex, uniform_dtex, uniform_shadowtex0, uniform_shadowmat0, uniform_shadowtex1, uniform_shadowmat1, uniform_shadowtex2, uniform_shadowmat2, uniform_direction, uniform_col, uniform_invproj;
static GLuint vao;
static void init();
static void setUniforms(const core::matrix4 &shadowmat, const core::vector3df &direction, const core::matrix4 &InvProjMatrix, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_shadowtex);
static void setUniforms(const core::matrix4 &shadowmat0, const core::matrix4 &shadowmat1, const core::matrix4 &shadowmat2, const core::vector3df &direction, const core::matrix4 &InvProjMatrix, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_shadowtex0, unsigned TU_shadowtex1, unsigned TU_shadowtex2);
};
class Gaussian6HBlurShader

View File

@ -50,7 +50,7 @@ SunNode::SunNode(scene::ISceneManager* mgr, scene::ISceneNode* parent, float r,
if (UserConfigParams::m_shadows)
{
m.setTexture(3, irr_driver->getRTT(RTT_SHADOW));
// m.setTexture(3, irr_driver->getRTT(RTT_SHADOW));
m.setTexture(4, irr_driver->getRTT(RTT_WARPH));
m.setTexture(5, irr_driver->getRTT(RTT_WARPV));

View File

@ -85,6 +85,7 @@ Event::Event(const Event& event)
Event::~Event()
{
delete peer;
peer = NULL;
m_packet = NULL;
}

View File

@ -40,6 +40,7 @@ GameSetup::~GameSetup()
delete m_players[i];
};
m_players.clear();
delete m_race_config;
}
//-----------------------------------------------------------------------------

View File

@ -51,7 +51,13 @@ STKPeer::~STKPeer()
m_peer = NULL;
if (m_player_profile)
delete m_player_profile;
m_player_profile = NULL;
m_player_profile = NULL;
if (m_client_server_token)
delete m_client_server_token;
m_client_server_token = NULL;
if (m_token_set)
delete m_token_set;
m_token_set = NULL;
}
//-----------------------------------------------------------------------------

View File

@ -270,7 +270,7 @@ namespace Online{
assert (profile != NULL);
if(!this->m_has_fetched_friends && profile->m_has_fetched_friends)
this->m_friends = profile->m_friends;
if(!this->m_has_fetched_achievements && profile->m_has_fetched_friends)
if(!this->m_has_fetched_achievements && profile->m_has_fetched_achievements)
this->m_achievements = profile->m_achievements;
if(this->m_relation_info == NULL && profile->m_relation_info != NULL)
{

View File

@ -102,6 +102,7 @@ void TriangleMesh::createCollisionShape(bool create_collision_object, const char
FILE *f = fopen(serialized_bhv, "rb");
fseek(f, 0, SEEK_END);
long pos = ftell(f);
assert(pos != -1L);
fseek(f, 0, SEEK_SET);
void* bytes = btAlignedAlloc(pos, 16);