Merge remote branch 'origin/master' into leyyin
This commit is contained in:
commit
940a296366
@ -1,7 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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%" />
|
||||
<label id="Red" width="100%"/>
|
||||
<gauge id="red_slider" min_value="0" max_value="100" width="100%" />
|
||||
<label id="Green" width="100%"/>
|
||||
<gauge id="green_slider" min_value="0" max_value="100" width="100%" />
|
||||
<label id="Blue" width="100%"/>
|
||||
<gauge id="blue_slider" min_value="0" max_value="100" width="100%" />
|
||||
<label id="SSAO radius" width="100%"/>
|
||||
<gauge id="ssao_radius" min_value="0" max_value="100" width="100%" />
|
||||
<label id="SSAO k" width="100%"/>
|
||||
<gauge id="ssao_k" min_value="0" max_value="100" width="100%" />
|
||||
<label id="SSAO Sigma" width="100%"/>
|
||||
<gauge id="ssao_sigma" min_value="0" max_value="100" width="100%" />
|
||||
</div>
|
||||
</stkgui>
|
||||
|
22
data/shaders/normal_visualizer.geom
Normal file
22
data/shaders/normal_visualizer.geom
Normal file
@ -0,0 +1,22 @@
|
||||
layout(triangles) in;
|
||||
layout(line_strip, max_vertices = 6) out;
|
||||
|
||||
in vec3 nor[];
|
||||
|
||||
void main()
|
||||
{
|
||||
for(int i=0; i < gl_in.length(); i++)
|
||||
{
|
||||
vec4 pos = gl_in[i].gl_Position;
|
||||
gl_Position = pos;
|
||||
EmitVertex();
|
||||
|
||||
vec3 normal = normalize(nor[i]);
|
||||
pos = inverse(ProjectionMatrix) * pos;
|
||||
pos /= pos.w;
|
||||
gl_Position = ProjectionMatrix * (pos + .2 * vec4(normal, 0.));
|
||||
EmitVertex();
|
||||
|
||||
EndPrimitive();
|
||||
}
|
||||
}
|
@ -60,7 +60,7 @@ void main(void)
|
||||
vec2 uv = RHuv + offset * 0.01;
|
||||
|
||||
// Get world position and normal from the RSM sample
|
||||
float depth = texture(dtex, uv).z;
|
||||
float depth = texture(dtex, uv).x;
|
||||
vec4 RSMPos = inverse(RSMMatrix) * (2. * vec4(uv, depth, 1.) - 1.);
|
||||
RSMPos /= RSMPos.w;
|
||||
vec3 RSMAlbedo = texture(ctex, uv).xyz;
|
||||
@ -74,7 +74,7 @@ void main(void)
|
||||
float dist = distance(SamplePos, RSMPos.xyz) / R_wcs;
|
||||
// Determine the incident direction.
|
||||
// Avoid very close samples (and numerical instability problems)
|
||||
vec3 RSM_to_RH_dir = (dist <= 0.00) ? vec3(0.) : normalize(SamplePos - RSMPos.xyz);
|
||||
vec3 RSM_to_RH_dir = (dist <= 0.1) ? vec3(0.) : normalize(SamplePos - RSMPos.xyz);
|
||||
float dotprod = max(dot(RSM_to_RH_dir, normal.xyz), 0.);
|
||||
float factor = dotprod / (0.1 + dist * dist);
|
||||
|
||||
|
@ -10,5 +10,5 @@ void main()
|
||||
float r = texture(SHR, uvw).w;
|
||||
float g = texture(SHG, uvw).w;
|
||||
float b = texture(SHB, uvw).w;
|
||||
FragColor = max(vec4(r, g, b, 1.0), vec4(0.));
|
||||
FragColor = max(10. * vec4(r, g, b, 1.0), vec4(0.));
|
||||
}
|
||||
|
@ -15,6 +15,6 @@ void main(void)
|
||||
uvw = vec3(gx, gy, gz) / vec3(resolution);
|
||||
vec3 WorldPos = (2. * uvw - 1.) * extents;
|
||||
gl_Position = ProjectionMatrix * ViewMatrix * RHMatrix * vec4(WorldPos, 1.);
|
||||
gl_PointSize = 100. / gl_Position.w;
|
||||
gl_PointSize = 500. / gl_Position.w;
|
||||
|
||||
}
|
@ -8,6 +8,7 @@ layout (location = 1) out vec3 RSMNormals;
|
||||
|
||||
void main()
|
||||
{
|
||||
if (texture(tex, uv).a < .5) discard;
|
||||
RSMColor = texture(tex, uv).xyz * color.rgb;
|
||||
RSMNormals = .5 * normalize(nor) + .5;
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
uniform mat4 ModelMatrix;
|
||||
uniform mat4 InverseModelMatrix;
|
||||
uniform mat4 RSMMatrix;
|
||||
|
||||
uniform mat4 TextureMatrix =
|
||||
@ -13,24 +12,28 @@ layout(location = 0) in vec3 Position;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec4 Color;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
layout(location = 4) in vec2 SecondTexcoord;
|
||||
#else
|
||||
in vec3 Position;
|
||||
in vec3 Normal;
|
||||
in vec4 Color;
|
||||
in vec2 Texcoord;
|
||||
in vec2 SecondTexcoord;
|
||||
#endif
|
||||
|
||||
out vec3 nor;
|
||||
out vec2 uv;
|
||||
out vec2 uv_bis;
|
||||
out vec4 color;
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
mat4 ModelViewProjectionMatrix = RSMMatrix * ModelMatrix;
|
||||
mat4 TransposeInverseModel = transpose(InverseModelMatrix);
|
||||
mat4 TransposeInverseModel = transpose(inverse(ModelMatrix));
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
|
||||
nor = (vec4(Normal, 0.)).xyz;
|
||||
nor = (TransposeInverseModel * vec4(Normal, 0.)).xyz;
|
||||
uv = (TextureMatrix * vec4(Texcoord, 1., 1.)).xy;
|
||||
uv_bis = SecondTexcoord;
|
||||
color = Color.zyxw;
|
||||
}
|
||||
|
@ -3,10 +3,6 @@ uniform sampler2D tex_detail0;
|
||||
uniform sampler2D tex_detail1;
|
||||
uniform sampler2D tex_detail2;
|
||||
uniform sampler2D tex_detail3;
|
||||
uniform sampler2D DiffuseMap;
|
||||
uniform sampler2D SpecularMap;
|
||||
uniform sampler2D SSAO;
|
||||
uniform vec3 ambient;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
@ -18,26 +14,22 @@ varying vec2 uv_bis;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
vec3 getLightFactor(float specMapValue);
|
||||
|
||||
void main() {
|
||||
// Splatting part
|
||||
vec4 splatting = texture(tex_layout, uv_bis);
|
||||
vec4 detail0 = texture(tex_detail0, uv);
|
||||
vec4 detail1 = texture(tex_detail1, uv);
|
||||
vec4 detail2 = texture(tex_detail2, uv);
|
||||
vec4 detail3 = texture(tex_detail3, uv);
|
||||
vec4 detail4 = vec4(0.0);
|
||||
// Splatting part
|
||||
vec4 splatting = texture(tex_layout, uv_bis);
|
||||
vec4 detail0 = texture(tex_detail0, uv);
|
||||
vec4 detail1 = texture(tex_detail1, uv);
|
||||
vec4 detail2 = texture(tex_detail2, uv);
|
||||
vec4 detail3 = texture(tex_detail3, uv);
|
||||
vec4 detail4 = vec4(0.0);
|
||||
|
||||
vec4 splatted = splatting.r * detail0 +
|
||||
splatting.g * detail1 +
|
||||
splatting.b * detail2 +
|
||||
max(0., (1.0 - splatting.r - splatting.g - splatting.b)) * detail3;
|
||||
vec4 splatted = splatting.r * detail0 +
|
||||
splatting.g * detail1 +
|
||||
splatting.b * detail2 +
|
||||
max(0., (1.0 - splatting.r - splatting.g - splatting.b)) * detail3;
|
||||
|
||||
vec2 tc = gl_FragCoord.xy / screen;
|
||||
vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz;
|
||||
vec3 SpecularComponent = texture(SpecularMap, tc).xyz;
|
||||
float ao = texture(SSAO, tc).x;
|
||||
vec3 LightFactor = ao * ambient + DiffuseComponent + SpecularComponent;
|
||||
|
||||
FragColor = vec4(splatted.xyz * LightFactor, 1.);
|
||||
vec3 LightFactor = getLightFactor(1.);
|
||||
FragColor = vec4(splatted.xyz * LightFactor, 1.);
|
||||
}
|
||||
|
27
data/shaders/splatting_rsm.frag
Normal file
27
data/shaders/splatting_rsm.frag
Normal file
@ -0,0 +1,27 @@
|
||||
uniform sampler2D tex_layout;
|
||||
uniform sampler2D tex_detail0;
|
||||
uniform sampler2D tex_detail1;
|
||||
uniform sampler2D tex_detail2;
|
||||
uniform sampler2D tex_detail3;
|
||||
|
||||
in vec2 uv;
|
||||
in vec2 uv_bis;
|
||||
in vec3 nor;
|
||||
layout (location = 0) out vec3 RSMColor;
|
||||
layout (location = 1) out vec3 RSMNormals;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 splatting = texture(tex_layout, uv_bis);
|
||||
vec4 detail0 = texture(tex_detail0, uv);
|
||||
vec4 detail1 = texture(tex_detail1, uv);
|
||||
vec4 detail2 = texture(tex_detail2, uv);
|
||||
vec4 detail3 = texture(tex_detail3, uv);
|
||||
|
||||
vec4 splatted = splatting.r * detail0 +
|
||||
splatting.g * detail1 +
|
||||
splatting.b * detail2 +
|
||||
max(0., (1.0 - splatting.r - splatting.g - splatting.b)) * detail3;
|
||||
RSMColor = splatted.rgb;
|
||||
RSMNormals = .5 * normalize(nor) + .5;
|
||||
}
|
@ -2,15 +2,14 @@
|
||||
// and improvements here http://graphics.cs.williams.edu/papers/SAOHPG12/
|
||||
|
||||
uniform sampler2D dtex;
|
||||
uniform vec4 samplePoints[16];
|
||||
uniform float radius = 1.;
|
||||
uniform float k = 1.5;
|
||||
uniform float sigma = 1.;
|
||||
out float AO;
|
||||
|
||||
const float sigma = 1.;
|
||||
const float tau = 7.;
|
||||
const float beta = 0.002;
|
||||
const float epsilon = .00001;
|
||||
const float radius = 1.;
|
||||
const float k = 1.5;
|
||||
|
||||
#define SAMPLES 16
|
||||
|
||||
|
@ -1,58 +0,0 @@
|
||||
uniform sampler2D ntex;
|
||||
uniform sampler2D dtex;
|
||||
uniform sampler2DArrayShadow shadowtex;
|
||||
|
||||
uniform vec3 direction;
|
||||
uniform vec3 col;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 Diff;
|
||||
out vec4 Spec;
|
||||
|
||||
vec3 DecodeNormal(vec2 n);
|
||||
vec3 getSpecular(vec3 normal, vec3 eyedir, vec3 lightdir, vec3 color, float roughness);
|
||||
|
||||
vec3 getShadowFactor(vec3 pos)
|
||||
{
|
||||
vec3 cascadeColor[] = vec3[](
|
||||
vec3(1., 0., 0.),
|
||||
vec3(0., 1., 0.),
|
||||
vec3(0., 0., 1.),
|
||||
vec3(1., 1., 1.)
|
||||
);
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
vec4 shadowcoord = (ShadowViewProjMatrixes[i] * vec4(pos, 1.0));
|
||||
shadowcoord /= shadowcoord.w;
|
||||
vec2 shadowtexcoord = shadowcoord.xy * 0.5 + 0.5;
|
||||
if (shadowtexcoord.x < 0. || shadowtexcoord.x > 1. || shadowtexcoord.y < 0. || shadowtexcoord.y > 1.)
|
||||
continue;
|
||||
return cascadeColor[i] * texture(shadowtex, vec4(shadowtexcoord, float(i), 0.5 * shadowcoord.z + 0.5));
|
||||
}
|
||||
return vec3(1.);
|
||||
}
|
||||
|
||||
void main() {
|
||||
float z = texture(dtex, uv).x;
|
||||
vec4 xpos = 2.0 * vec4(uv, z, 1.0) - 1.0;
|
||||
xpos = InverseViewMatrix * InverseProjectionMatrix * xpos;
|
||||
xpos.xyz /= xpos.w;
|
||||
|
||||
vec3 norm = normalize(DecodeNormal(2. * texture(ntex, uv).xy - 1.));
|
||||
float roughness =texture(ntex, uv).z;
|
||||
vec3 eyedir = -normalize(xpos.xyz);
|
||||
|
||||
// Normalized on the cpu
|
||||
vec3 L = direction;
|
||||
|
||||
float NdotL = max(0., dot(norm, L));
|
||||
|
||||
vec3 Specular = getSpecular(norm, eyedir, L, col, roughness) * NdotL;
|
||||
vec3 outcol = NdotL * col;
|
||||
|
||||
// Shadows
|
||||
vec3 factor = getShadowFactor(xpos.xyz);
|
||||
Diff = vec4(factor * NdotL * col, 1.);
|
||||
Spec = vec4(factor * Specular, 1.);
|
||||
return;
|
||||
}
|
@ -669,7 +669,6 @@ void Camera::activate()
|
||||
{
|
||||
irr::scene::ISceneManager *sm = irr_driver->getSceneManager();
|
||||
sm->setActiveCamera(m_camera);
|
||||
sm->setAmbientLight(m_ambient_light);
|
||||
irr_driver->getVideoDriver()->setViewPort(m_viewport);
|
||||
|
||||
} // activate
|
||||
|
@ -1621,11 +1621,17 @@ void IrrDriver::onUnloadWorld()
|
||||
/** Sets the ambient light.
|
||||
* \param light The colour of the light to set.
|
||||
*/
|
||||
void IrrDriver::setAmbientLight(const video::SColor &light)
|
||||
void IrrDriver::setAmbientLight(const video::SColorf &light)
|
||||
{
|
||||
m_scene_manager->setAmbientLight(light);
|
||||
m_SH_dirty = true;
|
||||
} // setAmbientLight
|
||||
|
||||
video::SColorf IrrDriver::getAmbientLight() const
|
||||
{
|
||||
return m_scene_manager->getAmbientLight();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Displays the FPS on the screen.
|
||||
*/
|
||||
|
@ -213,14 +213,13 @@ private:
|
||||
Shaders *m_shaders;
|
||||
/** Wind. */
|
||||
Wind *m_wind;
|
||||
float m_exposure;
|
||||
float m_lwhite;
|
||||
/** RTTs. */
|
||||
RTT *m_rtts;
|
||||
std::vector<core::matrix4> sun_ortho_matrix;
|
||||
core::vector3df rh_extend;
|
||||
core::matrix4 rh_matrix;
|
||||
core::matrix4 rsm_matrix;
|
||||
core::vector2df m_current_screen_size;
|
||||
|
||||
/** Additional details to be shown in case that a texture is not found.
|
||||
* This is used to specify details like: "while loading kart '...'" */
|
||||
@ -290,25 +289,7 @@ public:
|
||||
return hasVSLayer;
|
||||
}
|
||||
|
||||
float getExposure() const
|
||||
{
|
||||
return m_exposure;
|
||||
}
|
||||
|
||||
void setExposure(float v)
|
||||
{
|
||||
m_exposure = v;
|
||||
}
|
||||
|
||||
float getLwhite() const
|
||||
{
|
||||
return m_lwhite;
|
||||
}
|
||||
|
||||
void setLwhite(float v)
|
||||
{
|
||||
m_lwhite = v;
|
||||
}
|
||||
video::SColorf getAmbientLight() const;
|
||||
|
||||
struct GlowData {
|
||||
scene::ISceneNode * node;
|
||||
@ -363,6 +344,10 @@ private:
|
||||
|
||||
STKRenderingPass m_phase;
|
||||
|
||||
float m_ssao_radius;
|
||||
float m_ssao_k;
|
||||
float m_ssao_sigma;
|
||||
|
||||
#ifdef DEBUG
|
||||
/** Used to visualise skeletons. */
|
||||
std::vector<irr::scene::IAnimatedMeshSceneNode*> m_debug_meshes;
|
||||
@ -377,6 +362,7 @@ private:
|
||||
void renderGLSL(float dt);
|
||||
void renderSolidFirstPass();
|
||||
void renderSolidSecondPass();
|
||||
void renderNormalsVisualisation();
|
||||
void renderTransparent();
|
||||
void renderParticles();
|
||||
void computeSunVisibility();
|
||||
@ -410,7 +396,7 @@ public:
|
||||
const std::string& mask_path);
|
||||
void displayFPS();
|
||||
bool OnEvent(const irr::SEvent &event);
|
||||
void setAmbientLight(const video::SColor &light);
|
||||
void setAmbientLight(const video::SColorf &light);
|
||||
std::string generateSmallerTextures(const std::string& dir);
|
||||
std::string getSmallerTexture(const std::string& texture);
|
||||
video::ITexture *getTexture(FileManager::AssetType type,
|
||||
@ -696,6 +682,37 @@ public:
|
||||
const core::matrix4 & getPreviousPVMatrix() { return m_previousProjViewMatrix; }
|
||||
const core::matrix4 &getProjViewMatrix() const { return m_ProjViewMatrix; }
|
||||
const core::matrix4 &getInvProjViewMatrix() const { return m_InvProjViewMatrix; }
|
||||
const core::vector2df &getCurrentScreenSize() const { return m_current_screen_size; }
|
||||
// ------------------------------------------------------------------------
|
||||
float getSSAORadius() const
|
||||
{
|
||||
return m_ssao_radius;
|
||||
}
|
||||
|
||||
void setSSAORadius(float v)
|
||||
{
|
||||
m_ssao_radius = v;
|
||||
}
|
||||
|
||||
float getSSAOK() const
|
||||
{
|
||||
return m_ssao_k;
|
||||
}
|
||||
|
||||
void setSSAOK(float v)
|
||||
{
|
||||
m_ssao_k = v;
|
||||
}
|
||||
|
||||
float getSSAOSigma() const
|
||||
{
|
||||
return m_ssao_sigma;
|
||||
}
|
||||
|
||||
void setSSAOSigma(float v)
|
||||
{
|
||||
m_ssao_sigma = v;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
/** Removes debug meshes. */
|
||||
void clearDebugMesh() { m_debug_meshes.clear(); }
|
||||
|
@ -278,11 +278,11 @@ void PostProcessing::renderSunlight()
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
|
||||
glUseProgram(FullScreenShader::SunLightShader::Program);
|
||||
glBindVertexArray(FullScreenShader::SunLightShader::vao);
|
||||
setTexture(0, irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), GL_NEAREST, GL_NEAREST);
|
||||
setTexture(1, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::SunLightShader::setUniforms(cb->getPosition(), cb->getRed(), cb->getGreen(), cb->getBlue(), 0, 1);
|
||||
glUseProgram(FullScreenShader::SunLightShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::SunLightShader::getInstance()->vao);
|
||||
setTexture(FullScreenShader::SunLightShader::getInstance()->TU_ntex, irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), GL_NEAREST, GL_NEAREST);
|
||||
setTexture(FullScreenShader::SunLightShader::getInstance()->TU_dtex, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::SunLightShader::getInstance()->setUniforms(cb->getPosition(), video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue()));
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
@ -296,9 +296,9 @@ void PostProcessing::renderShadowedSunlight(const std::vector<core::matrix4> &su
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
|
||||
setTexture(0, irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), GL_NEAREST, GL_NEAREST);
|
||||
setTexture(1, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
setTexture(FullScreenShader::ShadowedSunLightShader::getInstance()->TU_ntex, irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), GL_NEAREST, GL_NEAREST);
|
||||
setTexture(FullScreenShader::ShadowedSunLightShader::getInstance()->TU_dtex, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
glActiveTexture(GL_TEXTURE0 + FullScreenShader::ShadowedSunLightShader::getInstance()->TU_shadowtex);
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY, depthtex);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
@ -307,19 +307,10 @@ void PostProcessing::renderShadowedSunlight(const std::vector<core::matrix4> &su
|
||||
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
|
||||
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
|
||||
|
||||
if (irr_driver->getShadowViz())
|
||||
{
|
||||
glUseProgram(FullScreenShader::ShadowedSunLightDebugShader::Program);
|
||||
glBindVertexArray(FullScreenShader::ShadowedSunLightDebugShader::vao);
|
||||
FullScreenShader::ShadowedSunLightDebugShader::setUniforms(cb->getPosition(), cb->getRed(), cb->getGreen(), cb->getBlue(), 0, 1, 2);
|
||||
glUseProgram(FullScreenShader::ShadowedSunLightShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::ShadowedSunLightShader::getInstance()->vao);
|
||||
FullScreenShader::ShadowedSunLightShader::getInstance()->setUniforms(cb->getPosition(), video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue()));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
glUseProgram(FullScreenShader::ShadowedSunLightShader::Program);
|
||||
glBindVertexArray(FullScreenShader::ShadowedSunLightShader::vao);
|
||||
FullScreenShader::ShadowedSunLightShader::setUniforms(cb->getPosition(), cb->getRed(), cb->getGreen(), cb->getBlue(), 0, 1, 2);
|
||||
}
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
@ -534,16 +525,13 @@ void PostProcessing::renderSSAO()
|
||||
if (!noise_tex)
|
||||
noise_tex = irr_driver->getTexture(file_manager->getAsset("textures/noise.png").c_str());
|
||||
|
||||
glUseProgram(FullScreenShader::SSAOShader::Program);
|
||||
glBindVertexArray(FullScreenShader::SSAOShader::vao);
|
||||
glUseProgram(FullScreenShader::SSAOShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::SSAOShader::getInstance()->vao);
|
||||
|
||||
setTexture(0, irr_driver->getRenderTargetTexture(RTT_LINEAR_DEPTH), GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST);
|
||||
setTexture(FullScreenShader::SSAOShader::getInstance()->TU_dtex, irr_driver->getRenderTargetTexture(RTT_LINEAR_DEPTH), GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
setTexture(1, getTextureGLuint(noise_tex), GL_LINEAR, GL_LINEAR);
|
||||
|
||||
FullScreenShader::SSAOShader::setUniforms(core::vector2df(float(UserConfigParams::m_width),
|
||||
float(UserConfigParams::m_height)),
|
||||
0, 1);
|
||||
FullScreenShader::SSAOShader::getInstance()->setUniforms(irr_driver->getSSAORadius(), irr_driver->getSSAOK(), irr_driver->getSSAOSigma());
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
}
|
||||
@ -645,11 +633,10 @@ static void renderGodRay(GLuint tex, const core::vector2df &sunpos)
|
||||
static void toneMap(FrameBuffer &fbo, GLuint rtt)
|
||||
{
|
||||
fbo.Bind();
|
||||
glUseProgram(FullScreenShader::ToneMapShader::Program);
|
||||
glBindVertexArray(FullScreenShader::ToneMapShader::vao);
|
||||
setTexture(0, rtt, GL_NEAREST, GL_NEAREST);
|
||||
setTexture(1, irr_driver->getRenderTargetTexture(RTT_LOG_LUMINANCE), GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST);
|
||||
FullScreenShader::ToneMapShader::setUniforms(irr_driver->getExposure(), irr_driver->getLwhite(), 0, 1);
|
||||
glUseProgram(FullScreenShader::ToneMapShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::ToneMapShader::getInstance()->vao);
|
||||
setTexture(FullScreenShader::ToneMapShader::getInstance()->TU_tex, rtt, GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::ToneMapShader::getInstance()->setUniforms();
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
}
|
||||
@ -657,11 +644,11 @@ static void toneMap(FrameBuffer &fbo, GLuint rtt)
|
||||
static void renderDoF(FrameBuffer &fbo, GLuint rtt)
|
||||
{
|
||||
fbo.Bind();
|
||||
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(0, 1);
|
||||
glUseProgram(FullScreenShader::DepthOfFieldShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::DepthOfFieldShader::getInstance()->vao);
|
||||
setTexture(FullScreenShader::DepthOfFieldShader::getInstance()->TU_tex, rtt, GL_LINEAR, GL_LINEAR);
|
||||
setTexture(FullScreenShader::DepthOfFieldShader::getInstance()->TU_depth, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::DepthOfFieldShader::getInstance()->setUniforms();
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
}
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "items/item_manager.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "physics/physics.hpp"
|
||||
#include "physics/triangle_mesh.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "utils/constants.hpp"
|
||||
#include "utils/helpers.hpp"
|
||||
@ -318,6 +319,13 @@ void IrrDriver::renderScene(scene::ICameraSceneNode * const camnode, unsigned po
|
||||
renderSolidSecondPass();
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
if (getNormals())
|
||||
{
|
||||
m_rtts->getFBO(FBO_NORMAL_AND_DEPTHS).Bind();
|
||||
renderNormalsVisualisation();
|
||||
m_rtts->getFBO(FBO_COLORS).Bind();
|
||||
}
|
||||
|
||||
if (UserConfigParams::m_dynamic_lights && World::getWorld() != NULL &&
|
||||
World::getWorld()->isFogEnabled())
|
||||
{
|
||||
@ -563,6 +571,8 @@ void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode, siz
|
||||
irr_driver->setViewMatrix(irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW));
|
||||
irr_driver->genProjViewMatrix();
|
||||
|
||||
m_current_screen_size = core::vector2df(float(width), float(height));
|
||||
|
||||
const float oldfar = camnode->getFarValue();
|
||||
const float oldnear = camnode->getNearValue();
|
||||
float FarValues[] =
|
||||
@ -592,8 +602,12 @@ void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode, siz
|
||||
|
||||
if (World::getWorld() && World::getWorld()->getTrack())
|
||||
{
|
||||
const Vec3 *vmin, *vmax;
|
||||
World::getWorld()->getTrack()->getAABB(&vmin, &vmax);
|
||||
btVector3 btmin, btmax;
|
||||
if (World::getWorld()->getTrack()->getPtrTriangleMesh())
|
||||
{
|
||||
World::getWorld()->getTrack()->getTriangleMesh().getCollisionShape().getAabb(btTransform::getIdentity(), btmin, btmax);
|
||||
}
|
||||
const Vec3 vmin = btmin , vmax = btmax;
|
||||
|
||||
// Build the 3 ortho projection (for the 3 shadow resolution levels)
|
||||
for (unsigned i = 0; i < 4; i++)
|
||||
@ -631,7 +645,7 @@ void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode, siz
|
||||
memcpy(m_shadows_cam[i], tmp, 24 * sizeof(float));
|
||||
const core::aabbox3df smallcambox = camnode->
|
||||
getViewFrustum()->getBoundingBox();
|
||||
core::aabbox3df trackbox(vmin->toIrrVector(), vmax->toIrrVector() -
|
||||
core::aabbox3df trackbox(vmin.toIrrVector(), vmax.toIrrVector() -
|
||||
core::vector3df(0, 30, 0));
|
||||
|
||||
// Set up a nice ortho projection that contains our camera frustum
|
||||
@ -668,7 +682,7 @@ void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode, siz
|
||||
}
|
||||
|
||||
{
|
||||
core::aabbox3df trackbox(vmin->toIrrVector(), vmax->toIrrVector() -
|
||||
core::aabbox3df trackbox(vmin.toIrrVector(), vmax.toIrrVector() -
|
||||
core::vector3df(0, 30, 0));
|
||||
if (trackbox.MinEdge.X != trackbox.MaxEdge.X &&
|
||||
trackbox.MinEdge.Y != trackbox.MaxEdge.Y &&
|
||||
|
@ -332,6 +332,41 @@ void IrrDriver::renderSolidSecondPass()
|
||||
}
|
||||
}
|
||||
|
||||
template<enum E_VERTEX_TYPE VertexType, typename... TupleType>
|
||||
static void renderMeshNormals(std::vector<STK::Tuple<TupleType...> > &meshes)
|
||||
{
|
||||
glUseProgram(MeshShader::NormalVisualizer::getInstance()->Program);
|
||||
glBindVertexArray(getVAO(VertexType));
|
||||
for (unsigned i = 0; i < meshes.size(); i++)
|
||||
{
|
||||
GLMesh &mesh = *(STK::tuple_get<0>(meshes[i]));
|
||||
|
||||
if (mesh.VAOType != VertexType)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
Log::error("Materials", "Wrong vertex Type associed to pass 2 (hint texture : %s)", mesh.textures[0]->getName().getPath().c_str());
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
draw(MeshShader::NormalVisualizer::getInstance(), STK::tuple_get<0>(meshes[i]), STK::tuple_get<1>(meshes[i]), STK::tuple_get<2>(meshes[i]), video::SColor(255, 0, 255, 0));
|
||||
}
|
||||
}
|
||||
|
||||
void IrrDriver::renderNormalsVisualisation()
|
||||
{
|
||||
renderMeshNormals<video::EVT_STANDARD>(ListMatDefault::Arguments);
|
||||
renderMeshNormals<video::EVT_STANDARD>(ListMatAlphaRef::Arguments);
|
||||
renderMeshNormals<video::EVT_STANDARD>(ListMatSphereMap::Arguments);
|
||||
// renderMeshNormals<video::EVT_STANDARD>(ListMatGrass::Arguments);
|
||||
renderMeshNormals<video::EVT_2TCOORDS>(ListMatDetails::Arguments);
|
||||
renderMeshNormals<video::EVT_STANDARD>(ListMatUnlit::Arguments);
|
||||
renderMeshNormals<video::EVT_2TCOORDS>(ListMatSplatting::Arguments);
|
||||
renderMeshNormals<video::EVT_TANGENTS>(ListMatNormalMap::Arguments);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
static video::ITexture *displaceTex = 0;
|
||||
|
||||
void IrrDriver::renderTransparent()
|
||||
@ -507,10 +542,37 @@ void renderShadow(const std::vector<GLuint> TextureUnits, const std::vector<STK:
|
||||
}
|
||||
}
|
||||
|
||||
template<enum E_VERTEX_TYPE VertexType, typename... Args>
|
||||
|
||||
template<int...List>
|
||||
struct rsm_custom_unroll_args;
|
||||
|
||||
template<>
|
||||
struct rsm_custom_unroll_args<>
|
||||
{
|
||||
template<typename T, typename ...TupleTypes, typename ...Args>
|
||||
static void exec(const core::matrix4 &rsm_matrix, const STK::Tuple<TupleTypes...> &t, Args... args)
|
||||
{
|
||||
draw<T>(T::getInstance(), STK::tuple_get<0>(t), rsm_matrix, args...);
|
||||
}
|
||||
};
|
||||
|
||||
template<int N, int...List>
|
||||
struct rsm_custom_unroll_args<N, List...>
|
||||
{
|
||||
template<typename T, typename ...TupleTypes, typename ...Args>
|
||||
static void exec(const core::matrix4 &rsm_matrix, const STK::Tuple<TupleTypes...> &t, Args... args)
|
||||
{
|
||||
rsm_custom_unroll_args<List...>::template exec<T>(rsm_matrix, t, STK::tuple_get<N>(t), args...);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, enum E_VERTEX_TYPE VertexType, int... Selector, typename... Args>
|
||||
void drawRSM(const core::matrix4 & rsm_matrix, const std::vector<GLuint> TextureUnits, const std::vector<STK::Tuple<GLMesh *, core::matrix4, Args...> >&t)
|
||||
{
|
||||
glUseProgram(MeshShader::RSMShader::Program);
|
||||
glUseProgram(T::getInstance()->Program);
|
||||
glBindVertexArray(getVAO(VertexType));
|
||||
for (unsigned i = 0; i < t.size(); i++)
|
||||
{
|
||||
@ -522,7 +584,7 @@ void drawRSM(const core::matrix4 & rsm_matrix, const std::vector<GLuint> Texture
|
||||
compressTexture(mesh->textures[j], true);
|
||||
setTexture(TextureUnits[j], getTextureGLuint(mesh->textures[j]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
}
|
||||
draw<MeshShader::RSMShader>(mesh, rsm_matrix, STK::tuple_get<1>(t[i]));
|
||||
rsm_custom_unroll_args<Selector...>::template exec<T>(rsm_matrix, t[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -568,9 +630,18 @@ void IrrDriver::renderShadows()
|
||||
m_rtts->getRSM().Bind();
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
drawRSM<EVT_STANDARD>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::TU_tex }, ListMatDefault::Arguments);
|
||||
drawRSM<EVT_STANDARD>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::TU_tex }, ListMatSphereMap::Arguments);
|
||||
drawRSM<EVT_STANDARD>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::TU_tex }, ListMatUnlit::Arguments);
|
||||
drawRSM<EVT_2TCOORDS>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::TU_tex }, ListMatDetails::Arguments);
|
||||
drawRSM<EVT_2TCOORDS>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::TU_tex }, ListMatSplatting::Arguments);
|
||||
drawRSM<MeshShader::RSMShader, EVT_STANDARD, 3, 1>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::getInstance()->TU_tex }, ListMatDefault::Arguments);
|
||||
drawRSM<MeshShader::RSMShader, EVT_STANDARD, 3, 1>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::getInstance()->TU_tex }, ListMatAlphaRef::Arguments);
|
||||
// drawRSM<EVT_STANDARD, 2, 1>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::getInstance()->TU_tex }, ListMatSphereMap::Arguments);
|
||||
drawRSM<MeshShader::RSMShader, EVT_STANDARD, 3, 1>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::getInstance()->TU_tex }, ListMatUnlit::Arguments);
|
||||
drawRSM<MeshShader::RSMShader, EVT_2TCOORDS, 3, 1>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::getInstance()->TU_tex }, ListMatDetails::Arguments);
|
||||
drawRSM<MeshShader::SplattingRSMShader, EVT_2TCOORDS, 1>(rsm_matrix,
|
||||
std::vector<GLuint>{
|
||||
8,
|
||||
MeshShader::SplattingRSMShader::getInstance()->TU_layout,
|
||||
MeshShader::SplattingRSMShader::getInstance()->TU_detail0,
|
||||
MeshShader::SplattingRSMShader::getInstance()->TU_detail1,
|
||||
MeshShader::SplattingRSMShader::getInstance()->TU_detail2,
|
||||
MeshShader::SplattingRSMShader::getInstance()->TU_detail3},
|
||||
ListMatSplatting::Arguments);
|
||||
}
|
||||
|
@ -378,6 +378,14 @@ static void testSH(unsigned char *color[6], size_t width, size_t height,
|
||||
}
|
||||
}
|
||||
|
||||
static void swapPixels(char *old_img, char *new_img, unsigned stride, unsigned old_i, unsigned old_j, unsigned new_i, unsigned new_j)
|
||||
{
|
||||
new_img[4 * (stride * new_i + new_j)] = old_img[4 * (stride * old_i + old_j)];
|
||||
new_img[4 * (stride * new_i + new_j) + 1] = old_img[4 * (stride * old_i + old_j) + 1];
|
||||
new_img[4 * (stride * new_i + new_j) + 2] = old_img[4 * (stride * old_i + old_j) + 2];
|
||||
new_img[4 * (stride * new_i + new_j) + 3] = old_img[4 * (stride * old_i + old_j) + 3];
|
||||
}
|
||||
|
||||
/** Generate an opengl cubemap texture from 6 2d textures.
|
||||
Out of legacy the sequence of textures maps to :
|
||||
- 1st texture maps to GL_TEXTURE_CUBE_MAP_POSITIVE_Y
|
||||
@ -421,6 +429,19 @@ GLuint generateCubeMapFromTextures(const std::vector<video::ITexture *> &texture
|
||||
image->copyToScaling(rgba[i], w, h);
|
||||
image->drop();
|
||||
|
||||
if (i == 2 || i == 3)
|
||||
{
|
||||
char *tmp = new char[w * h * 4];
|
||||
memcpy(tmp, rgba[i], w * h * 4);
|
||||
for (unsigned x = 0; x < w; x++)
|
||||
{
|
||||
for (unsigned y = 0; y < h; y++)
|
||||
{
|
||||
swapPixels(tmp, rgba[i], h, x, y, (w - y - 1), x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, result);
|
||||
if (UserConfigParams::m_texture_compression)
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_COMPRESSED_SRGB_ALPHA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid*)rgba[i]);
|
||||
@ -485,8 +506,7 @@ void IrrDriver::generateDiffuseCoefficients()
|
||||
int sh_w = 16;
|
||||
int sh_h = 16;
|
||||
|
||||
const video::SColorf& ambientf = irr_driver->getSceneManager()->getAmbientLight();
|
||||
video::SColor ambient = ambientf.toSColor();
|
||||
video::SColor ambient = m_scene_manager->getAmbientLight().toSColor();
|
||||
|
||||
unsigned char *sh_rgba[6];
|
||||
for (unsigned i = 0; i < 6; i++)
|
||||
|
@ -375,7 +375,6 @@ void Shaders::loadShaders()
|
||||
initShadowVPMUBO();
|
||||
FullScreenShader::BloomBlendShader::init();
|
||||
FullScreenShader::BloomShader::init();
|
||||
FullScreenShader::DepthOfFieldShader::init();
|
||||
FullScreenShader::FogShader::init();
|
||||
FullScreenShader::Gaussian17TapHShader::init();
|
||||
FullScreenShader::ComputeGaussian17TapHShader::init();
|
||||
@ -389,24 +388,18 @@ void Shaders::loadShaders()
|
||||
FullScreenShader::PassThroughShader::init();
|
||||
FullScreenShader::LayerPassThroughShader::init();
|
||||
FullScreenShader::LinearizeDepthShader::init();
|
||||
FullScreenShader::SSAOShader::init();
|
||||
FullScreenShader::SunLightShader::init();
|
||||
FullScreenShader::DiffuseEnvMapShader::init();
|
||||
FullScreenShader::ShadowedSunLightShader::init();
|
||||
FullScreenShader::ShadowedSunLightDebugShader::init();
|
||||
FullScreenShader::RadianceHintsConstructionShader::init();
|
||||
FullScreenShader::RHDebug::init();
|
||||
FullScreenShader::GlobalIlluminationReconstructionShader::init();
|
||||
FullScreenShader::MotionBlurShader::init();
|
||||
FullScreenShader::GodFadeShader::init();
|
||||
FullScreenShader::GodRayShader::init();
|
||||
FullScreenShader::ToneMapShader::init();
|
||||
FullScreenShader::MLAAColorEdgeDetectionSHader::init();
|
||||
FullScreenShader::MLAABlendWeightSHader::init();
|
||||
FullScreenShader::MLAAGatherSHader::init();
|
||||
MeshShader::BubbleShader::init();
|
||||
LightShader::PointLightShader::init();
|
||||
MeshShader::RSMShader::init();
|
||||
MeshShader::SkyboxShader::init();
|
||||
MeshShader::ViewFrustrumShader::init();
|
||||
ParticleShader::FlipParticleRender::init();
|
||||
@ -457,7 +450,7 @@ void bypassUBO(GLuint Program)
|
||||
GLint IPM = glGetUniformLocation(Program, "InverseProjectionMatrix");
|
||||
glUniformMatrix4fv(IPM, 1, GL_FALSE, irr_driver->getInvProjMatrix().pointer());
|
||||
GLint Screen = glGetUniformLocation(Program, "screen");
|
||||
glUniform2f(Screen, UserConfigParams::m_width, UserConfigParams::m_height);
|
||||
glUniform2f(Screen, irr_driver->getCurrentScreenSize().X, irr_driver->getCurrentScreenSize().Y);
|
||||
}
|
||||
|
||||
namespace UtilShader
|
||||
@ -578,6 +571,11 @@ void glUniform3fWraper(GLuint a, float b, float c, float d)
|
||||
glUniform3f(a, b, c, d);
|
||||
}
|
||||
|
||||
void glUniform4iWraper(GLuint a, int b, int c, int d, int e)
|
||||
{
|
||||
glUniform4i(a, b, c, d, e);
|
||||
}
|
||||
|
||||
void glUniform2fWraper(GLuint a, float b, float c)
|
||||
{
|
||||
glUniform2f(a, b, c);
|
||||
@ -884,6 +882,7 @@ namespace MeshShader
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/splatting.frag").c_str());
|
||||
AssignUniforms("ModelMatrix");
|
||||
TU_tex_layout = 3;
|
||||
@ -1007,27 +1006,34 @@ namespace MeshShader
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
GLuint RSMShader::Program;
|
||||
GLuint RSMShader::uniform_MM;
|
||||
GLuint RSMShader::uniform_RSMMatrix;
|
||||
GLuint RSMShader::TU_tex;
|
||||
|
||||
void RSMShader::init()
|
||||
RSMShader::RSMShader()
|
||||
{
|
||||
if (irr_driver->getGLSLVersion() < 150)
|
||||
return;
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/rsm.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/rsm.frag").c_str());
|
||||
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
|
||||
uniform_RSMMatrix = glGetUniformLocation(Program, "RSMMatrix");
|
||||
AssignTextureUnit(Program, { TexUnit(TU_tex, "tex") });
|
||||
TU_tex = 0;
|
||||
AssignUniforms("RSMMatrix", "ModelMatrix", "TextureMatrix");
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
void RSMShader::setUniforms(const core::matrix4 &RSMMatrix, const core::matrix4 &ModelMatrix)
|
||||
SplattingRSMShader::SplattingRSMShader()
|
||||
{
|
||||
glUniformMatrix4fv(uniform_RSMMatrix, 1, GL_FALSE, RSMMatrix.pointer());
|
||||
glUniformMatrix4fv(uniform_MM, 1, GL_FALSE, ModelMatrix.pointer());
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/rsm.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/splatting_rsm.frag").c_str());
|
||||
TU_layout = 0;
|
||||
TU_detail0 = 1;
|
||||
TU_detail1 = 2;
|
||||
TU_detail2 = 3;
|
||||
TU_detail3 = 4;
|
||||
AssignUniforms("RSMMatrix", "ModelMatrix");
|
||||
AssignTextureUnit(Program, TexUnit(TU_layout, "tex_layout"), TexUnit(TU_detail0, "tex_detail0"), TexUnit(TU_detail1, "tex_detail1"), TexUnit(TU_detail2, "tex_detail2"), TexUnit(TU_detail3, "tex_detail3"));
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
InstancedShadowShader::InstancedShadowShader()
|
||||
@ -1227,6 +1233,18 @@ namespace MeshShader
|
||||
glUniform1i(uniform_tex, TU_tex);
|
||||
}
|
||||
|
||||
NormalVisualizer::NormalVisualizer()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_GEOMETRY_SHADER, file_manager->getAsset("shaders/normal_visualizer.geom").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/coloredquad.frag").c_str());
|
||||
AssignUniforms("ModelMatrix", "InverseModelMatrix", "color");
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
GLuint ViewFrustrumShader::Program;
|
||||
GLuint ViewFrustrumShader::attrib_position;
|
||||
GLuint ViewFrustrumShader::uniform_color;
|
||||
@ -1588,66 +1606,34 @@ namespace FullScreenShader
|
||||
glUniform1i(uniform_tex_512, TU_tex_512);
|
||||
}
|
||||
|
||||
GLuint ToneMapShader::Program;
|
||||
GLuint ToneMapShader::uniform_tex;
|
||||
GLuint ToneMapShader::uniform_logluminancetex;
|
||||
GLuint ToneMapShader::uniform_exposure;
|
||||
GLuint ToneMapShader::uniform_lwhite;
|
||||
GLuint ToneMapShader::vao;
|
||||
|
||||
void ToneMapShader::init()
|
||||
ToneMapShader::ToneMapShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getRGBfromCIEXxy.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getCIEXYZ.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/tonemap.frag").c_str());
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_logluminancetex = glGetUniformLocation(Program, "logluminancetex");
|
||||
uniform_exposure = glGetUniformLocation(Program, "exposure");
|
||||
uniform_lwhite = glGetUniformLocation(Program, "Lwhite");
|
||||
AssignUniforms();
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "text"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
}
|
||||
|
||||
void ToneMapShader::setUniforms(float exposure, float Lwhite, unsigned TU_tex, unsigned TU_loglum)
|
||||
{
|
||||
glUniform1i(uniform_tex, TU_tex);
|
||||
glUniform1i(uniform_logluminancetex, TU_loglum);
|
||||
glUniform1f(uniform_exposure, exposure);
|
||||
glUniform1f(uniform_lwhite, Lwhite);
|
||||
}
|
||||
|
||||
GLuint DepthOfFieldShader::Program;
|
||||
GLuint DepthOfFieldShader::uniform_tex;
|
||||
GLuint DepthOfFieldShader::uniform_depth;
|
||||
GLuint DepthOfFieldShader::vao;
|
||||
|
||||
void DepthOfFieldShader::init()
|
||||
DepthOfFieldShader::DepthOfFieldShader()
|
||||
{
|
||||
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");
|
||||
TU_tex = 0;
|
||||
TU_depth = 1;
|
||||
AssignUniforms();
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"), TexUnit(TU_depth, "dtex"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
void DepthOfFieldShader::setUniforms(unsigned TU_tex, unsigned TU_dtex)
|
||||
{
|
||||
glUniform1i(uniform_tex, TU_tex);
|
||||
glUniform1i(uniform_depth, TU_dtex);
|
||||
}
|
||||
|
||||
GLuint SunLightShader::Program;
|
||||
GLuint SunLightShader::uniform_ntex;
|
||||
GLuint SunLightShader::uniform_dtex;
|
||||
GLuint SunLightShader::uniform_direction;
|
||||
GLuint SunLightShader::uniform_col;
|
||||
GLuint SunLightShader::vao;
|
||||
|
||||
void SunLightShader::init()
|
||||
SunLightShader::SunLightShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
@ -1655,26 +1641,16 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getSpecular.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getPosFromUVDepth.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/sunlight.frag").c_str());
|
||||
uniform_ntex = glGetUniformLocation(Program, "ntex");
|
||||
uniform_dtex = glGetUniformLocation(Program, "dtex");
|
||||
uniform_direction = glGetUniformLocation(Program, "direction");
|
||||
uniform_col = glGetUniformLocation(Program, "col");
|
||||
TU_ntex = 0;
|
||||
TU_dtex = 1;
|
||||
AssignTextureUnit(Program, TexUnit(TU_ntex, "ntex"), TexUnit(TU_dtex, "dtex"));
|
||||
AssignUniforms("direction", "col");
|
||||
vao = createFullScreenVAO(Program);
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
void SunLightShader::setUniforms(const core::vector3df &direction, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex)
|
||||
{
|
||||
if (irr_driver->needUBOWorkaround())
|
||||
bypassUBO(Program);
|
||||
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);
|
||||
}
|
||||
|
||||
GLuint DiffuseEnvMapShader::Program;
|
||||
GLuint DiffuseEnvMapShader::uniform_ntex;
|
||||
GLuint DiffuseEnvMapShader::uniform_blueLmn;
|
||||
@ -1706,15 +1682,7 @@ namespace FullScreenShader
|
||||
glUniform1fv(uniform_redLmn, 9, redSHCoeff);
|
||||
}
|
||||
|
||||
GLuint ShadowedSunLightShader::Program;
|
||||
GLuint ShadowedSunLightShader::uniform_ntex;
|
||||
GLuint ShadowedSunLightShader::uniform_dtex;
|
||||
GLuint ShadowedSunLightShader::uniform_shadowtex;
|
||||
GLuint ShadowedSunLightShader::uniform_direction;
|
||||
GLuint ShadowedSunLightShader::uniform_col;
|
||||
GLuint ShadowedSunLightShader::vao;
|
||||
|
||||
void ShadowedSunLightShader::init()
|
||||
ShadowedSunLightShader::ShadowedSunLightShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
@ -1722,65 +1690,17 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getSpecular.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getPosFromUVDepth.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/sunlightshadow.frag").c_str());
|
||||
uniform_ntex = glGetUniformLocation(Program, "ntex");
|
||||
uniform_dtex = glGetUniformLocation(Program, "dtex");
|
||||
uniform_shadowtex = glGetUniformLocation(Program, "shadowtex");
|
||||
uniform_direction = glGetUniformLocation(Program, "direction");
|
||||
uniform_col = glGetUniformLocation(Program, "col");
|
||||
TU_ntex = 0;
|
||||
TU_dtex = 1;
|
||||
TU_shadowtex = 2;
|
||||
AssignTextureUnit(Program, TexUnit(TU_ntex, "ntex"), TexUnit(TU_dtex, "dtex"), TexUnit(TU_shadowtex, "shadowtex"));
|
||||
AssignUniforms("direction", "col");
|
||||
vao = createFullScreenVAO(Program);
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
void ShadowedSunLightShader::setUniforms(const core::vector3df &direction, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_shadowtex)
|
||||
{
|
||||
if (irr_driver->needUBOWorkaround())
|
||||
bypassUBO(Program);
|
||||
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);
|
||||
}
|
||||
|
||||
GLuint ShadowedSunLightDebugShader::Program;
|
||||
GLuint ShadowedSunLightDebugShader::uniform_ntex;
|
||||
GLuint ShadowedSunLightDebugShader::uniform_dtex;
|
||||
GLuint ShadowedSunLightDebugShader::uniform_shadowtex;
|
||||
GLuint ShadowedSunLightDebugShader::uniform_direction;
|
||||
GLuint ShadowedSunLightDebugShader::uniform_col;
|
||||
GLuint ShadowedSunLightDebugShader::vao;
|
||||
|
||||
void ShadowedSunLightDebugShader::init()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/decodeNormal.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getSpecular.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/sunlightshadowdebug.frag").c_str());
|
||||
uniform_ntex = glGetUniformLocation(Program, "ntex");
|
||||
uniform_dtex = glGetUniformLocation(Program, "dtex");
|
||||
uniform_shadowtex = glGetUniformLocation(Program, "shadowtex");
|
||||
uniform_direction = glGetUniformLocation(Program, "direction");
|
||||
uniform_col = glGetUniformLocation(Program, "col");
|
||||
vao = createVAO(Program);
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
void ShadowedSunLightDebugShader::setUniforms(const core::vector3df &direction, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_shadowtex)
|
||||
{
|
||||
if (irr_driver->needUBOWorkaround())
|
||||
bypassUBO(Program);
|
||||
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);
|
||||
}
|
||||
|
||||
GLuint RadianceHintsConstructionShader::Program;
|
||||
GLuint RadianceHintsConstructionShader::uniform_ctex;
|
||||
GLuint RadianceHintsConstructionShader::uniform_ntex;
|
||||
@ -2083,152 +2003,20 @@ namespace FullScreenShader
|
||||
vao = createVAO(Program);
|
||||
}
|
||||
|
||||
GLuint SSAOShader::Program;
|
||||
GLuint SSAOShader::uniform_ntex;
|
||||
GLuint SSAOShader::uniform_dtex;
|
||||
GLuint SSAOShader::uniform_noise_texture;
|
||||
GLuint SSAOShader::uniform_samplePoints;
|
||||
GLuint SSAOShader::vao;
|
||||
float SSAOShader::SSAOSamples[64];
|
||||
|
||||
void SSAOShader::init()
|
||||
SSAOShader::SSAOShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/decodeNormal.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getPosFromUVDepth.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/ssao.frag").c_str());
|
||||
uniform_ntex = glGetUniformLocation(Program, "ntex");
|
||||
uniform_dtex = glGetUniformLocation(Program, "dtex");
|
||||
uniform_noise_texture = glGetUniformLocation(Program, "noise_texture");
|
||||
uniform_samplePoints = glGetUniformLocation(Program, "samplePoints[0]");
|
||||
TU_dtex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_dtex, "dtex"));
|
||||
AssignUniforms("radius", "k", "sigma");
|
||||
vao = createFullScreenVAO(Program);
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
|
||||
// SSAOSamples[4 * i] and SSAOSamples[4 * i + 1] can be negative
|
||||
|
||||
SSAOSamples[0] = 0.135061f;
|
||||
SSAOSamples[1] = 0.207948f;
|
||||
SSAOSamples[2] = 0.968770f;
|
||||
SSAOSamples[3] = 0.983032f;
|
||||
|
||||
SSAOSamples[4] = 0.273456f;
|
||||
SSAOSamples[5] = -0.805390f;
|
||||
SSAOSamples[6] = 0.525898f;
|
||||
SSAOSamples[7] = 0.942808f;
|
||||
|
||||
SSAOSamples[8] = 0.443450f;
|
||||
SSAOSamples[9] = -0.803786f;
|
||||
SSAOSamples[10] = 0.396585f;
|
||||
SSAOSamples[11] = 0.007996f;
|
||||
|
||||
SSAOSamples[12] = 0.742420f;
|
||||
SSAOSamples[13] = -0.620072f;
|
||||
SSAOSamples[14] = 0.253621f;
|
||||
SSAOSamples[15] = 0.284829f;
|
||||
|
||||
SSAOSamples[16] = 0.892464f;
|
||||
SSAOSamples[17] = 0.046221f;
|
||||
SSAOSamples[18] = 0.448744f;
|
||||
SSAOSamples[19] = 0.753655f;
|
||||
|
||||
SSAOSamples[20] = 0.830350f;
|
||||
SSAOSamples[21] = -0.043593f;
|
||||
SSAOSamples[22] = 0.555535f;
|
||||
SSAOSamples[23] = 0.357463f;
|
||||
|
||||
SSAOSamples[24] = -0.600612f;
|
||||
SSAOSamples[25] = -0.536421f;
|
||||
SSAOSamples[26] = 0.592889f;
|
||||
SSAOSamples[27] = 0.670583f;
|
||||
|
||||
SSAOSamples[28] = -0.280658f;
|
||||
SSAOSamples[29] = 0.674894f;
|
||||
SSAOSamples[30] = 0.682458f;
|
||||
SSAOSamples[31] = 0.553362f;
|
||||
|
||||
SSAOSamples[32] = -0.654493f;
|
||||
SSAOSamples[33] = -0.140866f;
|
||||
SSAOSamples[34] = 0.742830f;
|
||||
SSAOSamples[35] = 0.699820f;
|
||||
|
||||
SSAOSamples[36] = 0.114730f;
|
||||
SSAOSamples[37] = 0.873130f;
|
||||
SSAOSamples[38] = 0.473794f;
|
||||
SSAOSamples[39] = 0.483901f;
|
||||
|
||||
SSAOSamples[40] = 0.699167f;
|
||||
SSAOSamples[41] = 0.632210f;
|
||||
SSAOSamples[42] = 0.333879f;
|
||||
SSAOSamples[43] = 0.010956f;
|
||||
|
||||
SSAOSamples[44] = 0.904603f;
|
||||
SSAOSamples[45] = 0.393410f;
|
||||
SSAOSamples[46] = 0.164080f;
|
||||
SSAOSamples[47] = 0.780297f;
|
||||
|
||||
SSAOSamples[48] = 0.631662f;
|
||||
SSAOSamples[49] = -0.405195f;
|
||||
SSAOSamples[50] = 0.660924f;
|
||||
SSAOSamples[51] = 0.865596f;
|
||||
|
||||
SSAOSamples[52] = -0.195668f;
|
||||
SSAOSamples[53] = 0.629185f;
|
||||
SSAOSamples[54] = 0.752223f;
|
||||
SSAOSamples[55] = 0.019013f;
|
||||
|
||||
SSAOSamples[56] = -0.511316f;
|
||||
SSAOSamples[57] = 0.635504f;
|
||||
SSAOSamples[58] = 0.578524f;
|
||||
SSAOSamples[59] = 0.605457f;
|
||||
|
||||
SSAOSamples[60] = -0.898843f;
|
||||
SSAOSamples[61] = 0.067382f;
|
||||
SSAOSamples[62] = 0.433061f;
|
||||
SSAOSamples[63] = 0.772942f;
|
||||
|
||||
// Generate another random distribution, if needed
|
||||
/* for (unsigned i = 0; i < 16; i++) {
|
||||
// Use double to avoid denorm and get a true uniform distribution
|
||||
// Generate z component between [0.1; 1] to avoid being too close from surface
|
||||
double z = rand();
|
||||
z /= RAND_MAX;
|
||||
z = 0.1 + 0.9 * z;
|
||||
|
||||
// Now generate x,y on the unit circle
|
||||
double x = rand();
|
||||
x /= RAND_MAX;
|
||||
x = 2 * x - 1;
|
||||
double y = rand();
|
||||
y /= RAND_MAX;
|
||||
y = 2 * y - 1;
|
||||
double xynorm = sqrt(x * x + y * y);
|
||||
x /= xynorm;
|
||||
y /= xynorm;
|
||||
// Now resize x,y so that norm(x,y,z) is one
|
||||
x *= sqrt(1. - z * z);
|
||||
y *= sqrt(1. - z * z);
|
||||
|
||||
// Norm factor
|
||||
double w = rand();
|
||||
w /= RAND_MAX;
|
||||
SSAOSamples[4 * i] = (float)x;
|
||||
SSAOSamples[4 * i + 1] = (float)y;
|
||||
SSAOSamples[4 * i + 2] = (float)z;
|
||||
SSAOSamples[4 * i + 3] = (float)w;
|
||||
}*/
|
||||
}
|
||||
|
||||
void SSAOShader::setUniforms(const core::vector2df &screen, unsigned TU_dtex, unsigned TU_noise)
|
||||
{
|
||||
if (irr_driver->needUBOWorkaround())
|
||||
bypassUBO(Program);
|
||||
glUniform4fv(uniform_samplePoints, 16, SSAOSamples);
|
||||
|
||||
glUniform1i(uniform_dtex, TU_dtex);
|
||||
glUniform1i(uniform_noise_texture, TU_noise);
|
||||
}
|
||||
|
||||
GLuint FogShader::Program;
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
|
||||
void glUniformMatrix4fvWraper(GLuint, size_t, unsigned, const float *mat);
|
||||
void glUniform3fWraper(GLuint, float, float, float);
|
||||
void glUniform4iWraper(GLuint, int, int, int, int);
|
||||
void glUniform2fWraper(GLuint a, float b, float c);
|
||||
void glUniform1fWrapper(GLuint, float);
|
||||
bool needsUBO();
|
||||
@ -79,6 +80,13 @@ struct UniformHelper
|
||||
setUniformsHelper<N + 1>(uniforms, arg...);
|
||||
}
|
||||
|
||||
template<unsigned N = 0, typename... Args>
|
||||
static void setUniformsHelper(const std::vector<GLuint> &uniforms, const video::SColor &col, Args... arg)
|
||||
{
|
||||
glUniform4iWraper(uniforms[N], col.getRed(), col.getGreen(), col.getBlue(), col.getAlpha());
|
||||
setUniformsHelper<N + 1>(uniforms, arg...);
|
||||
}
|
||||
|
||||
template<unsigned N = 0, typename... Args>
|
||||
static void setUniformsHelper(const std::vector<GLuint> &uniforms, const core::vector3df &v, Args... arg)
|
||||
{
|
||||
@ -331,15 +339,20 @@ public:
|
||||
ShadowShader();
|
||||
};
|
||||
|
||||
class RSMShader
|
||||
class RSMShader : public ShaderHelperSingleton<RSMShader, core::matrix4, core::matrix4, core::matrix4>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_MM, uniform_RSMMatrix;
|
||||
static GLuint TU_tex;
|
||||
GLuint TU_tex;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &RSMMatrix, const core::matrix4 &ModelMatrix);
|
||||
RSMShader();
|
||||
};
|
||||
|
||||
class SplattingRSMShader : public ShaderHelperSingleton<SplattingRSMShader, core::matrix4, core::matrix4>
|
||||
{
|
||||
public:
|
||||
GLuint TU_layout, TU_detail0, TU_detail1, TU_detail2, TU_detail3;
|
||||
|
||||
SplattingRSMShader();
|
||||
};
|
||||
|
||||
class InstancedShadowShader : public ShaderHelperSingleton<InstancedShadowShader>
|
||||
@ -402,6 +415,12 @@ public:
|
||||
static void setUniforms(const core::matrix4 &ModelMatrix, const core::vector2df &screen, unsigned TU_tex);
|
||||
};
|
||||
|
||||
class NormalVisualizer : public ShaderHelperSingleton<NormalVisualizer, core::matrix4, core::matrix4, video::SColor>
|
||||
{
|
||||
public:
|
||||
NormalVisualizer();
|
||||
};
|
||||
|
||||
class ViewFrustrumShader
|
||||
{
|
||||
public:
|
||||
@ -523,37 +542,31 @@ public:
|
||||
static void setUniforms(unsigned TU_tex_128, unsigned TU_tex_256, unsigned TU_tex_512);
|
||||
};
|
||||
|
||||
class ToneMapShader
|
||||
class ToneMapShader : public ShaderHelperSingleton<ToneMapShader>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_logluminancetex, uniform_exposure, uniform_lwhite;
|
||||
static GLuint vao;
|
||||
GLuint TU_tex;
|
||||
GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(float exposure, float Lwhite, unsigned TU_tex, unsigned TU_logluminance);
|
||||
ToneMapShader();
|
||||
};
|
||||
|
||||
class DepthOfFieldShader
|
||||
class DepthOfFieldShader : public ShaderHelperSingleton<DepthOfFieldShader>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_depth;
|
||||
static GLuint vao;
|
||||
GLuint TU_tex, TU_depth;
|
||||
GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(unsigned TU_tex, unsigned TU_depth);
|
||||
DepthOfFieldShader();
|
||||
};
|
||||
|
||||
class SunLightShader
|
||||
class SunLightShader : public ShaderHelperSingleton<SunLightShader, core::vector3df, video::SColorf>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_ntex, uniform_dtex, uniform_direction, uniform_col;
|
||||
static GLuint vao;
|
||||
GLuint TU_ntex, TU_dtex;
|
||||
GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::vector3df &direction, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex);
|
||||
SunLightShader();
|
||||
};
|
||||
|
||||
class DiffuseEnvMapShader
|
||||
@ -567,26 +580,13 @@ public:
|
||||
static void setUniforms(const core::matrix4 &TransposeViewMatrix, const float *blueSHCoeff, const float *greenSHCoeff, const float *redSHCoeff, unsigned TU_ntex);
|
||||
};
|
||||
|
||||
class ShadowedSunLightShader
|
||||
class ShadowedSunLightShader : public ShaderHelperSingleton<ShadowedSunLightShader, core::vector3df, video::SColorf>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_ntex, uniform_dtex, uniform_shadowtex, uniform_direction, uniform_col;
|
||||
static GLuint vao;
|
||||
GLuint TU_ntex, TU_dtex, TU_shadowtex;
|
||||
GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::vector3df &direction, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_shadowtex);
|
||||
};
|
||||
|
||||
class ShadowedSunLightDebugShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_ntex, uniform_dtex, uniform_shadowtex, uniform_direction, uniform_col;
|
||||
static GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::vector3df &direction, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_shadowtex);
|
||||
ShadowedSunLightShader();
|
||||
};
|
||||
|
||||
class RadianceHintsConstructionShader
|
||||
@ -741,16 +741,13 @@ public:
|
||||
static void init();
|
||||
};
|
||||
|
||||
class SSAOShader
|
||||
class SSAOShader : public ShaderHelperSingleton<SSAOShader, float, float, float>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_ntex, uniform_dtex, uniform_noise_texture, uniform_samplePoints;
|
||||
static GLuint vao;
|
||||
static float SSAOSamples[64];
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::vector2df &screen, unsigned TU_dtex, unsigned TU_noise);
|
||||
GLuint TU_dtex;
|
||||
GLuint vao;
|
||||
|
||||
SSAOShader();
|
||||
};
|
||||
|
||||
class FogShader
|
||||
|
@ -119,6 +119,27 @@ void STKInstancedSceneNode::addInstance(const core::vector3df &origin, const cor
|
||||
instance_pos.push_back(scale.Z);
|
||||
}
|
||||
|
||||
core::matrix4 STKInstancedSceneNode::getInstanceTransform(int id)
|
||||
{
|
||||
core::matrix4 mat;
|
||||
|
||||
int offset = id * 9;
|
||||
mat.setTranslation(core::vector3df(
|
||||
instance_pos[offset],
|
||||
instance_pos[offset + 1],
|
||||
instance_pos[offset + 2]));
|
||||
mat.setRotationDegrees(core::vector3df(
|
||||
instance_pos[offset + 3],
|
||||
instance_pos[offset + 4],
|
||||
instance_pos[offset + 5]));
|
||||
mat.setScale(core::vector3df(
|
||||
instance_pos[offset + 6],
|
||||
instance_pos[offset + 7],
|
||||
instance_pos[offset + 8]));
|
||||
|
||||
return mat;
|
||||
}
|
||||
|
||||
static void drawFSPMDefault(GLMesh &mesh, size_t instance_count)
|
||||
{
|
||||
irr_driver->IncreaseObjectCount();
|
||||
|
@ -28,6 +28,10 @@ public:
|
||||
virtual void render();
|
||||
void addInstance(const core::vector3df &origin, const core::vector3df &orientation, const core::vector3df &scale);
|
||||
|
||||
int getInstanceCount() const { return instance_pos.size() / 9; }
|
||||
|
||||
core::matrix4 getInstanceTransform(int id);
|
||||
|
||||
void instanceGrab() { m_ref_count++; }
|
||||
void instanceDrop()
|
||||
{
|
||||
|
@ -574,7 +574,7 @@ void PhysicalObject::hit(const Material *m, const Vec3 &normal)
|
||||
if(isSoccerBall() && m != NULL &&
|
||||
m->getCollisionReaction() == Material::PUSH_SOCCER_BALL)
|
||||
{
|
||||
m_body->applyCentralImpulse(normal * 100.0f);
|
||||
m_body->applyCentralImpulse(normal * m_mass * 5.0f);
|
||||
}
|
||||
} // hit
|
||||
|
||||
|
@ -32,30 +32,19 @@ using namespace GUIEngine;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
DebugSliderDialog::DebugSliderDialog(std::string id, irr::core::stringw msg) :
|
||||
ModalDialog(0.85f, 0.25f, MODAL_DIALOG_LOCATION_BOTTOM)
|
||||
DebugSliderDialog::DebugSliderDialog() : ModalDialog(0.85f, 0.25f, MODAL_DIALOG_LOCATION_CENTER)
|
||||
{
|
||||
//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 );
|
||||
|
||||
float val;
|
||||
if (m_id == "lwhite")
|
||||
val = irr_driver->getLwhite() * 10.f;
|
||||
if (m_id == "exposure")
|
||||
val = irr_driver->getExposure() * 100.f;
|
||||
|
||||
getWidget<SpinnerWidget>("value_slider")->setValue(int(val));
|
||||
void DebugSliderDialog::setSliderHook(std::string id, unsigned min, unsigned max, std::function<int()> G, std::function<void(int)> S)
|
||||
{
|
||||
getWidget<SpinnerWidget>(id.c_str())->setValue(G());
|
||||
getWidget<SpinnerWidget>(id.c_str())->setMin(min);
|
||||
getWidget<SpinnerWidget>(id.c_str())->setMax(max);
|
||||
Setters[id] = S;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
@ -78,18 +67,12 @@ 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);
|
||||
if (m_id == "lwhite")
|
||||
irr_driver->setLwhite(value / 10.f);
|
||||
if (m_id == "exposure")
|
||||
irr_driver->setExposure(value / 100.f);
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
|
||||
return GUIEngine::EVENT_LET;
|
||||
if (Setters.find(eventSource) == Setters.end())
|
||||
return GUIEngine::EVENT_LET;
|
||||
int value = getWidget<SpinnerWidget>(eventSource.c_str())->getValue();
|
||||
Log::info("DebugSlider", "Value for <%s> : %i", eventSource.c_str(), value);
|
||||
Setters[eventSource](value);
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "guiengine/modaldialog.hpp"
|
||||
#include "utils/cpp2011.hpp"
|
||||
#include "utils/leak_check.hpp"
|
||||
#include <functional>
|
||||
|
||||
/**
|
||||
* \brief For internal value tweaking
|
||||
@ -32,18 +33,18 @@ class DebugSliderDialog : public GUIEngine::ModalDialog
|
||||
private:
|
||||
|
||||
std::string m_id;
|
||||
std::map<std::string, std::function<void(int)> >Setters;
|
||||
|
||||
public:
|
||||
DebugSliderDialog();
|
||||
|
||||
|
||||
DebugSliderDialog(std::string id, ::core::stringw msg);
|
||||
|
||||
~DebugSliderDialog();
|
||||
|
||||
|
||||
void setSliderHook(std::string id, unsigned min, unsigned max, std::function<int()> G, std::function<void(int)> S);
|
||||
|
||||
virtual void onEnterPressedInternal() OVERRIDE;
|
||||
virtual void onUpdate(float dt) OVERRIDE;
|
||||
|
||||
|
||||
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
|
||||
};
|
||||
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "graphics/particle_emitter.hpp"
|
||||
#include "graphics/particle_kind.hpp"
|
||||
#include "graphics/particle_kind_manager.hpp"
|
||||
#include "graphics/stkinstancedscenenode.hpp"
|
||||
#include "graphics/stk_text_billboard.hpp"
|
||||
#include "guiengine/scalable_font.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
@ -430,8 +431,6 @@ void Track::cleanup()
|
||||
//-----------------------------------------------------------------------------
|
||||
void Track::loadTrackInfo()
|
||||
{
|
||||
irr_driver->setLwhite(1.);
|
||||
irr_driver->setExposure(0.09f);
|
||||
// Default values
|
||||
m_use_fog = false;
|
||||
m_fog_max = 1.0f;
|
||||
@ -447,6 +446,9 @@ void Track::loadTrackInfo()
|
||||
m_sun_specular_color = video::SColor(255, 255, 255, 255);
|
||||
m_sun_diffuse_color = video::SColor(255, 255, 255, 255);
|
||||
m_sun_position = core::vector3df(0, 0, 0);
|
||||
irr_driver->setSSAORadius(1.);
|
||||
irr_driver->setSSAOK(1.5);
|
||||
irr_driver->setSSAOSigma(1.);
|
||||
XMLNode *root = file_manager->createXMLTree(m_filename);
|
||||
|
||||
if(!root || root->getName()!="track")
|
||||
@ -728,10 +730,25 @@ void Track::convertTrackToBullet(scene::ISceneNode *node)
|
||||
"This track contains an empty LOD group.");
|
||||
return;
|
||||
}
|
||||
node->updateAbsolutePosition();
|
||||
}
|
||||
node->updateAbsolutePosition();
|
||||
|
||||
std::vector<core::matrix4> matrices;
|
||||
|
||||
STKInstancedSceneNode* instancing_node = dynamic_cast<STKInstancedSceneNode*>(node);
|
||||
if (instancing_node != NULL)
|
||||
{
|
||||
int count = instancing_node->getInstanceCount();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
matrices.push_back(instancing_node->getInstanceTransform(i));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
matrices.push_back(node->getAbsoluteTransformation());
|
||||
}
|
||||
|
||||
const core::vector3df &pos = node->getAbsolutePosition();
|
||||
|
||||
|
||||
@ -773,14 +790,15 @@ void Track::convertTrackToBullet(scene::ISceneNode *node)
|
||||
return;
|
||||
} // switch node->getType()
|
||||
|
||||
core::matrix4 mat;
|
||||
mat.setRotationDegrees(hpr);
|
||||
mat.setTranslation(pos);
|
||||
core::matrix4 mat_scale;
|
||||
// Note that we can't simply call mat.setScale, since this would
|
||||
// overwrite the elements on the diagonal, making any rotation incorrect.
|
||||
mat_scale.setScale(scale);
|
||||
mat *= mat_scale;
|
||||
//core::matrix4 mat;
|
||||
//mat.setRotationDegrees(hpr);
|
||||
//mat.setTranslation(pos);
|
||||
//core::matrix4 mat_scale;
|
||||
//// Note that we can't simply call mat.setScale, since this would
|
||||
//// overwrite the elements on the diagonal, making any rotation incorrect.
|
||||
//mat_scale.setScale(scale);
|
||||
//mat *= mat_scale;
|
||||
|
||||
for(unsigned int i=0; i<mesh->getMeshBufferCount(); i++)
|
||||
{
|
||||
scene::IMeshBuffer *mb = mesh->getMeshBuffer(i);
|
||||
@ -834,59 +852,80 @@ void Track::convertTrackToBullet(scene::ISceneNode *node)
|
||||
if (mb->getVertexType() == video::EVT_STANDARD)
|
||||
{
|
||||
irr::video::S3DVertex* mbVertices=(video::S3DVertex*)mb->getVertices();
|
||||
for(unsigned int j=0; j<mb->getIndexCount(); j+=3)
|
||||
for (unsigned int matrix_index = 0; matrix_index < matrices.size(); matrix_index++)
|
||||
{
|
||||
for(unsigned int k=0; k<3; k++)
|
||||
for (unsigned int j = 0; j < mb->getIndexCount(); j += 3)
|
||||
{
|
||||
int indx=mbIndices[j+k];
|
||||
core::vector3df v = mbVertices[indx].Pos;
|
||||
mat.transformVect(v);
|
||||
vertices[k]=v;
|
||||
normals[k]=mbVertices[indx].Normal;
|
||||
} // for k
|
||||
if(tmesh) tmesh->addTriangle(vertices[0], vertices[1],
|
||||
vertices[2], normals[0],
|
||||
normals[1], normals[2],
|
||||
material );
|
||||
} // for j
|
||||
for (unsigned int k = 0; k < 3; k++)
|
||||
{
|
||||
int indx = mbIndices[j + k];
|
||||
core::vector3df v = mbVertices[indx].Pos;
|
||||
matrices[matrix_index].transformVect(v);
|
||||
vertices[k] = v;
|
||||
normals[k] = mbVertices[indx].Normal;
|
||||
} // for k
|
||||
|
||||
if (tmesh)
|
||||
{
|
||||
tmesh->addTriangle(vertices[0], vertices[1],
|
||||
vertices[2], normals[0],
|
||||
normals[1], normals[2],
|
||||
material);
|
||||
}
|
||||
} // for j
|
||||
} // for matrix_index
|
||||
}
|
||||
else if (mb->getVertexType() == video::EVT_2TCOORDS)
|
||||
{
|
||||
irr::video::S3DVertex2TCoords* mbVertices = (video::S3DVertex2TCoords*)mb->getVertices();
|
||||
for(unsigned int j=0; j<mb->getIndexCount(); j+=3)
|
||||
for (unsigned int matrix_index = 0; matrix_index < matrices.size(); matrix_index++)
|
||||
{
|
||||
for(unsigned int k=0; k<3; k++)
|
||||
for (unsigned int j = 0; j < mb->getIndexCount(); j += 3)
|
||||
{
|
||||
int indx=mbIndices[j+k];
|
||||
core::vector3df v = mbVertices[indx].Pos;
|
||||
mat.transformVect(v);
|
||||
vertices[k]=v;
|
||||
normals[k]=mbVertices[indx].Normal;
|
||||
} // for k
|
||||
if(tmesh) tmesh->addTriangle(vertices[0], vertices[1],
|
||||
vertices[2], normals[0],
|
||||
normals[1], normals[2],
|
||||
material );
|
||||
} // for j
|
||||
for (unsigned int k = 0; k < 3; k++)
|
||||
{
|
||||
int indx = mbIndices[j + k];
|
||||
core::vector3df v = mbVertices[indx].Pos;
|
||||
matrices[matrix_index].transformVect(v);
|
||||
vertices[k] = v;
|
||||
normals[k] = mbVertices[indx].Normal;
|
||||
} // for k
|
||||
|
||||
if (tmesh)
|
||||
{
|
||||
tmesh->addTriangle(vertices[0], vertices[1],
|
||||
vertices[2], normals[0],
|
||||
normals[1], normals[2],
|
||||
material);
|
||||
}
|
||||
} // for j
|
||||
} // for matrix_index
|
||||
}
|
||||
else if (mb->getVertexType() == video::EVT_TANGENTS)
|
||||
{
|
||||
irr::video::S3DVertexTangents* mbVertices = (video::S3DVertexTangents*)mb->getVertices();
|
||||
for(unsigned int j=0; j<mb->getIndexCount(); j+=3)
|
||||
for (unsigned int matrix_index = 0; matrix_index < matrices.size(); matrix_index++)
|
||||
{
|
||||
for(unsigned int k=0; k<3; k++)
|
||||
for (unsigned int j = 0; j < mb->getIndexCount(); j += 3)
|
||||
{
|
||||
int indx=mbIndices[j+k];
|
||||
core::vector3df v = mbVertices[indx].Pos;
|
||||
mat.transformVect(v);
|
||||
vertices[k]=v;
|
||||
normals[k]=mbVertices[indx].Normal;
|
||||
} // for k
|
||||
if(tmesh) tmesh->addTriangle(vertices[0], vertices[1],
|
||||
vertices[2], normals[0],
|
||||
normals[1], normals[2],
|
||||
material );
|
||||
} // for j
|
||||
for (unsigned int k = 0; k < 3; k++)
|
||||
{
|
||||
int indx = mbIndices[j + k];
|
||||
core::vector3df v = mbVertices[indx].Pos;
|
||||
matrices[matrix_index].transformVect(v);
|
||||
vertices[k] = v;
|
||||
normals[k] = mbVertices[indx].Normal;
|
||||
} // for k
|
||||
|
||||
if (tmesh)
|
||||
{
|
||||
tmesh->addTriangle(vertices[0], vertices[1],
|
||||
vertices[2], normals[0],
|
||||
normals[1], normals[2],
|
||||
material);
|
||||
}
|
||||
} // for j
|
||||
} // for matrix_index
|
||||
}
|
||||
|
||||
} // for i<getMeshBufferCount
|
||||
|
@ -548,6 +548,7 @@ public:
|
||||
float getCameraFar() const { return m_camera_far; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the triangle mesh for this track. */
|
||||
const TriangleMesh *getPtrTriangleMesh() const { return m_track_mesh; }
|
||||
const TriangleMesh& getTriangleMesh() const {return *m_track_mesh; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the graphical effect mesh for this track. */
|
||||
|
@ -83,8 +83,7 @@ enum DebugMenuCommand
|
||||
DEBUG_TOGGLE_GUI,
|
||||
DEBUG_HIDE_KARTS,
|
||||
DEBUG_THROTTLE_FPS,
|
||||
DEBUG_TWEAK_SHADER_EXPOSURE,
|
||||
DEBUG_TWEAK_SHADER_LWHITE
|
||||
DEBUG_VISUAL_VALUES,
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -188,10 +187,7 @@ 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"Adjust values", DEBUG_VISUAL_VALUES);
|
||||
|
||||
mnu->addItem(L"Profiler",DEBUG_PROFILER);
|
||||
if (UserConfigParams::m_profiler_enabled)
|
||||
@ -438,13 +434,36 @@ bool onEvent(const SEvent &event)
|
||||
kart->getNode()->setVisible(false);
|
||||
}
|
||||
}
|
||||
else if (cmdID == DEBUG_TWEAK_SHADER_EXPOSURE)
|
||||
else if (cmdID == DEBUG_VISUAL_VALUES)
|
||||
{
|
||||
new DebugSliderDialog("exposure", "Exposure");
|
||||
}
|
||||
else if (cmdID == DEBUG_TWEAK_SHADER_LWHITE)
|
||||
{
|
||||
new DebugSliderDialog("lwhite", "LWhite");
|
||||
DebugSliderDialog *dsd = new DebugSliderDialog();
|
||||
dsd->setSliderHook( "red_slider", 0, 255, [](){ return irr_driver->getAmbientLight().r * 255.; },
|
||||
[](int v){
|
||||
video::SColorf ambient = irr_driver->getAmbientLight();
|
||||
ambient.setColorComponentValue(0, v / 255.);
|
||||
irr_driver->setAmbientLight(ambient); }
|
||||
);
|
||||
dsd->setSliderHook("green_slider", 0, 255, [](){ return irr_driver->getAmbientLight().g * 255.; },
|
||||
[](int v){
|
||||
video::SColorf ambient = irr_driver->getAmbientLight();
|
||||
ambient.setColorComponentValue(1, v / 255.);
|
||||
irr_driver->setAmbientLight(ambient); }
|
||||
);
|
||||
dsd->setSliderHook("blue_slider", 0, 255, [](){ return irr_driver->getAmbientLight().b * 255.; },
|
||||
[](int v){
|
||||
video::SColorf ambient = irr_driver->getAmbientLight();
|
||||
ambient.setColorComponentValue(2, v / 255.);
|
||||
irr_driver->setAmbientLight(ambient); }
|
||||
);
|
||||
dsd->setSliderHook("ssao_radius", 0, 100, [](){ return irr_driver->getSSAORadius() * 10; },
|
||||
[](int v){irr_driver->setSSAORadius(v / 10.); }
|
||||
);
|
||||
dsd->setSliderHook("ssao_k", 0, 100, [](){ return irr_driver->getSSAOK() * 10; },
|
||||
[](int v){irr_driver->setSSAOK(v / 10.); }
|
||||
);
|
||||
dsd->setSliderHook("ssao_sigma", 0, 100, [](){ return irr_driver->getSSAOSigma() * 10; },
|
||||
[](int v){irr_driver->setSSAOSigma(v / 10.); }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user