Merge branch 'master' of github.com:supertuxkart/stk-code

This commit is contained in:
hiker 2014-06-03 13:50:52 +10:00
commit 71b79cc72f
3 changed files with 36 additions and 30 deletions

View File

@ -58,14 +58,19 @@ void main(void)
float r = radius / FragPos.z;
float phi = 30. * (x ^ y) + 10. * x * y;
float bl = 0.0;
float m = log2(r) + 6 + log2(invSamples);
float theta = 2. * 3.14 * tau * .5 * invSamples + phi;
vec2 rotations = vec2(cos(theta), sin(theta)) * screen;
vec2 offset = vec2(cos(invSamples), sin(invSamples));
for(int i = 0; i < SAMPLES; ++i) {
float alpha = (i + .5) * invSamples;
float theta = 2. * 3.14 * tau * alpha + phi;
rotations = vec2(rotations.x * offset.x - rotations.y * offset.y, rotations.x * offset.y + rotations.y * offset.x);
float h = r * alpha;
vec2 offset = h * vec2(cos(theta), sin(theta)) * screen;
vec2 offset = h * rotations;
float m = round(log2(h) + 6);
m = m + .5;
ivec2 ioccluder_uv = ivec2(x, y) + ivec2(offset);
if (ioccluder_uv.x < 0 || ioccluder_uv.x > screen.x || ioccluder_uv.y < 0 || ioccluder_uv.y > screen.y) continue;

View File

@ -760,32 +760,31 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
IVideoDriver* video_driver = irr_driver->getVideoDriver();
if (irr_driver->isGLSL())
{
// FIXME; cannot perform this check atm, because setMaterialProperties
// is sometimes called before calculating tangents
//if (mb->getVertexType() != video::EVT_TANGENTS)
//{
// Log::warn("material", "Requiring normal map without tangent enabled mesh for <%s>",
// m_texname.c_str());
//}
ITexture* tex = irr_driver->getTexture(m_normal_map_tex);
m->setTexture(1, tex);
if (mb->getVertexType() != video::EVT_TANGENTS)
{
Log::warn("material", "Requiring normal map without tangent enabled mesh for <%s>",
m_texname.c_str());
}
else
{
ITexture* tex = irr_driver->getTexture(m_normal_map_tex);
m->setTexture(1, tex);
bool with_lightmap = false;
bool with_lightmap = false;
//if (m_normal_map_shader_lightmap.size() > 0)
//{
// ITexture* lm_tex = irr_driver->getTexture(m_normal_map_shader_lightmap);
// m->setTexture(2, lm_tex);
// with_lightmap = true;
//}
//if (m_normal_map_shader_lightmap.size() > 0)
//{
// ITexture* lm_tex = irr_driver->getTexture(m_normal_map_shader_lightmap);
// m->setTexture(2, lm_tex);
// with_lightmap = true;
//}
// Material and shaders
m->MaterialType = irr_driver->getShader(
with_lightmap ? ES_NORMAL_MAP_LIGHTMAP : ES_NORMAL_MAP);
m->Lighting = false;
m->ZWriteEnable = true;
}
// Material and shaders
m->MaterialType = irr_driver->getShader(
with_lightmap ? ES_NORMAL_MAP_LIGHTMAP : ES_NORMAL_MAP);
m->Lighting = false;
m->ZWriteEnable = true;
}
else
{

View File

@ -22,7 +22,7 @@
#include "graphics/irr_driver.hpp"
#include "utils/log.hpp"
static GLuint generateRTT(const core::dimension2du &res, GLint internalFormat, GLint format, GLint type)
static GLuint generateRTT(const core::dimension2du &res, GLint internalFormat, GLint format, GLint type, unsigned mipmaplevel = 1)
{
GLuint result;
glGenTextures(1, &result);
@ -30,7 +30,7 @@ static GLuint generateRTT(const core::dimension2du &res, GLint internalFormat, G
if (irr_driver->getGLSLVersion() < 420)
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, res.Width, res.Height, 0, format, type, 0);
else
glTexStorage2D(GL_TEXTURE_2D, 1, internalFormat, res.Width, res.Height);
glTexStorage2D(GL_TEXTURE_2D, mipmaplevel, internalFormat, res.Width, res.Height);
return result;
}
@ -77,6 +77,8 @@ RTT::RTT(size_t width, size_t height)
const dimension2du warpvsize(1, 512);
const dimension2du warphsize(512, 1);
unsigned linear_depth_mip_levels = ceil(log2(max_(res.Width, res.Height)));
glGenTextures(1, &DepthStencilTexture);
glBindTexture(GL_TEXTURE_2D, DepthStencilTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL, res.Width, res.Height, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, 0);
@ -88,10 +90,10 @@ RTT::RTT(size_t width, size_t height)
RenderTargetTextures[RTT_TMP2] = generateRTT(res, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_TMP3] = generateRTT(res, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_TMP4] = generateRTT(res, GL_R16F, GL_RED, GL_FLOAT);
RenderTargetTextures[RTT_LINEAR_DEPTH] = generateRTT(res, GL_R32F, GL_RED, GL_FLOAT);
RenderTargetTextures[RTT_LINEAR_DEPTH] = generateRTT(res, GL_R32F, GL_RED, GL_FLOAT, linear_depth_mip_levels);
RenderTargetTextures[RTT_NORMAL_AND_DEPTH] = generateRTT(res, GL_RGBA16F, GL_RGBA, GL_FLOAT);
RenderTargetTextures[RTT_COLOR] = generateRTT(res, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_MLAA_COLORS] = generateRTT(res, GL_SRGB8, GL_BGR, GL_UNSIGNED_BYTE);
RenderTargetTextures[RTT_MLAA_COLORS] = generateRTT(res, GL_SRGB, GL_BGR, GL_UNSIGNED_BYTE);
RenderTargetTextures[RTT_SSAO] = generateRTT(res, GL_R16F, GL_RED, GL_FLOAT);
RenderTargetTextures[RTT_DISPLACE] = generateRTT(res, GL_RGBA16F, GL_BGRA, GL_FLOAT);