Merge remote-tracking branch 'origin/master' into new_login
This commit is contained in:
commit
370e2e4935
6
data/gui/debug_slider.stkgui
Normal file
6
data/gui/debug_slider.stkgui
Normal file
@ -0,0 +1,6 @@
|
||||
<stkgui>
|
||||
<div x="2%" y="10%" width="96%" height="80%" layout="vertical-row" >
|
||||
<label id="title" width="100%"/>
|
||||
<gauge id="value_slider" min_value="0" max_value="100" width="100%" />
|
||||
</div>
|
||||
</stkgui>
|
82
data/shaders/dof.frag
Normal file
82
data/shaders/dof.frag
Normal file
@ -0,0 +1,82 @@
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D dtex;
|
||||
uniform mat4 invprojm;
|
||||
uniform vec2 screen;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
float focalDepth = 10.;
|
||||
float maxblur = 1.;
|
||||
float range = 100.;
|
||||
|
||||
void main()
|
||||
{
|
||||
float curdepth = texture(dtex, uv).x;
|
||||
vec4 FragPos = invprojm * (2.0f * vec4(uv, curdepth, 1.0f) - 1.0f);
|
||||
FragPos /= FragPos.w;
|
||||
|
||||
float depth = FragPos.z;
|
||||
float blur = clamp(abs(depth - focalDepth) / range, -maxblur, maxblur);
|
||||
|
||||
vec2 offset = 10. / screen;
|
||||
|
||||
vec4 col = texture2D(tex, uv);
|
||||
vec4 colOriginal = col;
|
||||
// Weight from here http://artmartinsh.blogspot.fr/2010/02/glsl-lens-blur-filter-with-bokeh.html
|
||||
|
||||
col += texture2D(tex, uv + (vec2(0.0, 0.4) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(0.15, 0.37) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(0.29,0.29) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(-0.37,0.15) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(0.4, 0.0) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(0.37, -0.15) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(0.29, -0.29) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(-0.15, -0.37) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(0.0, -0.4) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(-0.15, 0.37) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(-0.29, 0.29) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(0.37, 0.15) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(-0.4, 0.0) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(-0.37, -0.15) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(-0.29, -0.29) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(0.15, -0.37) * offset) * blur);
|
||||
|
||||
col += texture2D(tex, uv + (vec2(0.15, 0.37) * offset) * blur * 0.9);
|
||||
col += texture2D(tex, uv + (vec2(-0.37, 0.15) * offset) * blur * 0.9);
|
||||
col += texture2D(tex, uv + (vec2(0.37, -0.15) * offset) * blur * 0.9);
|
||||
col += texture2D(tex, uv + (vec2(-0.15, -0.37) * offset) * blur * 0.9);
|
||||
col += texture2D(tex, uv + (vec2(-0.15, 0.37) * offset) * blur * 0.9);
|
||||
col += texture2D(tex, uv + (vec2(0.37, 0.15) * offset) * blur * 0.9);
|
||||
col += texture2D(tex, uv + (vec2(-0.37, -0.15) * offset) * blur * 0.9);
|
||||
col += texture2D(tex, uv + (vec2(0.15, -0.37) * offset) * blur * 0.9);
|
||||
|
||||
col += texture2D(tex, uv + (vec2(0.29, 0.29) * offset) * blur * 0.7);
|
||||
col += texture2D(tex, uv + (vec2(0.4, 0.0) * offset) * blur * 0.7);
|
||||
col += texture2D(tex, uv + (vec2(0.29, -0.29) * offset) * blur * 0.7);
|
||||
col += texture2D(tex, uv + (vec2(0.0, -0.4) * offset) * blur * 0.7);
|
||||
col += texture2D(tex, uv + (vec2(-0.29, 0.29) * offset) * blur * 0.7);
|
||||
col += texture2D(tex, uv + (vec2(-0.4, 0.0) * offset) * blur * 0.7);
|
||||
col += texture2D(tex, uv + (vec2(-0.29, -0.29) * offset) * blur * 0.7);
|
||||
col += texture2D(tex, uv + (vec2(0.0, 0.4) * offset) * blur *0.7);
|
||||
|
||||
col += texture2D(tex, uv + (vec2(0.29, 0.29) * offset) * blur * 0.4);
|
||||
col += texture2D(tex, uv + (vec2(0.4, 0.0) * offset) * blur * 0.4);
|
||||
col += texture2D(tex, uv + (vec2(0.29, -0.29) * offset) * blur * 0.4);
|
||||
col += texture2D(tex, uv + (vec2(0.0, -0.4) * offset) * blur * 0.4);
|
||||
col += texture2D(tex, uv + (vec2(-0.29, 0.29) * offset) * blur * 0.4);
|
||||
col += texture2D(tex, uv + (vec2(-0.4, 0.0) * offset) * blur * 0.4);
|
||||
col += texture2D(tex, uv + (vec2(-0.29, -0.29) * offset) * blur * 0.4);
|
||||
col += texture2D(tex, uv + (vec2(0.0, 0.4) * offset) * blur * 0.4);
|
||||
|
||||
col.rgb = col.rgb / 41.0;
|
||||
depth = clamp((FragPos.z/280), 0., 1.);
|
||||
depth = (1 - depth);
|
||||
vec3 final = colOriginal.rgb * depth + col.rgb * (1 - depth);
|
||||
|
||||
/*
|
||||
FragColor.xyz = vec3(depth);
|
||||
FragColor.a = 1.0;
|
||||
*/
|
||||
FragColor = vec4(final, 1.);
|
||||
}
|
@ -3,13 +3,12 @@ uniform sampler2D tex;
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
float delta = .1;
|
||||
float delta = .0001;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 weight = vec3(0.2125f, 0.7154f, 0.0721f);
|
||||
vec3 col = texture(tex, uv).xyz;
|
||||
// TODO: Investigate why color buffer has negative value sometimes
|
||||
float luma = max(dot(col, weight), 0.);
|
||||
float luma = dot(col, weight);
|
||||
FragColor = vec4(log(luma + delta));
|
||||
}
|
@ -1,31 +1,24 @@
|
||||
uniform sampler2D normalMap;
|
||||
uniform sampler2D DiffuseForAlpha;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec3 tangent;
|
||||
in vec3 bitangent;
|
||||
in vec2 uv;
|
||||
out vec3 EncodedNormal;
|
||||
#else
|
||||
varying vec3 tangent;
|
||||
varying vec3 bitangent;
|
||||
varying vec2 uv;
|
||||
#define EncodedNormal gl_FragColor.xy
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
vec2 EncodeNormal(vec3 n);
|
||||
|
||||
void main()
|
||||
{
|
||||
// normal in Tangent Space
|
||||
vec3 TS_normal = 2.0 * texture(normalMap, uv).rgb - 1.0;
|
||||
// Because of interpolation, we need to renormalize
|
||||
vec3 Frag_tangent = normalize(tangent);
|
||||
vec3 Frag_normal = normalize(cross(Frag_tangent, bitangent));
|
||||
vec3 Frag_bitangent = cross(Frag_normal, Frag_tangent);
|
||||
// normal in Tangent Space
|
||||
vec3 TS_normal = 2.0 * texture(normalMap, uv).rgb - 1.0;
|
||||
float alpha = texture(DiffuseForAlpha, uv).a;
|
||||
// Because of interpolation, we need to renormalize
|
||||
vec3 Frag_tangent = normalize(tangent);
|
||||
vec3 Frag_normal = normalize(cross(Frag_tangent, bitangent));
|
||||
vec3 Frag_bitangent = cross(Frag_normal, Frag_tangent);
|
||||
|
||||
vec3 FragmentNormal = TS_normal.x * Frag_tangent + TS_normal.y * Frag_bitangent - TS_normal.z * Frag_normal;
|
||||
EncodedNormal.xy = 0.5 * EncodeNormal(normalize(FragmentNormal)) + 0.5;
|
||||
EncodedNormal.z = 1.;
|
||||
vec3 FragmentNormal = TS_normal.x * Frag_tangent + TS_normal.y * Frag_bitangent - TS_normal.z * Frag_normal;
|
||||
EncodedNormal.xy = 0.5 * EncodeNormal(normalize(FragmentNormal)) + 0.5;
|
||||
EncodedNormal.z = exp2(10. * (1. - alpha) + 1.);
|
||||
}
|
||||
|
@ -66,5 +66,5 @@ void main(void)
|
||||
bl += isOccluded ? samplePoints[i].z * smoothstep(5 * radius, 0, distance(samplePos, FragPos)) : 0.;
|
||||
}
|
||||
|
||||
AO = 1.0 - bl * invSamples;
|
||||
AO = max(1.0 - bl * invSamples, 0.);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#define AUTO_EXPOSURE
|
||||
// From http://www.ceng.metu.edu.tr/~akyuz/files/hdrgpu.pdf
|
||||
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D logluminancetex;
|
||||
@ -9,18 +9,23 @@ out vec4 FragColor;
|
||||
vec3 getCIEYxy(vec3 rgbColor);
|
||||
vec3 getRGBFromCIEXxy(vec3 YxyColor);
|
||||
|
||||
float exposure = .4;
|
||||
float whitePoint = 1.5;
|
||||
float delta = .1;
|
||||
float exposure = .09;
|
||||
float Lwhite = 1.;
|
||||
float delta = .0001;
|
||||
float saturation = 1.;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 col = texture(tex, uv);
|
||||
float avgLuminance = textureLod(logluminancetex, uv, 10.).x;
|
||||
avgLuminance = exp(avgLuminance) - delta;
|
||||
float avgLw = textureLod(logluminancetex, uv, 10.).x;
|
||||
avgLw = max(exp(avgLw) - delta, delta);
|
||||
|
||||
vec3 Cw = getCIEYxy(col.xyz);
|
||||
float Lw = Cw.y;
|
||||
float L = Lw * exposure / avgLw;
|
||||
float Ld = L * (1. + L / (Lwhite * Lwhite));
|
||||
Ld /= (1. + L);
|
||||
|
||||
FragColor = vec4(Ld * pow(col.xyz / Lw, vec3(saturation)), 1.);
|
||||
|
||||
vec3 Yxy = getCIEYxy(col.xyz);
|
||||
float Lp = Yxy.r * exposure / avgLuminance;
|
||||
Yxy.r = (Lp * (1. * Lp / (whitePoint * whitePoint))) / (1. + Lp);
|
||||
FragColor.xyz = getRGBFromCIEXxy(Yxy);
|
||||
}
|
||||
|
@ -3,15 +3,10 @@
|
||||
|
||||
vec3 getCIEYxy(vec3 rgbColor)
|
||||
{
|
||||
// convert rgb to srgb
|
||||
vec3 sRGBColor = rgbColor;//vec3(pow(rgbColor.x, 1. / 2.2), pow(rgbColor.y, 1. / 2.2), pow(rgbColor.z, 1. / 2.2));
|
||||
|
||||
mat3 sRGB2XYZ = transpose(mat3(
|
||||
vec3(.4125, .2126, .0193),
|
||||
vec3(.3576, .7152, .1192),
|
||||
vec3(.1805, .0722, .9505)));
|
||||
|
||||
vec3 XYZ = sRGB2XYZ * sRGBColor;
|
||||
float sum = dot(vec3(1.), XYZ);
|
||||
return vec3(XYZ.y, XYZ.xy / sum);
|
||||
}
|
||||
return sRGB2XYZ * rgbColor;
|
||||
}
|
||||
|
@ -535,6 +535,19 @@ static void toneMap(GLuint fbo, GLuint rtt)
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
|
||||
static void renderDoF(GLuint fbo, GLuint rtt)
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
glViewport(0, 0, UserConfigParams::m_width, UserConfigParams::m_height);
|
||||
glUseProgram(FullScreenShader::DepthOfFieldShader::Program);
|
||||
glBindVertexArray(FullScreenShader::DepthOfFieldShader::vao);
|
||||
setTexture(0, rtt, GL_LINEAR, GL_LINEAR);
|
||||
setTexture(1, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::DepthOfFieldShader::setUniforms(irr_driver->getInvProjMatrix(), core::vector2df(UserConfigParams::m_width, UserConfigParams::m_height), 0, 1);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
|
||||
static void averageTexture(GLuint tex)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
@ -637,10 +650,81 @@ void PostProcessing::render()
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
/* computeLogLuminance(in_rtt);
|
||||
toneMap(out_fbo, in_rtt);
|
||||
renderDoF(out_fbo, in_rtt);
|
||||
std::swap(in_rtt, out_rtt);
|
||||
std::swap(in_fbo, out_fbo);*/
|
||||
std::swap(in_fbo, out_fbo);
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("- Godrays", 0xFF, 0x00, 0x00);
|
||||
if (UserConfigParams::m_light_shaft && m_sunpixels > 30)//World::getWorld()->getTrack()->hasGodRays() && ) // god rays
|
||||
{
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
// Grab the sky
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, out_fbo);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
irr_driver->renderSkybox();
|
||||
|
||||
// Set the sun's color
|
||||
const SColor col = World::getWorld()->getTrack()->getSunColor();
|
||||
ColorizeProvider * const colcb = (ColorizeProvider *)irr_driver->getCallback(ES_COLORIZE);
|
||||
colcb->setColor(col.getRed() / 255.0f, col.getGreen() / 255.0f, col.getBlue() / 255.0f);
|
||||
|
||||
// The sun interposer
|
||||
STKMeshSceneNode *sun = irr_driver->getSunInterposer();
|
||||
irr_driver->getSceneManager()->drawAll(ESNRP_CAMERA);
|
||||
irr_driver->setPhase(GLOW_PASS);
|
||||
sun->render();
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
// Fade to quarter
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_QUARTER1));
|
||||
glViewport(0, 0, UserConfigParams::m_width / 4, UserConfigParams::m_height / 4);
|
||||
renderGodFade(out_rtt, col);
|
||||
|
||||
// Blur
|
||||
renderGaussian3Blur(irr_driver->getFBO(FBO_QUARTER1), irr_driver->getRenderTargetTexture(RTT_QUARTER1),
|
||||
irr_driver->getFBO(FBO_QUARTER2), irr_driver->getRenderTargetTexture(RTT_QUARTER2),
|
||||
UserConfigParams::m_width / 4,
|
||||
UserConfigParams::m_height / 4);
|
||||
|
||||
|
||||
|
||||
// Calculate the sun's position in texcoords
|
||||
const core::vector3df pos = sun->getPosition();
|
||||
float ndc[4];
|
||||
core::matrix4 trans = camnode->getProjectionMatrix();
|
||||
trans *= camnode->getViewMatrix();
|
||||
|
||||
trans.transformVect(ndc, pos);
|
||||
|
||||
const float texh = m_vertices[cam].v1.TCoords.Y - m_vertices[cam].v0.TCoords.Y;
|
||||
const float texw = m_vertices[cam].v3.TCoords.X - m_vertices[cam].v0.TCoords.X;
|
||||
|
||||
const float sunx = ((ndc[0] / ndc[3]) * 0.5f + 0.5f) * texw;
|
||||
const float suny = ((ndc[1] / ndc[3]) * 0.5f + 0.5f) * texh;
|
||||
|
||||
// Rays please
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_QUARTER2));
|
||||
renderGodRay(irr_driver->getRenderTargetTexture(RTT_QUARTER1), core::vector2df(sunx, suny));
|
||||
|
||||
// Blur
|
||||
renderGaussian3Blur(irr_driver->getFBO(FBO_QUARTER2), irr_driver->getRenderTargetTexture(RTT_QUARTER2),
|
||||
irr_driver->getFBO(FBO_QUARTER1), irr_driver->getRenderTargetTexture(RTT_QUARTER1),
|
||||
UserConfigParams::m_width / 4,
|
||||
UserConfigParams::m_height / 4);
|
||||
|
||||
glViewport(0, 0, UserConfigParams::m_width, UserConfigParams::m_height);
|
||||
// Blend
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, in_fbo);
|
||||
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_QUARTER2));
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
// Simulate camera defects from there
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("- Bloom", 0xFF, 0x00, 0x00);
|
||||
if (UserConfigParams::m_bloom)
|
||||
@ -696,78 +780,12 @@ void PostProcessing::render()
|
||||
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_BLOOM_512));
|
||||
glDisable(GL_BLEND);
|
||||
} // end if bloom
|
||||
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("- Godrays", 0xFF, 0x00, 0x00);
|
||||
if (UserConfigParams::m_light_shaft && m_sunpixels > 30)//World::getWorld()->getTrack()->hasGodRays() && ) // god rays
|
||||
{
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
// Grab the sky
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, out_fbo);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
irr_driver->renderSkybox();
|
||||
|
||||
// Set the sun's color
|
||||
const SColor col = World::getWorld()->getTrack()->getSunColor();
|
||||
ColorizeProvider * const colcb = (ColorizeProvider *) irr_driver->getCallback(ES_COLORIZE);
|
||||
colcb->setColor(col.getRed() / 255.0f, col.getGreen() / 255.0f, col.getBlue() / 255.0f);
|
||||
|
||||
// The sun interposer
|
||||
STKMeshSceneNode *sun = irr_driver->getSunInterposer();
|
||||
irr_driver->getSceneManager()->drawAll(ESNRP_CAMERA);
|
||||
irr_driver->setPhase(GLOW_PASS);
|
||||
sun->render();
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
// Fade to quarter
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_QUARTER1));
|
||||
glViewport(0, 0, UserConfigParams::m_width / 4, UserConfigParams::m_height / 4);
|
||||
renderGodFade(out_rtt, col);
|
||||
|
||||
// Blur
|
||||
renderGaussian3Blur(irr_driver->getFBO(FBO_QUARTER1), irr_driver->getRenderTargetTexture(RTT_QUARTER1),
|
||||
irr_driver->getFBO(FBO_QUARTER2), irr_driver->getRenderTargetTexture(RTT_QUARTER2),
|
||||
UserConfigParams::m_width / 4,
|
||||
UserConfigParams::m_height / 4);
|
||||
|
||||
|
||||
|
||||
// Calculate the sun's position in texcoords
|
||||
const core::vector3df pos = sun->getPosition();
|
||||
float ndc[4];
|
||||
core::matrix4 trans = camnode->getProjectionMatrix();
|
||||
trans *= camnode->getViewMatrix();
|
||||
|
||||
trans.transformVect(ndc, pos);
|
||||
|
||||
const float texh = m_vertices[cam].v1.TCoords.Y - m_vertices[cam].v0.TCoords.Y;
|
||||
const float texw = m_vertices[cam].v3.TCoords.X - m_vertices[cam].v0.TCoords.X;
|
||||
|
||||
const float sunx = ((ndc[0] / ndc[3]) * 0.5f + 0.5f) * texw;
|
||||
const float suny = ((ndc[1] / ndc[3]) * 0.5f + 0.5f) * texh;
|
||||
|
||||
// Rays please
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_QUARTER2));
|
||||
renderGodRay(irr_driver->getRenderTargetTexture(RTT_QUARTER1), core::vector2df(sunx, suny));
|
||||
|
||||
// Blur
|
||||
renderGaussian3Blur(irr_driver->getFBO(FBO_QUARTER2), irr_driver->getRenderTargetTexture(RTT_QUARTER2),
|
||||
irr_driver->getFBO(FBO_QUARTER1), irr_driver->getRenderTargetTexture(RTT_QUARTER1),
|
||||
UserConfigParams::m_width / 4,
|
||||
UserConfigParams::m_height / 4);
|
||||
|
||||
glViewport(0, 0, UserConfigParams::m_width, UserConfigParams::m_height);
|
||||
// Blend
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, in_fbo);
|
||||
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_QUARTER2));
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
computeLogLuminance(in_rtt);
|
||||
toneMap(out_fbo, in_rtt);
|
||||
std::swap(in_rtt, out_rtt);
|
||||
std::swap(in_fbo, out_fbo);
|
||||
|
||||
if (UserConfigParams::m_motionblur && m_any_boost) // motion blur
|
||||
{
|
||||
@ -778,11 +796,6 @@ void PostProcessing::render()
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
}
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, out_fbo);
|
||||
renderColorLevel(in_rtt);
|
||||
std::swap(in_fbo, out_fbo);
|
||||
std::swap(in_rtt, out_rtt);
|
||||
|
||||
if (irr_driver->getNormals())
|
||||
{
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
|
@ -56,6 +56,8 @@ void IrrDriver::renderGLSL(float dt)
|
||||
{
|
||||
World *world = World::getWorld(); // Never NULL.
|
||||
|
||||
Track *track = world->getTrack();
|
||||
|
||||
// Overrides
|
||||
video::SOverrideMaterial &overridemat = m_video_driver->getOverrideMaterial();
|
||||
overridemat.EnablePasses = scene::ESNRP_SOLID | scene::ESNRP_TRANSPARENT;
|
||||
@ -184,8 +186,8 @@ void IrrDriver::renderGLSL(float dt)
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("- Shadow", 0x30, 0x6F, 0x90);
|
||||
// Shadows
|
||||
if (!m_mipviz && !m_wireframe && UserConfigParams::m_dynamic_lights && UserConfigParams::m_shadows)
|
||||
//&& World::getWorld()->getTrack()->hasShadows())
|
||||
if (!m_mipviz && !m_wireframe && UserConfigParams::m_dynamic_lights &&
|
||||
UserConfigParams::m_shadows && track->hasShadows())
|
||||
{
|
||||
renderShadows(camnode, camera);
|
||||
}
|
||||
|
@ -298,6 +298,7 @@ void Shaders::loadShaders()
|
||||
initShadowVPMUBO();
|
||||
FullScreenShader::BloomBlendShader::init();
|
||||
FullScreenShader::BloomShader::init();
|
||||
FullScreenShader::DepthOfFieldShader::init();
|
||||
FullScreenShader::ColorLevelShader::init();
|
||||
FullScreenShader::FogShader::init();
|
||||
FullScreenShader::Gaussian3HBlurShader::init();
|
||||
@ -518,6 +519,7 @@ namespace MeshShader
|
||||
GLuint NormalMapShader::uniform_MM;
|
||||
GLuint NormalMapShader::uniform_IMM;
|
||||
GLuint NormalMapShader::uniform_normalMap;
|
||||
GLuint NormalMapShader::uniform_DiffuseForAlpha;
|
||||
|
||||
void NormalMapShader::init()
|
||||
{
|
||||
@ -532,17 +534,19 @@ namespace MeshShader
|
||||
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
|
||||
uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix");
|
||||
uniform_normalMap = glGetUniformLocation(Program, "normalMap");
|
||||
uniform_DiffuseForAlpha = glGetUniformLocation(Program, "DiffuseForAlpha");
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
void NormalMapShader::setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &InverseModelMatrix, unsigned TU_normalMap)
|
||||
void NormalMapShader::setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &InverseModelMatrix, unsigned TU_normalMap, unsigned TU_uniform_DiffuseForAlpha)
|
||||
{
|
||||
if (UserConfigParams::m_ubo_disabled)
|
||||
bypassUBO(Program);
|
||||
glUniformMatrix4fv(uniform_MM, 1, GL_FALSE, ModelMatrix.pointer());
|
||||
glUniformMatrix4fv(uniform_IMM, 1, GL_FALSE, InverseModelMatrix.pointer());
|
||||
glUniform1i(uniform_normalMap, TU_normalMap);
|
||||
glUniform1i(uniform_DiffuseForAlpha, TU_uniform_DiffuseForAlpha);
|
||||
}
|
||||
|
||||
GLuint InstancedObjectPass1Shader::Program;
|
||||
@ -2085,6 +2089,33 @@ namespace FullScreenShader
|
||||
glUniform1i(uniform_logluminancetex, TU_loglum);
|
||||
}
|
||||
|
||||
GLuint DepthOfFieldShader::Program;
|
||||
GLuint DepthOfFieldShader::uniform_tex;
|
||||
GLuint DepthOfFieldShader::uniform_depth;
|
||||
GLuint DepthOfFieldShader::uniform_invproj;
|
||||
GLuint DepthOfFieldShader::uniform_screen;
|
||||
GLuint DepthOfFieldShader::vao;
|
||||
|
||||
void DepthOfFieldShader::init()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/dof.frag").c_str());
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_depth = glGetUniformLocation(Program, "dtex");
|
||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||
uniform_invproj = glGetUniformLocation(Program, "invprojm");
|
||||
vao = createVAO(Program);
|
||||
}
|
||||
|
||||
void DepthOfFieldShader::setUniforms(const core::matrix4 &invproj, const core::vector2df &screen, unsigned TU_tex, unsigned TU_dtex)
|
||||
{
|
||||
glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, invproj.pointer());
|
||||
glUniform2f(uniform_screen, screen.X, screen.Y);
|
||||
glUniform1i(uniform_tex, TU_tex);
|
||||
glUniform1i(uniform_depth, TU_dtex);
|
||||
}
|
||||
|
||||
GLuint ColorLevelShader::Program;
|
||||
GLuint ColorLevelShader::uniform_tex;
|
||||
GLuint ColorLevelShader::uniform_inlevel;
|
||||
|
@ -72,10 +72,10 @@ class NormalMapShader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_tangent, attrib_bitangent;
|
||||
static GLuint uniform_MM, uniform_IMM, uniform_normalMap;
|
||||
static GLuint uniform_MM, uniform_IMM, uniform_normalMap, uniform_DiffuseForAlpha;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &InverseModelMatrix, unsigned TU_normalMap);
|
||||
static void setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &InverseModelMatrix, unsigned TU_normalMap, unsigned TU_uniform_DiffuseForAlpha);
|
||||
};
|
||||
|
||||
class InstancedObjectPass1Shader
|
||||
@ -531,6 +531,17 @@ public:
|
||||
static void setUniforms(unsigned TU_tex, unsigned TU_logluminance);
|
||||
};
|
||||
|
||||
class DepthOfFieldShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_depth, uniform_screen, uniform_invproj;
|
||||
static GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &invproj, const core::vector2df &screen, unsigned TU_tex, unsigned TU_depth);
|
||||
};
|
||||
|
||||
class ColorLevelShader
|
||||
{
|
||||
public:
|
||||
|
@ -292,8 +292,10 @@ void drawNormalPass(const GLMesh &mesh, const core::matrix4 & ModelMatrix, const
|
||||
assert(mesh.textures[1]);
|
||||
compressTexture(mesh.textures[1], false);
|
||||
setTexture(0, getTextureGLuint(mesh.textures[1]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
compressTexture(mesh.textures[0], true);
|
||||
setTexture(1, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
|
||||
MeshShader::NormalMapShader::setUniforms(ModelMatrix, InverseModelMatrix, 0);
|
||||
MeshShader::NormalMapShader::setUniforms(ModelMatrix, InverseModelMatrix, 0, 1);
|
||||
|
||||
assert(mesh.vao_first_pass);
|
||||
glBindVertexArray(mesh.vao_first_pass);
|
||||
|
@ -52,6 +52,7 @@ ModalDialog::ModalDialog(const float percentWidth, const float percentHeight,
|
||||
{
|
||||
m_dialog_location = location;
|
||||
m_init = false;
|
||||
m_fade_background = true;
|
||||
m_percent_width = percentWidth;
|
||||
m_percent_height = percentHeight;
|
||||
m_irrlicht_window = NULL;
|
||||
|
@ -61,10 +61,10 @@ namespace GUIEngine
|
||||
float m_percent_width, m_percent_height;
|
||||
bool m_init;
|
||||
|
||||
|
||||
protected:
|
||||
irr::gui::IGUIWindow* m_irrlicht_window;
|
||||
irr::core::rect< irr::s32 > m_area;
|
||||
bool m_fade_background;
|
||||
|
||||
InputManager::InputDriverMode m_previous_mode;
|
||||
|
||||
@ -136,6 +136,8 @@ namespace GUIEngine
|
||||
*/
|
||||
virtual int getHeight() { return m_area.getHeight(); }
|
||||
|
||||
bool fadeBackground() const { return m_fade_background; }
|
||||
|
||||
bool isMyIrrChild(irr::gui::IGUIElement* widget) const { return m_irrlicht_window->isMyChild(widget); }
|
||||
};
|
||||
|
||||
|
@ -2177,7 +2177,8 @@ core::recti Skin::draw3DWindowBackground(IGUIElement *element,
|
||||
{
|
||||
if (ModalDialog::getCurrent() == NULL) return rect;
|
||||
|
||||
drawBGFadeColor();
|
||||
if (ModalDialog::getCurrent()->fadeBackground())
|
||||
drawBGFadeColor();
|
||||
|
||||
// draw frame
|
||||
if (m_dialog_size < 1.0f)
|
||||
|
86
src/states_screens/dialogs/debug_slider.cpp
Normal file
86
src/states_screens/dialogs/debug_slider.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2010-2013 Marianne Gagnon
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "states_screens/dialogs/debug_slider.hpp"
|
||||
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "guiengine/widgets/button_widget.hpp"
|
||||
#include "guiengine/widgets/label_widget.hpp"
|
||||
#include "guiengine/widgets/spinner_widget.hpp"
|
||||
#include "karts/abstract_kart.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
using namespace GUIEngine;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
DebugSliderDialog::DebugSliderDialog(std::string id, irr::core::stringw msg) :
|
||||
ModalDialog(0.85f, 0.25f, MODAL_DIALOG_LOCATION_BOTTOM)
|
||||
{
|
||||
//if (StateManager::get()->getGameState() == GUIEngine::GAME)
|
||||
//{
|
||||
// World::getWorld()->schedulePause(World::IN_GAME_MENU_PHASE);
|
||||
//}
|
||||
|
||||
m_id = id;
|
||||
m_fade_background = false;
|
||||
|
||||
loadFromFile("debug_slider.stkgui");
|
||||
|
||||
|
||||
LabelWidget* message = getWidget<LabelWidget>("title");
|
||||
message->setText( msg.c_str(), false );
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
DebugSliderDialog::~DebugSliderDialog()
|
||||
{
|
||||
//if (StateManager::get()->getGameState() == GUIEngine::GAME)
|
||||
//{
|
||||
// World::getWorld()->scheduleUnpause();
|
||||
//}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
void DebugSliderDialog::onEnterPressedInternal()
|
||||
{
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
GUIEngine::EventPropagation DebugSliderDialog::processEvent(const std::string& eventSource)
|
||||
{
|
||||
if (eventSource == "value_slider")
|
||||
{
|
||||
int value = getWidget<SpinnerWidget>("value_slider")->getValue();
|
||||
Log::info("DebugSlider", "Value for <%s> : %i", m_id.c_str(), value);
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
|
||||
return GUIEngine::EVENT_LET;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
void DebugSliderDialog::onUpdate(float dt)
|
||||
{
|
||||
}
|
51
src/states_screens/dialogs/debug_slider.hpp
Normal file
51
src/states_screens/dialogs/debug_slider.hpp
Normal file
@ -0,0 +1,51 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2010-2013 Marianne Gagnon
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
#ifndef HEADER_DEBUG_SLIDER_DIALOG_HPP
|
||||
#define HEADER_DEBUG_SLIDER_DIALOG_HPP
|
||||
|
||||
#include "guiengine/modaldialog.hpp"
|
||||
#include "utils/cpp2011.h"
|
||||
#include "utils/leak_check.hpp"
|
||||
|
||||
/**
|
||||
* \brief For internal value tweaking
|
||||
* \ingroup states_screens
|
||||
*/
|
||||
class DebugSliderDialog : public GUIEngine::ModalDialog
|
||||
{
|
||||
private:
|
||||
|
||||
std::string m_id;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
DebugSliderDialog(std::string id, ::core::stringw msg);
|
||||
|
||||
~DebugSliderDialog();
|
||||
|
||||
virtual void onEnterPressedInternal() OVERRIDE;
|
||||
virtual void onUpdate(float dt) OVERRIDE;
|
||||
|
||||
|
||||
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@ -29,6 +29,7 @@
|
||||
#include "race/history.hpp"
|
||||
#include "main_loop.hpp"
|
||||
#include "replay/replay_recorder.hpp"
|
||||
#include "states_screens/dialogs/debug_slider.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/profiler.hpp"
|
||||
#include <IGUIEnvironment.h>
|
||||
@ -77,7 +78,9 @@ enum DebugMenuCommand
|
||||
DEBUG_ATTACHMENT_BOMB,
|
||||
DEBUG_ATTACHMENT_ANVIL,
|
||||
DEBUG_TOGGLE_GUI,
|
||||
DEBUG_THROTTLE_FPS
|
||||
DEBUG_THROTTLE_FPS,
|
||||
DEBUG_TWEAK_SHADER_EXPOSURE,
|
||||
DEBUG_TWEAK_SHADER_LWHITE
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -178,6 +181,11 @@ bool onEvent(const SEvent &event)
|
||||
sub->addItem(L"Anvil", DEBUG_ATTACHMENT_ANVIL);
|
||||
sub->addItem(L"Parachute", DEBUG_ATTACHMENT_PARACHUTE);
|
||||
|
||||
mnu->addItem(L"Adjust shaders >", -1, true, true);
|
||||
sub = mnu->getSubMenu(3);
|
||||
sub->addItem(L"Exposure", DEBUG_TWEAK_SHADER_EXPOSURE);
|
||||
sub->addItem(L"LWhite", DEBUG_TWEAK_SHADER_LWHITE);
|
||||
|
||||
mnu->addItem(L"Profiler",DEBUG_PROFILER);
|
||||
if (UserConfigParams::m_profiler_enabled)
|
||||
mnu->addItem(L"Toggle capture profiler report", DEBUG_PROFILER_GENERATE_REPORT);
|
||||
@ -369,15 +377,15 @@ bool onEvent(const SEvent &event)
|
||||
}
|
||||
else if (cmdID == DEBUG_ATTACHMENT_ANVIL)
|
||||
{
|
||||
addAttachment(Attachment::ATTACH_ANVIL);
|
||||
addAttachment(Attachment::ATTACH_ANVIL);
|
||||
}
|
||||
else if (cmdID == DEBUG_ATTACHMENT_BOMB)
|
||||
{
|
||||
addAttachment(Attachment::ATTACH_BOMB);
|
||||
addAttachment(Attachment::ATTACH_BOMB);
|
||||
}
|
||||
else if (cmdID == DEBUG_ATTACHMENT_PARACHUTE)
|
||||
{
|
||||
addAttachment(Attachment::ATTACH_PARACHUTE);
|
||||
addAttachment(Attachment::ATTACH_PARACHUTE);
|
||||
}
|
||||
else if (cmdID == DEBUG_TOGGLE_GUI)
|
||||
{
|
||||
@ -394,6 +402,14 @@ bool onEvent(const SEvent &event)
|
||||
kart->getNode()->setVisible(gui->m_enabled);
|
||||
}
|
||||
}
|
||||
else if (cmdID == DEBUG_TWEAK_SHADER_EXPOSURE)
|
||||
{
|
||||
new DebugSliderDialog("exposure", "Exposure");
|
||||
}
|
||||
else if (cmdID == DEBUG_TWEAK_SHADER_LWHITE)
|
||||
{
|
||||
new DebugSliderDialog("lwhite", "LWhite");
|
||||
}
|
||||
}
|
||||
|
||||
return false; // event has been handled
|
||||
|
Loading…
Reference in New Issue
Block a user