Merge normals and depth RTT into a single one

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14754 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
vincentlj 2013-12-23 16:59:55 +00:00
parent 8b76971a54
commit 45db87de8a
20 changed files with 35 additions and 211 deletions

View File

@ -9,13 +9,9 @@ uniform vec3 col;
uniform vec3 campos; uniform vec3 campos;
uniform mat4 ipvmat; uniform mat4 ipvmat;
float decdepth(vec4 rgba) {
return dot(rgba, vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0));
}
void main() void main()
{ {
float z = decdepth(vec4(texture2D(tex, gl_TexCoord[0].xy).xyz, 0.0)); float z = texture2D(tex, gl_TexCoord[0].xy).a;
vec3 tmp = vec3(gl_TexCoord[0].xy, z); vec3 tmp = vec3(gl_TexCoord[0].xy, z);
tmp = tmp * 2.0 - 1.0; tmp = tmp * 2.0 - 1.0;

View File

@ -1,30 +1,13 @@
#version 130 #version 130
uniform float far; uniform float far;
uniform float objectid; uniform float objectid;
uniform sampler2D tex; uniform sampler2D tex;
noperspective in vec3 nor; noperspective in vec3 nor;
const float near = 1.0;
vec4 encdepth(float v) {
vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;
enc = fract(enc);
enc -= enc.yzww * vec4(1.0/255.0, 1.0/255.0, 1.0/255.0, 0.0);
return enc;
}
void main() void main()
{ {
vec4 color = texture2D(tex, gl_TexCoord[0].st); vec4 color = texture2D(tex, gl_TexCoord[0].st);
float linear_z = (2.0 * near) / (far + near - gl_FragCoord.z * (far - near));
// Tune for better inside range without losing outdoors
linear_z *= 2.0;
gl_FragData[0] = color; gl_FragData[0] = color;
gl_FragData[1] = vec4(0.5 * normalize(nor) + 0.5, linear_z); gl_FragData[1] = vec4(0.5 * normalize(nor) + 0.5, gl_FragCoord.z);
gl_FragData[2] = vec4(encdepth(gl_FragCoord.z).xyz, objectid);
} }

View File

@ -6,13 +6,6 @@ noperspective in vec3 tangent;
noperspective in vec3 bitangent; noperspective in vec3 bitangent;
noperspective in vec3 normal; noperspective in vec3 normal;
vec4 encdepth(float v) {
vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;
enc = fract(enc);
enc -= enc.yzww * vec4(1.0/255.0, 1.0/255.0, 1.0/255.0, 0.0);
return enc;
}
void main() void main()
{ {
// normal in Tangent Space // normal in Tangent Space
@ -28,6 +21,5 @@ void main()
gl_FragData[0] = texture2D (texture, gl_TexCoord[0].st); gl_FragData[0] = texture2D (texture, gl_TexCoord[0].st);
gl_FragData[1] = vec4(0.5 * FragmentNormal + 0.5, 1.0); gl_FragData[1] = vec4(0.5 * FragmentNormal + 0.5, gl_FragCoord.z);
gl_FragData[2] = vec4(encdepth(gl_FragCoord.z).xyz, 0.0);
} }

View File

@ -1,29 +1,12 @@
#version 130 #version 130
uniform sampler2D tex; uniform sampler2D tex;
uniform sampler2D lighttex; uniform sampler2D lighttex;
uniform float far;
uniform int hastex; uniform int hastex;
uniform int haslightmap; uniform int haslightmap;
uniform float objectid;
noperspective in vec3 nor; noperspective in vec3 nor;
const float near = 1.0;
vec4 encdepth(float v) {
vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;
enc = fract(enc);
enc -= enc.yzww * vec4(1.0/255.0, 1.0/255.0, 1.0/255.0, 0.0);
return enc;
}
void main() { void main() {
float linear_z = (2.0 * near) / (far + near - gl_FragCoord.z * (far - near));
// Tune for better inside range without losing outdoors
linear_z *= 2.0;
vec4 light = vec4(1.0); vec4 light = vec4(1.0);
if (haslightmap != 0) { if (haslightmap != 0) {
@ -35,7 +18,6 @@ void main() {
else else
gl_FragData[0] = gl_Color; gl_FragData[0] = gl_Color;
gl_FragData[1] = vec4(0.5 * normalize(nor) + 0.5, linear_z); gl_FragData[1] = vec4(0.5 * normalize(nor) + 0.5, gl_FragCoord.z);
gl_FragData[2] = vec4(encdepth(gl_FragCoord.z).xyz, objectid);
} }

View File

@ -1,27 +1,12 @@
#version 130 #version 130
uniform sampler2D tex; uniform sampler2D tex;
uniform float far;
uniform int hastex; uniform int hastex;
uniform float objectid; uniform float objectid;
noperspective in vec3 nor; noperspective in vec3 nor;
const float near = 1.0;
vec4 encdepth(float v) {
vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;
enc = fract(enc);
enc -= enc.yzww * vec4(1.0/255.0, 1.0/255.0, 1.0/255.0, 0.0);
return enc;
}
void main() { void main() {
float linear_z = (2.0 * near) / (far + near - gl_FragCoord.z * (far - near));
// Tune for better inside range without losing outdoors
linear_z *= 2.0;
//if (hastex != 0) { //if (hastex != 0) {
vec4 col = texture2D(tex, gl_TexCoord[0].xy); vec4 col = texture2D(tex, gl_TexCoord[0].xy);
@ -33,7 +18,6 @@ void main() {
// gl_FragData[0] = gl_Color; // gl_FragData[0] = gl_Color;
//} //}
gl_FragData[1] = vec4(0.5 * normalize(nor) + 0.5, linear_z); gl_FragData[1] = vec4(0.5 * normalize(nor) + 0.5, gl_FragCoord.z);
gl_FragData[2] = vec4(encdepth(gl_FragCoord.z).xyz, objectid);
} }

View File

@ -1,6 +1,5 @@
#version 130 #version 130
uniform sampler2D tex; uniform sampler2D tex;
uniform float far;
uniform int hastex; uniform int hastex;
uniform float objectid; uniform float objectid;
@ -8,22 +7,7 @@ noperspective in vec3 nor;
noperspective in vec3 eyenor; noperspective in vec3 eyenor;
noperspective in vec3 viewpos; noperspective in vec3 viewpos;
const float near = 1.0;
vec4 encdepth(float v) {
vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;
enc = fract(enc);
enc -= enc.yzww * vec4(1.0/255.0, 1.0/255.0, 1.0/255.0, 0.0);
return enc;
}
void main() { void main() {
float linear_z = (2.0 * near) / (far + near - gl_FragCoord.z * (far - near));
// Tune for better inside range without losing outdoors
linear_z *= 2.0;
float rim = 1.0 - dot(eyenor, viewpos); float rim = 1.0 - dot(eyenor, viewpos);
rim = smoothstep(0.5, 1.5, rim) * 0.35; rim = smoothstep(0.5, 1.5, rim) * 0.35;
@ -40,7 +24,6 @@ void main() {
gl_FragData[0] = gl_Color + vec4(vec3(rim), 0.0); gl_FragData[0] = gl_Color + vec4(vec3(rim), 0.0);
} }
gl_FragData[1] = vec4(0.5 * normalize(nor) + 0.5, linear_z); gl_FragData[1] = vec4(0.5 * normalize(nor) + 0.5, gl_FragCoord.z);
gl_FragData[2] = vec4(encdepth(gl_FragCoord.z).xyz, objectid);
} }

View File

@ -1,28 +1,11 @@
#version 130 #version 130
uniform sampler2D tex; uniform sampler2D tex;
uniform float far;
uniform float objectid;
noperspective in vec3 eyenor; noperspective in vec3 eyenor;
noperspective in vec3 viewpos; noperspective in vec3 viewpos;
noperspective in vec3 nor; noperspective in vec3 nor;
const float near = 1.0;
vec4 encdepth(float v) {
vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;
enc = fract(enc);
enc -= enc.yzww * vec4(1.0/255.0, 1.0/255.0, 1.0/255.0, 0.0);
return enc;
}
void main() { void main() {
float linear_z = (2.0 * near) / (far + near - gl_FragCoord.z * (far - near));
// Tune for better inside range without losing outdoors
linear_z *= 2.0;
// Calculate the spherical UV // Calculate the spherical UV
const vec3 forward = vec3(0.0, 0.0, 1.0); const vec3 forward = vec3(0.0, 0.0, 1.0);
@ -38,6 +21,5 @@ void main() {
gl_FragData[0] = detail0 * gl_Color; gl_FragData[0] = detail0 * gl_Color;
gl_FragData[1] = vec4(nor, linear_z); gl_FragData[1] = vec4(nor, gl_FragCoord.z);
gl_FragData[2] = vec4(encdepth(gl_FragCoord.z).xyz, objectid);
} }

View File

@ -1,5 +1,4 @@
uniform sampler2D ntex; uniform sampler2D ntex;
uniform sampler2D dtex;
uniform vec3 center; uniform vec3 center;
uniform vec3 col; uniform vec3 col;
@ -8,13 +7,9 @@ uniform float spec;
uniform vec2 screen; uniform vec2 screen;
uniform mat4 invproj; uniform mat4 invproj;
float decdepth(vec4 rgba) {
return dot(rgba, vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0));
}
void main() { void main() {
vec2 texc = gl_FragCoord.xy / screen; vec2 texc = gl_FragCoord.xy / screen;
float z = decdepth(vec4(texture2D(dtex, texc).xyz, 0.0)); float z = texture2D(ntex, texc).a;
vec4 xpos = 2.0 * vec4(texc, z, 1.0) - 1.0f; vec4 xpos = 2.0 * vec4(texc, z, 1.0) - 1.0f;
xpos = invproj * xpos; xpos = invproj * xpos;

View File

@ -1,7 +1,4 @@
#version 130 #version 130
uniform float far;
uniform float objectid;
uniform sampler2D tex_layout; uniform sampler2D tex_layout;
uniform sampler2D tex_detail0; uniform sampler2D tex_detail0;
uniform sampler2D tex_detail1; uniform sampler2D tex_detail1;
@ -11,22 +8,7 @@ uniform sampler2D tex_detail3;
noperspective in vec3 nor; noperspective in vec3 nor;
const float near = 1.0;
vec4 encdepth(float v) {
vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;
enc = fract(enc);
enc -= enc.yzww * vec4(1.0/255.0, 1.0/255.0, 1.0/255.0, 0.0);
return enc;
}
void main() { void main() {
float linear_z = (2.0 * near) / (far + near - gl_FragCoord.z * (far - near));
// Tune for better inside range without losing outdoors
linear_z *= 2.0;
// Splatting part // Splatting part
vec4 splatting = texture2D(tex_layout, gl_TexCoord[1].st); vec4 splatting = texture2D(tex_layout, gl_TexCoord[1].st);
vec4 detail0 = texture2D(tex_detail0, gl_TexCoord[0].st); vec4 detail0 = texture2D(tex_detail0, gl_TexCoord[0].st);
@ -45,6 +27,5 @@ void main() {
gl_FragData[0] = splatted; gl_FragData[0] = splatted;
gl_FragData[1] = vec4(normalize(nor) * 0.5 + 0.5, linear_z); gl_FragData[1] = vec4(normalize(nor) * 0.5 + 0.5, gl_FragCoord.z);
gl_FragData[2] = vec4(encdepth(gl_FragCoord.z).xyz, objectid);
} }

View File

@ -1,7 +1,5 @@
#version 120 #version 120
uniform sampler2D normals_and_depth; uniform sampler2D normals_and_depth;
uniform sampler2D depth;
uniform mat4 invprojm; uniform mat4 invprojm;
uniform mat4 projm; uniform mat4 projm;
uniform vec4 samplePoints[16]; uniform vec4 samplePoints[16];
@ -13,10 +11,6 @@ const float radius = .1f;
const float invSamples = strengh / SAMPLES; const float invSamples = strengh / SAMPLES;
float decdepth(vec4 rgba) {
return dot(rgba, vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0));
}
void main(void) void main(void)
{ {
// A set of Random(tm) vec2's. 8 1s, 6 0.7s, 2 0.4 // A set of Random(tm) vec2's. 8 1s, 6 0.7s, 2 0.4
@ -26,7 +20,7 @@ void main(void)
vec2 uv = gl_TexCoord[0].xy; vec2 uv = gl_TexCoord[0].xy;
vec4 cur = texture2D(normals_and_depth, uv); vec4 cur = texture2D(normals_and_depth, uv);
float curdepth = decdepth(vec4(texture2D(depth, uv).xyz, 0.0)); float curdepth = texture2D(normals_and_depth, uv).a;
vec4 FragPos = invprojm * (2.0f * vec4(uv, curdepth, 1.0f) - 1.0f); vec4 FragPos = invprojm * (2.0f * vec4(uv, curdepth, 1.0f) - 1.0f);
FragPos /= FragPos.w; FragPos /= FragPos.w;
@ -47,7 +41,7 @@ void main(void)
sampleProj /= sampleProj.w; sampleProj /= sampleProj.w;
// get the depth of the occluder fragment // get the depth of the occluder fragment
float occluderFragmentDepth = decdepth(vec4(texture2D(depth, (sampleProj.xy * 0.5) + 0.5).xyz, 0.0)); float occluderFragmentDepth = texture2D(normals_and_depth, (sampleProj.xy * 0.5) + 0.5).a;
// Position of the occluder fragment in worldSpace // Position of the occluder fragment in worldSpace
vec4 occluderPos = invprojm * vec4(sampleProj.xy, 2.0 * occluderFragmentDepth - 1.0, 1.0f); vec4 occluderPos = invprojm * vec4(sampleProj.xy, 2.0 * occluderFragmentDepth - 1.0, 1.0f);
occluderPos /= occluderPos.w; occluderPos /= occluderPos.w;

View File

@ -1,5 +1,4 @@
uniform sampler2D ntex; uniform sampler2D ntex;
uniform sampler2D dtex;
uniform sampler2D cloudtex; uniform sampler2D cloudtex;
uniform vec3 center; uniform vec3 center;
@ -9,14 +8,10 @@ uniform mat4 invproj;
uniform int hasclouds; uniform int hasclouds;
uniform vec2 wind; uniform vec2 wind;
float decdepth(vec4 rgba) {
return dot(rgba, vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0));
}
void main() { void main() {
vec2 texc = gl_FragCoord.xy / screen; vec2 texc = gl_FragCoord.xy / screen;
float z = decdepth(vec4(texture2D(dtex, texc).xyz, 0.0)); float z = texture2D(ntex, texc).a;
if (z < 0.03) if (z < 0.03)
{ {

View File

@ -109,16 +109,6 @@ void WaterShaderProvider::OnSetConstants(IMaterialRendererServices *srv, int)
void GrassShaderProvider::OnSetConstants(IMaterialRendererServices *srv, int userData) void GrassShaderProvider::OnSetConstants(IMaterialRendererServices *srv, int userData)
{ {
const float camfar = irr_driver->getSceneManager()->getActiveCamera()->getFarValue();
srv->setVertexShaderConstant("far", &camfar, 1);
float objectid = 0;
const stringc name = mat.TextureLayer[0].Texture->getName().getPath();
objectid = shash8((const u8 *) name.c_str(), name.size()) / 255.0f;
srv->setVertexShaderConstant("objectid", &objectid, 1);
IVideoDriver * const drv = srv->getVideoDriver(); IVideoDriver * const drv = srv->getVideoDriver();
const core::vector3df pos = drv->getTransform(ETS_WORLD).getTranslation(); const core::vector3df pos = drv->getTransform(ETS_WORLD).getTranslation();
const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f; const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f;
@ -165,14 +155,6 @@ void ColorLevelsProvider::OnSetConstants(IMaterialRendererServices *srv, int use
void SplattingProvider::OnSetConstants(IMaterialRendererServices *srv, int) void SplattingProvider::OnSetConstants(IMaterialRendererServices *srv, int)
{ {
const float camfar = irr_driver->getSceneManager()->getActiveCamera()->getFarValue();
srv->setVertexShaderConstant("far", &camfar, 1);
float objectid = 0;
const stringc name = mat.TextureLayer[0].Texture->getName().getPath();
objectid = shash8((const u8 *) name.c_str(), name.size()) / 255.0f;
srv->setVertexShaderConstant("objectid", &objectid, 1);
if (!firstdone) if (!firstdone)
{ {
s32 tex_layout = 1; s32 tex_layout = 1;
@ -324,23 +306,12 @@ void GlowProvider::OnSetConstants(IMaterialRendererServices *srv, int)
void ObjectPassProvider::OnSetConstants(IMaterialRendererServices *srv, int) void ObjectPassProvider::OnSetConstants(IMaterialRendererServices *srv, int)
{ {
const float camfar = irr_driver->getSceneManager()->getActiveCamera()->getFarValue();
srv->setVertexShaderConstant("far", &camfar, 1);
const int hastex = mat.TextureLayer[0].Texture != NULL; const int hastex = mat.TextureLayer[0].Texture != NULL;
srv->setVertexShaderConstant("hastex", &hastex, 1); srv->setVertexShaderConstant("hastex", &hastex, 1);
const int haslightmap = mat.TextureLayer[1].Texture != NULL; const int haslightmap = mat.TextureLayer[1].Texture != NULL;
srv->setVertexShaderConstant("haslightmap", &haslightmap, 1); srv->setVertexShaderConstant("haslightmap", &haslightmap, 1);
float objectid = 0;
if (hastex)
{
const stringc name = mat.TextureLayer[0].Texture->getName().getPath();
objectid = shash8((const u8 *) name.c_str(), name.size()) / 255.0f;
}
srv->setVertexShaderConstant("objectid", &objectid, 1);
//if (!firstdone) //if (!firstdone)
// Can't use the firstdone optimization, as this callback is used for multiple shaders // Can't use the firstdone optimization, as this callback is used for multiple shaders
{ {

View File

@ -424,8 +424,7 @@ void IrrDriver::initDevice()
m_mrt.clear(); m_mrt.clear();
m_mrt.reallocate(3); m_mrt.reallocate(3);
m_mrt.push_back(m_rtts->getRTT(RTT_COLOR)); m_mrt.push_back(m_rtts->getRTT(RTT_COLOR));
m_mrt.push_back(m_rtts->getRTT(RTT_NORMAL)); m_mrt.push_back(m_rtts->getRTT(RTT_NORMAL_AND_DEPTH));
m_mrt.push_back(m_rtts->getRTT(RTT_DEPTH));
irr::video::COpenGLDriver* gl_driver = (irr::video::COpenGLDriver*)m_device->getVideoDriver(); irr::video::COpenGLDriver* gl_driver = (irr::video::COpenGLDriver*)m_device->getVideoDriver();
gl_driver->extGlGenQueries(1, &m_lensflare_query); gl_driver->extGlGenQueries(1, &m_lensflare_query);

View File

@ -43,8 +43,7 @@ LightNode::LightNode(scene::ISceneManager* mgr, float radius, float r, float g,
mat.Lighting = false; mat.Lighting = false;
mat.MaterialType = irr_driver->getShader(ES_POINTLIGHT); mat.MaterialType = irr_driver->getShader(ES_POINTLIGHT);
mat.setTexture(0, irr_driver->getRTT(RTT_NORMAL)); mat.setTexture(0, irr_driver->getRTT(RTT_NORMAL_AND_DEPTH));
mat.setTexture(1, irr_driver->getRTT(RTT_DEPTH));
for (u32 i = 0; i < MATERIAL_MAX_TEXTURES; ++i) for (u32 i = 0; i < MATERIAL_MAX_TEXTURES; ++i)
{ {

View File

@ -217,16 +217,13 @@ void PostProcessing::renderSolid(const u32 cam)
GaussianBlurProvider * const gacb = (GaussianBlurProvider *) irr_driver-> GaussianBlurProvider * const gacb = (GaussianBlurProvider *) irr_driver->
getCallback(ES_GAUSSIAN3H); getCallback(ES_GAUSSIAN3H);
const TypeRTT curssao = tick ? RTT_SSAO2 : RTT_SSAO1;
if (UserConfigParams::m_ssao == 1) // SSAO low if (UserConfigParams::m_ssao == 1) // SSAO low
{ {
m_material.MaterialType = irr_driver->getShader(ES_SSAO); m_material.MaterialType = irr_driver->getShader(ES_SSAO);
m_material.setTexture(0, irr_driver->getRTT(RTT_NORMAL)); m_material.setTexture(0, irr_driver->getRTT(RTT_NORMAL_AND_DEPTH));
m_material.setTexture(1, irr_driver->getRTT(RTT_DEPTH));
drv->setRenderTarget(irr_driver->getRTT(curssao), true, false, drv->setRenderTarget(irr_driver->getRTT(RTT_SSAO), true, false,
SColor(255, 255, 255, 255)); SColor(255, 255, 255, 255));
drawQuad(cam, m_material); drawQuad(cam, m_material);
@ -236,21 +233,21 @@ void PostProcessing::renderSolid(const u32 cam)
gacb->setResolution(UserConfigParams::m_width / 4, gacb->setResolution(UserConfigParams::m_width / 4,
UserConfigParams::m_height / 4); UserConfigParams::m_height / 4);
m_material.MaterialType = irr_driver->getShader(ES_GAUSSIAN3V); m_material.MaterialType = irr_driver->getShader(ES_GAUSSIAN3V);
m_material.setTexture(0, irr_driver->getRTT(curssao)); m_material.setTexture(0, irr_driver->getRTT(RTT_SSAO));
drv->setRenderTarget(irr_driver->getRTT(RTT_QUARTER2), true, false); drv->setRenderTarget(irr_driver->getRTT(RTT_QUARTER2), true, false);
drawQuad(cam, m_material); drawQuad(cam, m_material);
m_material.MaterialType = irr_driver->getShader(ES_GAUSSIAN3H); m_material.MaterialType = irr_driver->getShader(ES_GAUSSIAN3H);
m_material.setTexture(0, irr_driver->getRTT(RTT_QUARTER2)); m_material.setTexture(0, irr_driver->getRTT(RTT_QUARTER2));
drv->setRenderTarget(irr_driver->getRTT(curssao), false, false); drv->setRenderTarget(irr_driver->getRTT(RTT_SSAO), false, false);
drawQuad(cam, m_material); drawQuad(cam, m_material);
} }
// Overlay // Overlay
m_material.MaterialType = EMT_ONETEXTURE_BLEND; m_material.MaterialType = EMT_ONETEXTURE_BLEND;
m_material.setTexture(0, irr_driver->getRTT(curssao)); m_material.setTexture(0, irr_driver->getRTT(RTT_SSAO));
m_material.setTexture(1, 0); m_material.setTexture(1, 0);
m_material.BlendOperation = EBO_ADD; m_material.BlendOperation = EBO_ADD;
m_material.MaterialTypeParam = pack_textureBlendFunc(EBF_DST_COLOR, EBF_ZERO); m_material.MaterialTypeParam = pack_textureBlendFunc(EBF_DST_COLOR, EBF_ZERO);
@ -264,10 +261,9 @@ void PostProcessing::renderSolid(const u32 cam)
} else if (UserConfigParams::m_ssao == 2) // SSAO high } else if (UserConfigParams::m_ssao == 2) // SSAO high
{ {
m_material.MaterialType = irr_driver->getShader(ES_SSAO); m_material.MaterialType = irr_driver->getShader(ES_SSAO);
m_material.setTexture(0, irr_driver->getRTT(RTT_NORMAL)); m_material.setTexture(0, irr_driver->getRTT(RTT_NORMAL_AND_DEPTH));
m_material.setTexture(1, irr_driver->getRTT(RTT_DEPTH));
drv->setRenderTarget(irr_driver->getRTT(curssao), true, false, drv->setRenderTarget(irr_driver->getRTT(RTT_SSAO), true, false,
SColor(255, 255, 255, 255)); SColor(255, 255, 255, 255));
drawQuad(cam, m_material); drawQuad(cam, m_material);
@ -277,21 +273,21 @@ void PostProcessing::renderSolid(const u32 cam)
gacb->setResolution(UserConfigParams::m_width, gacb->setResolution(UserConfigParams::m_width,
UserConfigParams::m_height); UserConfigParams::m_height);
m_material.MaterialType = irr_driver->getShader(ES_GAUSSIAN6V); m_material.MaterialType = irr_driver->getShader(ES_GAUSSIAN6V);
m_material.setTexture(0, irr_driver->getRTT(curssao)); m_material.setTexture(0, irr_driver->getRTT(RTT_SSAO));
drv->setRenderTarget(irr_driver->getRTT(RTT_TMP3), true, false); drv->setRenderTarget(irr_driver->getRTT(RTT_TMP3), true, false);
drawQuad(cam, m_material); drawQuad(cam, m_material);
m_material.MaterialType = irr_driver->getShader(ES_GAUSSIAN6H); m_material.MaterialType = irr_driver->getShader(ES_GAUSSIAN6H);
m_material.setTexture(0, irr_driver->getRTT(RTT_TMP3)); m_material.setTexture(0, irr_driver->getRTT(RTT_TMP3));
drv->setRenderTarget(irr_driver->getRTT(curssao), false, false); drv->setRenderTarget(irr_driver->getRTT(RTT_SSAO), false, false);
drawQuad(cam, m_material); drawQuad(cam, m_material);
} }
// Overlay // Overlay
m_material.MaterialType = EMT_ONETEXTURE_BLEND; m_material.MaterialType = EMT_ONETEXTURE_BLEND;
m_material.setTexture(0, irr_driver->getRTT(curssao)); m_material.setTexture(0, irr_driver->getRTT(RTT_SSAO));
m_material.setTexture(1, 0); m_material.setTexture(1, 0);
m_material.BlendOperation = EBO_ADD; m_material.BlendOperation = EBO_ADD;
m_material.MaterialTypeParam = pack_textureBlendFunc(EBF_DST_COLOR, EBF_ZERO); m_material.MaterialTypeParam = pack_textureBlendFunc(EBF_DST_COLOR, EBF_ZERO);
@ -306,7 +302,7 @@ void PostProcessing::renderSolid(const u32 cam)
if (World::getWorld()->getTrack()->isFogEnabled()) if (World::getWorld()->getTrack()->isFogEnabled())
{ {
m_material.MaterialType = irr_driver->getShader(ES_FOG); m_material.MaterialType = irr_driver->getShader(ES_FOG);
m_material.setTexture(0, irr_driver->getRTT(RTT_DEPTH)); m_material.setTexture(0, irr_driver->getRTT(RTT_NORMAL_AND_DEPTH));
// Overlay // Overlay
m_material.BlendOperation = EBO_ADD; m_material.BlendOperation = EBO_ADD;
@ -733,11 +729,11 @@ void PostProcessing::render()
if (irr_driver->getNormals()) if (irr_driver->getNormals())
{ {
m_material.MaterialType = irr_driver->getShader(ES_FLIP); m_material.MaterialType = irr_driver->getShader(ES_FLIP);
m_material.setTexture(0, irr_driver->getRTT(RTT_NORMAL)); m_material.setTexture(0, irr_driver->getRTT(RTT_NORMAL_AND_DEPTH));
} else if (irr_driver->getSSAOViz()) } else if (irr_driver->getSSAOViz())
{ {
m_material.MaterialType = irr_driver->getShader(ES_FLIP); m_material.MaterialType = irr_driver->getShader(ES_FLIP);
m_material.setTexture(0, irr_driver->getRTT(RTT_SSAO1)); m_material.setTexture(0, irr_driver->getRTT(RTT_SSAO));
} else if (irr_driver->getShadowViz()) } else if (irr_driver->getShadowViz())
{ {
m_material.MaterialType = irr_driver->getShader(ES_FLIP); m_material.MaterialType = irr_driver->getShader(ES_FLIP);

View File

@ -139,8 +139,7 @@ void IrrDriver::renderGLSL(float dt)
world->getClearColor()); world->getClearColor());
// Clear normal and depth to zero // Clear normal and depth to zero
m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_NORMAL), true, false, video::SColor(0,0,0,0)); m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_NORMAL_AND_DEPTH), true, false, video::SColor(0,0,0,0));
m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_DEPTH), true, false, video::SColor(0,0,0,0));
irr_driver->getVideoDriver()->enableMaterial2D(); irr_driver->getVideoDriver()->enableMaterial2D();
RaceGUIBase *rg = world->getRaceGUI(); RaceGUIBase *rg = world->getRaceGUI();

View File

@ -66,8 +66,7 @@ RTT::RTT()
rtts[RTT_TMP2] = drv->addRenderTargetTexture(res, "rtt.tmp2", ECF_A8R8G8B8, stencil); rtts[RTT_TMP2] = drv->addRenderTargetTexture(res, "rtt.tmp2", ECF_A8R8G8B8, stencil);
rtts[RTT_TMP3] = drv->addRenderTargetTexture(res, "rtt.tmp3", ECF_A8R8G8B8, stencil); rtts[RTT_TMP3] = drv->addRenderTargetTexture(res, "rtt.tmp3", ECF_A8R8G8B8, stencil);
rtts[RTT_TMP4] = drv->addRenderTargetTexture(res, "rtt.tmp4", ECF_A8R8G8B8, stencil); rtts[RTT_TMP4] = drv->addRenderTargetTexture(res, "rtt.tmp4", ECF_A8R8G8B8, stencil);
rtts[RTT_DEPTH] = drv->addRenderTargetTexture(res, "rtt.depth", ECF_A8R8G8B8, stencil); rtts[RTT_NORMAL_AND_DEPTH] = drv->addRenderTargetTexture(res, "rtt.normal_and_depth", ECF_A32B32G32R32F, stencil);
rtts[RTT_NORMAL] = drv->addRenderTargetTexture(res, "rtt.normal", ECF_A32B32G32R32F, stencil);
rtts[RTT_COLOR] = drv->addRenderTargetTexture(res, "rtt.color", ECF_A8R8G8B8, stencil); rtts[RTT_COLOR] = drv->addRenderTargetTexture(res, "rtt.color", ECF_A8R8G8B8, stencil);
rtts[RTT_HALF1] = drv->addRenderTargetTexture(half, "rtt.half1", ECF_A8R8G8B8, stencil); rtts[RTT_HALF1] = drv->addRenderTargetTexture(half, "rtt.half1", ECF_A8R8G8B8, stencil);
@ -83,8 +82,7 @@ RTT::RTT()
rtts[RTT_SIXTEENTH1] = drv->addRenderTargetTexture(sixteenth, "rtt.s1", ECF_A8R8G8B8, stencil); rtts[RTT_SIXTEENTH1] = drv->addRenderTargetTexture(sixteenth, "rtt.s1", ECF_A8R8G8B8, stencil);
rtts[RTT_SIXTEENTH2] = drv->addRenderTargetTexture(sixteenth, "rtt.s2", ECF_A8R8G8B8, stencil); rtts[RTT_SIXTEENTH2] = drv->addRenderTargetTexture(sixteenth, "rtt.s2", ECF_A8R8G8B8, stencil);
rtts[RTT_SSAO1] = drv->addRenderTargetTexture(ssaosize, "rtt.ssao1", ECF_A8R8G8B8, stencil); rtts[RTT_SSAO] = drv->addRenderTargetTexture(ssaosize, "rtt.ssao", ECF_A8R8G8B8, stencil);
rtts[RTT_SSAO2] = drv->addRenderTargetTexture(ssaosize, "rtt.ssao2", ECF_A8R8G8B8, stencil);
rtts[RTT_SHADOW] = drv->addRenderTargetTexture(shadowsize, "rtt.shadow", ECF_A8R8G8B8, stencil); rtts[RTT_SHADOW] = drv->addRenderTargetTexture(shadowsize, "rtt.shadow", ECF_A8R8G8B8, stencil);
rtts[RTT_WARPV] = drv->addRenderTargetTexture(warpvsize, "rtt.warpv", ECF_A8R8G8B8, stencil); rtts[RTT_WARPV] = drv->addRenderTargetTexture(warpvsize, "rtt.warpv", ECF_A8R8G8B8, stencil);
@ -125,8 +123,7 @@ RTT::RTT()
// Clear those that should be cleared // Clear those that should be cleared
drv->beginScene(false, false); drv->beginScene(false, false);
drv->setRenderTarget(rtts[RTT_SSAO1], true, false, SColor(255, 255, 255, 255)); drv->setRenderTarget(rtts[RTT_SSAO], true, false, SColor(255, 255, 255, 255));
drv->setRenderTarget(rtts[RTT_SSAO2], true, false, SColor(255, 255, 255, 255));
drv->setRenderTarget(rtts[RTT_COLLAPSEV], true, false); drv->setRenderTarget(rtts[RTT_COLLAPSEV], true, false);
drv->setRenderTarget(rtts[RTT_COLLAPSEH], true, false); drv->setRenderTarget(rtts[RTT_COLLAPSEH], true, false);

View File

@ -31,8 +31,7 @@ enum TypeRTT
RTT_TMP2, RTT_TMP2,
RTT_TMP3, RTT_TMP3,
RTT_TMP4, RTT_TMP4,
RTT_DEPTH, RTT_NORMAL_AND_DEPTH,
RTT_NORMAL,
RTT_COLOR, RTT_COLOR,
RTT_HALF1, RTT_HALF1,
@ -48,8 +47,7 @@ enum TypeRTT
RTT_SIXTEENTH1, RTT_SIXTEENTH1,
RTT_SIXTEENTH2, RTT_SIXTEENTH2,
RTT_SSAO1, RTT_SSAO,
RTT_SSAO2,
RTT_SHADOW, RTT_SHADOW,
RTT_COLLAPSE, RTT_COLLAPSE,

View File

@ -45,8 +45,7 @@ public:
mat.ZWriteEnable = false; mat.ZWriteEnable = false;
mat.MaterialType = irr_driver->getShader(ES_SHADOW_IMPORTANCE); mat.MaterialType = irr_driver->getShader(ES_SHADOW_IMPORTANCE);
mat.setTexture(0, irr_driver->getRTT(RTT_NORMAL)); mat.setTexture(0, irr_driver->getRTT(RTT_NORMAL_AND_DEPTH));
mat.setTexture(1, irr_driver->getRTT(RTT_DEPTH));
mat.setTexture(2, irr_driver->getRTT(RTT_COLOR)); mat.setTexture(2, irr_driver->getRTT(RTT_COLOR));
mat.setFlag(EMF_BILINEAR_FILTER, false); mat.setFlag(EMF_BILINEAR_FILTER, false);

View File

@ -43,8 +43,7 @@ SunNode::SunNode(scene::ISceneManager* mgr, float r, float g, float b):
SMaterial &m = sq->getMaterial(); SMaterial &m = sq->getMaterial();
m.MaterialType = irr_driver->getShader(ES_SUNLIGHT); m.MaterialType = irr_driver->getShader(ES_SUNLIGHT);
m.setTexture(0, irr_driver->getRTT(RTT_NORMAL)); m.setTexture(0, irr_driver->getRTT(RTT_NORMAL_AND_DEPTH));
m.setTexture(1, irr_driver->getRTT(RTT_DEPTH));
m.setTexture(2, irr_driver->getTexture(file_manager->getAsset(FileManager::TEXTURE,"cloudshadow.png"))); m.setTexture(2, irr_driver->getTexture(file_manager->getAsset(FileManager::TEXTURE,"cloudshadow.png")));
m.setFlag(EMF_BILINEAR_FILTER, false); m.setFlag(EMF_BILINEAR_FILTER, false);
m.MaterialTypeParam = pack_textureBlendFunc(EBF_ONE, EBF_ONE); m.MaterialTypeParam = pack_textureBlendFunc(EBF_ONE, EBF_ONE);