Merge branch 'upstream/master' into fixes
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2013 the SuperTuxKart team
|
||||
//
|
||||
// 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.
|
||||
|
||||
uniform sampler2D tex;
|
||||
uniform float transparency;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
varying vec2 uv;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 Color = texture(tex, uv);
|
||||
Color.a *= transparency;
|
||||
FragColor = vec4(Color.rgb * Color.a, Color.a);
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2013 the SuperTuxKart team
|
||||
//
|
||||
// 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.
|
||||
|
||||
|
||||
// Creates a bubble (wave) effect by distorting the texture depending on time
|
||||
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
uniform float time;
|
||||
|
||||
#if __VERSION__ >= 330
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
#else
|
||||
in vec3 Position;
|
||||
in vec2 Texcoord;
|
||||
#endif
|
||||
out vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
|
||||
|
||||
float delta_x = cos(time*3.0) * sin( 4.0 * Texcoord.x * 6.28318531 );
|
||||
float delta_y = cos(time*2.0) * sin( 3.0 * Texcoord.y * 6.28318531 );
|
||||
|
||||
uv = Texcoord + vec2(0.02*delta_x, 0.02*delta_y);
|
||||
}
|
||||
@@ -49,7 +49,7 @@ void main(void)
|
||||
vec3 sampleDirection = reflect(-eyedir, normal);
|
||||
sampleDirection = (InverseViewMatrix * vec4(sampleDirection, 0.)).xyz;
|
||||
|
||||
float specval = pow(texture(ntex, uv).z, 2.);
|
||||
float specval = texture(ntex, uv).z;
|
||||
// From http://graphics.cs.williams.edu/papers/EnvMipReport2013/
|
||||
int texSize = textureSize(tex, 0).x;
|
||||
float lodval = clamp(log2(texSize * sqrt(3.)) - .5 * log2(specval + 1.), 0., 10.);
|
||||
|
||||
@@ -15,7 +15,9 @@ void main()
|
||||
vec4 xpos = getPosFromUVDepth(vec3(uv, z), InverseProjectionMatrix);
|
||||
|
||||
float dist = length(xpos.xyz);
|
||||
vec3 fog = col * (1. - exp(- density * dist));
|
||||
float factor = (1. - exp(- density * dist));
|
||||
vec3 fog = col * factor;
|
||||
|
||||
FragColor = vec4(fog, 1.);
|
||||
// fog is scattering component, factor is the beer lambert absorption
|
||||
FragColor = vec4(fog, factor);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ uniform float sigma;
|
||||
|
||||
layout (local_size_x = 8, local_size_y = 8) in;
|
||||
|
||||
shared vec3 local_src[8 + 2 * 6][8];
|
||||
shared vec4 local_src[8 + 2 * 6][8];
|
||||
|
||||
void main()
|
||||
{
|
||||
@@ -17,9 +17,9 @@ void main()
|
||||
vec2 uv = iuv * pixel;
|
||||
vec2 uv_p = (iuv + ivec2(6, 0)) * pixel;
|
||||
|
||||
local_src[x][y] = texture(source, uv_m).rgb;
|
||||
local_src[x + 6][y] = texture(source, uv).rgb;
|
||||
local_src[x + 12][y] = texture(source, uv_p).rgb;
|
||||
local_src[x][y] = texture(source, uv_m);
|
||||
local_src[x + 6][y] = texture(source, uv);
|
||||
local_src[x + 12][y] = texture(source, uv_p);
|
||||
|
||||
barrier();
|
||||
|
||||
@@ -27,7 +27,7 @@ void main()
|
||||
g0 = 1.0 / (sqrt(2.0 * 3.14) * sigma);
|
||||
g1 = exp(-0.5 / (sigma * sigma));
|
||||
g2 = g1 * g1;
|
||||
vec3 sum = local_src[x + 6][y] * g0;
|
||||
vec4 sum = local_src[x + 6][y] * g0;
|
||||
g0 *= g1;
|
||||
g1 *= g2;
|
||||
for (int i = 1; i < 6; i++) {
|
||||
@@ -37,5 +37,5 @@ void main()
|
||||
g1 *= g2;
|
||||
}
|
||||
|
||||
imageStore(dest, iuv, vec4(sum, 0.));
|
||||
imageStore(dest, iuv, sum);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ uniform float sigma;
|
||||
|
||||
layout (local_size_x = 8, local_size_y = 8) in;
|
||||
|
||||
shared vec3 local_src[8][8 + 2 * 6];
|
||||
shared vec4 local_src[8][8 + 2 * 6];
|
||||
|
||||
void main()
|
||||
{
|
||||
@@ -17,9 +17,9 @@ void main()
|
||||
vec2 uv = iuv * pixel;
|
||||
vec2 uv_p = (iuv + ivec2(0, 6)) * pixel;
|
||||
|
||||
local_src[x][y] = texture(source, uv_m).rgb;
|
||||
local_src[x][y + 6] = texture(source, uv).rgb;
|
||||
local_src[x][y + 12] = texture(source, uv_p).rgb;
|
||||
local_src[x][y] = texture(source, uv_m);
|
||||
local_src[x][y + 6] = texture(source, uv);
|
||||
local_src[x][y + 12] = texture(source, uv_p);
|
||||
|
||||
barrier();
|
||||
|
||||
@@ -27,7 +27,7 @@ void main()
|
||||
g0 = 1.0 / (sqrt(2.0 * 3.14) * sigma);
|
||||
g1 = exp(-0.5 / (sigma * sigma));
|
||||
g2 = g1 * g1;
|
||||
vec3 sum = local_src[x][y + 6] * g0;
|
||||
vec4 sum = local_src[x][y + 6] * g0;
|
||||
g0 *= g1;
|
||||
g1 *= g2;
|
||||
for (int i = 1; i < 6; i++) {
|
||||
@@ -37,5 +37,5 @@ void main()
|
||||
g1 *= g2;
|
||||
}
|
||||
|
||||
imageStore(dest, iuv, vec4(sum, 0.));
|
||||
imageStore(dest, iuv, sum);
|
||||
}
|
||||
|
||||
@@ -42,5 +42,5 @@ void main()
|
||||
xpos += stepsize * eyedir;
|
||||
}
|
||||
|
||||
Fog = vec4(fogcol * fog, 1.);
|
||||
Fog = vec4(fogcol * fog, 0.);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@ uniform sampler2D dtex;
|
||||
|
||||
uniform vec3 direction;
|
||||
uniform vec3 col;
|
||||
uniform mat4 invproj;
|
||||
uniform float sunangle = .54;
|
||||
|
||||
//uniform int hasclouds;
|
||||
//uniform vec2 wind;
|
||||
|
||||
@@ -15,6 +16,16 @@ vec3 DecodeNormal(vec2 n);
|
||||
vec3 getSpecular(vec3 normal, vec3 eyedir, vec3 lightdir, vec3 color, float roughness);
|
||||
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
|
||||
|
||||
vec3 getMostRepresentativePoint(vec3 direction, vec3 R, float angularRadius)
|
||||
{
|
||||
vec3 D = direction;
|
||||
float d = cos(angularRadius);
|
||||
float r = sin(angularRadius);
|
||||
float DdotR = dot(D, R);
|
||||
vec3 S = R - DdotR * D;
|
||||
return (DdotR < d) ? normalize(d * D + normalize (S) * r) : R;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 uv = gl_FragCoord.xy / screen;
|
||||
float z = texture(dtex, uv).x;
|
||||
@@ -37,7 +48,11 @@ void main() {
|
||||
|
||||
float NdotL = max(0., dot(norm, L));
|
||||
|
||||
vec3 Specular = getSpecular(norm, eyedir, L, col, roughness) * NdotL;
|
||||
float angle = 3.14 * sunangle / 180.;
|
||||
vec3 R = reflect(-eyedir, norm);
|
||||
vec3 Lightdir = getMostRepresentativePoint(direction, R, angle);
|
||||
|
||||
vec3 Specular = getSpecular(norm, eyedir, Lightdir, col, roughness) * NdotL;
|
||||
|
||||
vec3 outcol = NdotL * col;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ uniform float splitmax;
|
||||
|
||||
uniform vec3 direction;
|
||||
uniform vec3 col;
|
||||
uniform float sunangle = .54;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 Diff;
|
||||
@@ -18,6 +19,16 @@ vec3 DecodeNormal(vec2 n);
|
||||
vec3 getSpecular(vec3 normal, vec3 eyedir, vec3 lightdir, vec3 color, float roughness);
|
||||
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
|
||||
|
||||
vec3 getMostRepresentativePoint(vec3 direction, vec3 R, float angularRadius)
|
||||
{
|
||||
vec3 D = direction;
|
||||
float d = cos(angularRadius);
|
||||
float r = sin(angularRadius);
|
||||
float DdotR = dot(D, R);
|
||||
vec3 S = R - DdotR * D;
|
||||
return (DdotR < d) ? normalize(d * D + normalize (S) * r) : R;
|
||||
}
|
||||
|
||||
float getShadowFactor(vec3 pos, float bias, int index)
|
||||
{
|
||||
|
||||
@@ -51,7 +62,11 @@ void main() {
|
||||
|
||||
float NdotL = max(0., dot(norm, L));
|
||||
|
||||
vec3 Specular = getSpecular(norm, eyedir, L, col, roughness) * NdotL;
|
||||
float angle = 3.14 * sunangle / 180.;
|
||||
vec3 R = reflect(-eyedir, norm);
|
||||
vec3 Lightdir = getMostRepresentativePoint(direction, R, angle);
|
||||
|
||||
vec3 Specular = getSpecular(norm, eyedir, Lightdir, col, roughness) * NdotL;
|
||||
|
||||
|
||||
vec3 outcol = NdotL * col;
|
||||
|
||||
@@ -652,11 +652,38 @@ namespace UserConfigParams
|
||||
PARAM_DEFAULT( BoolUserConfigParam(
|
||||
CONSOLE_DEFAULT, "log_errors", "Enable logging to console.") );
|
||||
|
||||
// ---- Camera
|
||||
PARAM_PREFIX GroupUserConfigParam m_camera
|
||||
PARAM_DEFAULT( GroupUserConfigParam("camera",
|
||||
"(Debug) camera settings.") );
|
||||
|
||||
PARAM_PREFIX IntUserConfigParam m_reverse_look_threshold
|
||||
PARAM_DEFAULT( IntUserConfigParam(0, "reverse_look_threshold",
|
||||
&m_camera,
|
||||
"If the kart is driving backwards faster than this value,\n"
|
||||
"switch automatically to reverse camera (set to 0 to disable).") );
|
||||
|
||||
PARAM_PREFIX FloatUserConfigParam m_fspcam_direction_speed
|
||||
PARAM_DEFAULT( FloatUserConfigParam(0.003f, "fspcam_rotation_speed",
|
||||
&m_camera,
|
||||
"How fast the first person camera's direction speed changes when\n"
|
||||
"moving the mouse (means acceleration).") );
|
||||
|
||||
PARAM_PREFIX FloatUserConfigParam m_fspcam_smooth_direction_max_speed
|
||||
PARAM_DEFAULT( FloatUserConfigParam(0.04f, "fspcam_smooth_rotation_max_speed",
|
||||
&m_camera,
|
||||
"How fast the first person camera's direction can change.") );
|
||||
|
||||
PARAM_PREFIX FloatUserConfigParam m_fspcam_angular_velocity
|
||||
PARAM_DEFAULT( FloatUserConfigParam(0.02f, "fspcam_angular_velocity",
|
||||
&m_camera,
|
||||
"How fast the first person camera's rotation speed changes.") );
|
||||
|
||||
PARAM_PREFIX FloatUserConfigParam m_fspcam_max_angular_velocity
|
||||
PARAM_DEFAULT( FloatUserConfigParam(1.0f, "fspcam_max_angular_velocity",
|
||||
&m_camera,
|
||||
"How fast the first person camera can rotate.") );
|
||||
|
||||
PARAM_PREFIX StringUserConfigParam m_item_style
|
||||
PARAM_DEFAULT( StringUserConfigParam("items", "item_style",
|
||||
"Name of the .items file to use.") );
|
||||
@@ -672,6 +699,7 @@ namespace UserConfigParams
|
||||
PARAM_DEFAULT( StringUserConfigParam("Peach.stkskin", "skin_file",
|
||||
"Name of the skin to use") );
|
||||
|
||||
// ---- Handicap
|
||||
PARAM_PREFIX GroupUserConfigParam m_handicap
|
||||
PARAM_DEFAULT( GroupUserConfigParam("Handicap",
|
||||
"Everything related to handicaps.") );
|
||||
|
||||
@@ -150,62 +150,6 @@ void MipVizProvider::OnSetConstants(IMaterialRendererServices *srv, int)
|
||||
|
||||
//-------------------------------------
|
||||
|
||||
void SunLightProvider::OnSetConstants(IMaterialRendererServices *srv, int)
|
||||
{
|
||||
const int hasclouds = World::getWorld()->getTrack()->hasClouds() &&
|
||||
UserConfigParams::m_weather_effects;
|
||||
|
||||
srv->setVertexShaderConstant("screen", m_screen, 2);
|
||||
srv->setVertexShaderConstant("col", m_color, 3);
|
||||
srv->setVertexShaderConstant("center", m_pos, 3);
|
||||
srv->setVertexShaderConstant("invproj", irr_driver->getInvProjMatrix().pointer(), 16);
|
||||
srv->setVertexShaderConstant("hasclouds", &hasclouds, 1);
|
||||
|
||||
const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f;
|
||||
|
||||
float strength = time;
|
||||
strength = fabsf(noise2d(strength / 10.0f)) * 0.003f;
|
||||
|
||||
const vector3df winddir = irr_driver->getWind() * strength;
|
||||
m_wind[0] += winddir.X;
|
||||
m_wind[1] += winddir.Z;
|
||||
srv->setVertexShaderConstant("wind", m_wind, 2);
|
||||
|
||||
if (UserConfigParams::m_shadows)
|
||||
{
|
||||
srv->setVertexShaderConstant("shadowmat", m_shadowmat.pointer(), 16);
|
||||
}
|
||||
|
||||
// Can't use the firstdone optimization, as this callback is used for multiple shaders
|
||||
//if (!firstdone)
|
||||
{
|
||||
int tex = 0;
|
||||
srv->setVertexShaderConstant("ntex", &tex, 1);
|
||||
|
||||
tex = 1;
|
||||
srv->setVertexShaderConstant("dtex", &tex, 1);
|
||||
|
||||
tex = 2;
|
||||
srv->setVertexShaderConstant("cloudtex", &tex, 1);
|
||||
|
||||
tex = 3;
|
||||
srv->setVertexShaderConstant("shadowtex", &tex, 1);
|
||||
|
||||
tex = 4;
|
||||
srv->setVertexShaderConstant("warpx", &tex, 1);
|
||||
|
||||
tex = 5;
|
||||
srv->setVertexShaderConstant("warpy", &tex, 1);
|
||||
|
||||
// const float shadowoffset = 1.0f / irr_driver->getRTT(RTT_SHADOW)->getSize().Width;
|
||||
// srv->setVertexShaderConstant("shadowoffset", &shadowoffset, 1);
|
||||
|
||||
firstdone = true;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
|
||||
void DisplaceProvider::OnSetConstants(IMaterialRendererServices *srv, int)
|
||||
{
|
||||
|
||||
|
||||
@@ -211,75 +211,6 @@ public:
|
||||
|
||||
//
|
||||
|
||||
class SunLightProvider: public CallBase
|
||||
{
|
||||
public:
|
||||
SunLightProvider()
|
||||
{
|
||||
m_screen[0] = (float)UserConfigParams::m_width;
|
||||
m_screen[1] = (float)UserConfigParams::m_height;
|
||||
|
||||
m_wind[0] = m_wind[1] = 0;
|
||||
}
|
||||
|
||||
virtual void OnSetConstants(video::IMaterialRendererServices *srv, int);
|
||||
|
||||
void setColor(float r, float g, float b)
|
||||
{
|
||||
m_color[0] = r;
|
||||
m_color[1] = g;
|
||||
m_color[2] = b;
|
||||
}
|
||||
|
||||
float getRed() const
|
||||
{
|
||||
return m_color[0];
|
||||
}
|
||||
|
||||
float getGreen() const
|
||||
{
|
||||
return m_color[1];
|
||||
}
|
||||
|
||||
float getBlue() const
|
||||
{
|
||||
return m_color[2];
|
||||
}
|
||||
|
||||
void setPosition(float x, float y, float z)
|
||||
{
|
||||
// Sun "position" is actually a direction and not a position
|
||||
core::matrix4 m_view = irr_driver->getViewMatrix();
|
||||
m_view.makeInverse();
|
||||
m_view = m_view.getTransposed();
|
||||
core::vector3df pos(x, y, z);
|
||||
m_view.transformVect(pos);
|
||||
pos.normalize();
|
||||
m_pos[0] = pos.X;
|
||||
m_pos[1] = pos.Y;
|
||||
m_pos[2] = pos.Z;
|
||||
}
|
||||
|
||||
core::vector3df getPosition() const
|
||||
{
|
||||
return core::vector3df(m_pos[0], m_pos[1], m_pos[2]);
|
||||
}
|
||||
|
||||
void setShadowMatrix(const core::matrix4 &mat)
|
||||
{
|
||||
m_shadowmat = mat;
|
||||
}
|
||||
|
||||
private:
|
||||
core::matrix4 m_shadowmat;
|
||||
float m_color[3];
|
||||
float m_pos[3];
|
||||
float m_screen[2];
|
||||
float m_wind[2];
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
class DisplaceProvider: public CallBase
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -90,6 +90,7 @@ Camera::Camera(int camera_index, AbstractKart* kart) : m_kart(NULL)
|
||||
m_target_velocity = core::vector3df(0, 0, 0);
|
||||
m_target_direction = core::vector3df(0, 0, 1);
|
||||
m_target_up_vector = core::vector3df(0, 1, 0);
|
||||
m_direction_velocity = core::vector3df(0, 0, 0);
|
||||
m_angular_velocity = 0;
|
||||
m_target_angular_velocity = 0;
|
||||
m_max_velocity = 15;
|
||||
@@ -500,13 +501,13 @@ void Camera::update(float dt)
|
||||
// Angular velocity
|
||||
if (m_angular_velocity < m_target_angular_velocity)
|
||||
{
|
||||
m_angular_velocity += 0.02f;
|
||||
m_angular_velocity += UserConfigParams::m_fspcam_angular_velocity;
|
||||
if (m_angular_velocity > m_target_angular_velocity)
|
||||
m_angular_velocity = m_target_angular_velocity;
|
||||
}
|
||||
else if (m_angular_velocity > m_target_angular_velocity)
|
||||
{
|
||||
m_angular_velocity -= 0.02f;
|
||||
m_angular_velocity -= UserConfigParams::m_fspcam_angular_velocity;
|
||||
if (m_angular_velocity < m_target_angular_velocity)
|
||||
m_angular_velocity = m_target_angular_velocity;
|
||||
}
|
||||
@@ -524,17 +525,25 @@ void Camera::update(float dt)
|
||||
diff = m_target_direction - direction;
|
||||
if (diff.X != 0 || diff.Y != 0 || diff.Z != 0)
|
||||
{
|
||||
if (diff.getLengthSQ() > 0.02f * 0.02f)
|
||||
diff.setLength(0.02f);
|
||||
direction += diff;
|
||||
diff.setLength(UserConfigParams::m_fspcam_direction_speed);
|
||||
m_direction_velocity += diff;
|
||||
if (m_direction_velocity.getLengthSQ() >
|
||||
UserConfigParams::m_fspcam_smooth_direction_max_speed *
|
||||
UserConfigParams::m_fspcam_smooth_direction_max_speed)
|
||||
m_direction_velocity.setLength(
|
||||
UserConfigParams::m_fspcam_smooth_direction_max_speed);
|
||||
direction += m_direction_velocity;
|
||||
m_target_direction = direction;
|
||||
}
|
||||
|
||||
// Camera rotation
|
||||
diff = m_target_up_vector - up;
|
||||
if (diff.X != 0 || diff.Y != 0 || diff.Z != 0)
|
||||
{
|
||||
if (diff.getLengthSQ() > 0.02f * 0.02f)
|
||||
diff.setLength(0.02f);
|
||||
if (diff.getLengthSQ() >
|
||||
UserConfigParams::m_fspcam_angular_velocity *
|
||||
UserConfigParams::m_fspcam_angular_velocity)
|
||||
diff.setLength(UserConfigParams::m_fspcam_angular_velocity);
|
||||
up += diff;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,6 +132,9 @@ private:
|
||||
/** The target direction for the camera, only used for the first person camera. */
|
||||
core::vector3df m_target_direction;
|
||||
|
||||
/** The speed at which the direction changes, only used for the first person camera. */
|
||||
core::vector3df m_direction_velocity;
|
||||
|
||||
/** The up vector the camera should have, only used for the first person camera. */
|
||||
core::vector3df m_target_up_vector;
|
||||
|
||||
|
||||
@@ -380,6 +380,8 @@ private:
|
||||
class STKMeshSceneNode *m_sun_interposer;
|
||||
scene::CLensFlareSceneNode *m_lensflare;
|
||||
scene::ICameraSceneNode *m_suncam;
|
||||
core::vector3df m_sundirection;
|
||||
video::SColorf m_suncolor;
|
||||
std::pair<float, float> m_shadow_scales[4];
|
||||
scene::ICameraSceneNode *m_shadow_camnodes[4];
|
||||
float m_shadows_cam[4][24];
|
||||
@@ -619,6 +621,25 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
inline core::vector3df getWind() {return m_wind->getWind();}
|
||||
// -----------------------------------------------------------------------
|
||||
core::vector3df getSunDirection() const { return m_sundirection; };
|
||||
// -----------------------------------------------------------------------
|
||||
void setSunDirection(const core::vector3df &SunPos)
|
||||
{
|
||||
core::matrix4 m_view = getViewMatrix();
|
||||
m_view.makeInverse();
|
||||
m_view = m_view.getTransposed();
|
||||
m_sundirection = SunPos;
|
||||
m_view.transformVect(m_sundirection);
|
||||
m_sundirection.normalize();
|
||||
}
|
||||
// -----------------------------------------------------------------------
|
||||
video::SColorf getSunColor() const { return m_suncolor; }
|
||||
// -----------------------------------------------------------------------
|
||||
void setSunColor(const video::SColorf &col)
|
||||
{
|
||||
m_suncolor = col;
|
||||
}
|
||||
// -----------------------------------------------------------------------
|
||||
inline video::E_MATERIAL_TYPE getShader(const ShaderType num) {return m_shaders->getShader(num);}
|
||||
// -----------------------------------------------------------------------
|
||||
inline void updateShaders() {m_shaders->killShaders();}
|
||||
|
||||
@@ -269,32 +269,28 @@ void PostProcessing::renderGI(const core::matrix4 &RHMatrix, const core::vector3
|
||||
DrawFullScreenEffect<FullScreenShader::GlobalIlluminationReconstructionShader>(RHMatrix, InvRHMatrix, rh_extend);
|
||||
}
|
||||
|
||||
void PostProcessing::renderSunlight()
|
||||
void PostProcessing::renderSunlight(const core::vector3df &direction, const video::SColorf &col)
|
||||
{
|
||||
SunLightProvider * const cb = (SunLightProvider *) irr_driver->getCallback(ES_SUNLIGHT);
|
||||
glEnable(GL_BLEND);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
|
||||
FullScreenShader::SunLightShader::getInstance()->SetTextureUnits(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), irr_driver->getDepthStencilTexture());
|
||||
DrawFullScreenEffect<FullScreenShader::SunLightShader>(cb->getPosition(), video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue()));
|
||||
FullScreenShader::SunLightShader::getInstance()->SetTextureUnits(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), irr_driver->getDepthStencilTexture());
|
||||
DrawFullScreenEffect<FullScreenShader::SunLightShader>(direction, col);
|
||||
}
|
||||
|
||||
extern float shadowSplit[5];
|
||||
|
||||
void PostProcessing::renderShadowedSunlight(const std::vector<core::matrix4> &sun_ortho_matrix, GLuint depthtex)
|
||||
void PostProcessing::renderShadowedSunlight(const core::vector3df &direction, const video::SColorf &col, const std::vector<core::matrix4> &sun_ortho_matrix, GLuint depthtex)
|
||||
{
|
||||
SunLightProvider * const cb = (SunLightProvider *)irr_driver->getCallback(ES_SUNLIGHT);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
|
||||
FullScreenShader::ShadowedSunLightShader::getInstance()->SetTextureUnits(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), irr_driver->getDepthStencilTexture(), depthtex);
|
||||
DrawFullScreenEffect<FullScreenShader::ShadowedSunLightShader>(shadowSplit[1], shadowSplit[2], shadowSplit[3], shadowSplit[4], cb->getPosition(), video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue()));
|
||||
DrawFullScreenEffect<FullScreenShader::ShadowedSunLightShader>(shadowSplit[1], shadowSplit[2], shadowSplit[3], shadowSplit[4], direction, col);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -76,8 +76,8 @@ public:
|
||||
void update(float dt);
|
||||
|
||||
/** Generate diffuse and specular map */
|
||||
void renderSunlight();
|
||||
void renderShadowedSunlight(const std::vector<core::matrix4> &sun_ortho_matrix, unsigned depthtex);
|
||||
void renderSunlight(const core::vector3df &direction, const video::SColorf &col);
|
||||
void renderShadowedSunlight(const core::vector3df &direction, const video::SColorf &col, const std::vector<core::matrix4> &sun_ortho_matrix, unsigned depthtex);
|
||||
|
||||
void renderFog();
|
||||
void renderSSAO();
|
||||
|
||||
@@ -644,14 +644,13 @@ void IrrDriver::renderSolidSecondPass()
|
||||
|
||||
// template does not work with template due to extra depth texture
|
||||
{
|
||||
SunLightProvider * const cb = (SunLightProvider *)irr_driver->getCallback(ES_SUNLIGHT);
|
||||
glUseProgram(GrassMat::InstancedSecondPassShader::getInstance()->Program);
|
||||
glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(GrassMat::VertexType, GrassMat::Instance));
|
||||
uint64_t nulltex[10] = {};
|
||||
if (SolidPassCmd::getInstance()->Size[GrassMat::MaterialType])
|
||||
{
|
||||
HandleExpander<GrassMat::InstancedSecondPassShader>::Expand(nulltex, GrassMat::SecondPassTextures, DiffuseHandle, SpecularHandle, SSAOHandle, DepthHandle);
|
||||
GrassMat::InstancedSecondPassShader::getInstance()->setUniforms(windDir, cb->getPosition());
|
||||
GrassMat::InstancedSecondPassShader::getInstance()->setUniforms(windDir, irr_driver->getSunDirection());
|
||||
glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT,
|
||||
(const void*)(SolidPassCmd::getInstance()->Offset[GrassMat::MaterialType] * sizeof(DrawElementsIndirectCommand)),
|
||||
(int)SolidPassCmd::getInstance()->Size[GrassMat::MaterialType],
|
||||
@@ -670,7 +669,6 @@ void IrrDriver::renderSolidSecondPass()
|
||||
|
||||
// template does not work with template due to extra depth texture
|
||||
{
|
||||
SunLightProvider * const cb = (SunLightProvider *)irr_driver->getCallback(ES_SUNLIGHT);
|
||||
std::vector<GLMesh *> &meshes = GrassMat::InstancedList::getInstance()->SolidPass;
|
||||
glUseProgram(GrassMat::InstancedSecondPassShader::getInstance()->Program);
|
||||
glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(GrassMat::VertexType, GrassMat::Instance));
|
||||
@@ -678,7 +676,7 @@ void IrrDriver::renderSolidSecondPass()
|
||||
{
|
||||
GLMesh *mesh = meshes[i];
|
||||
TexExpander<GrassMat::InstancedSecondPassShader>::ExpandTex(*mesh, GrassMat::SecondPassTextures, DiffSpecSSAOTex[0], DiffSpecSSAOTex[1], DiffSpecSSAOTex[2], irr_driver->getDepthStencilTexture());
|
||||
GrassMat::InstancedSecondPassShader::getInstance()->setUniforms(windDir, cb->getPosition());
|
||||
GrassMat::InstancedSecondPassShader::getInstance()->setUniforms(windDir, irr_driver->getSunDirection());
|
||||
glDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, (const void*)((SolidPassCmd::getInstance()->Offset[GrassMat::MaterialType] + i) * sizeof(DrawElementsIndirectCommand)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,6 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow)
|
||||
glDisable(GL_BLEND);
|
||||
m_rtts->getRH().Bind();
|
||||
glBindVertexArray(SharedObject::FullScreenQuadVAO);
|
||||
SunLightProvider * const cb = (SunLightProvider *)irr_driver->getCallback(ES_SUNLIGHT);
|
||||
if (irr_driver->needRHWorkaround())
|
||||
{
|
||||
glUseProgram(FullScreenShader::NVWorkaroundRadianceHintsConstructionShader::getInstance()->Program);
|
||||
@@ -123,7 +122,7 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow)
|
||||
m_rtts->getRSM().getRTT()[0], m_rtts->getRSM().getRTT()[1], m_rtts->getRSM().getDepthTexture());
|
||||
for (unsigned i = 0; i < 32; i++)
|
||||
{
|
||||
FullScreenShader::NVWorkaroundRadianceHintsConstructionShader::getInstance()->setUniforms(rsm_matrix, rh_matrix, rh_extend, i, video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue()));
|
||||
FullScreenShader::NVWorkaroundRadianceHintsConstructionShader::getInstance()->setUniforms(rsm_matrix, rh_matrix, rh_extend, i, irr_driver->getSunColor());
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
}
|
||||
@@ -135,7 +134,7 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow)
|
||||
m_rtts->getRSM().getRTT()[1],
|
||||
m_rtts->getRSM().getDepthTexture()
|
||||
);
|
||||
FullScreenShader::RadianceHintsConstructionShader::getInstance()->setUniforms(rsm_matrix, rh_matrix, rh_extend, video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue()));
|
||||
FullScreenShader::RadianceHintsConstructionShader::getInstance()->setUniforms(rsm_matrix, rh_matrix, rh_extend, irr_driver->getSunColor());
|
||||
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, 32);
|
||||
}
|
||||
}
|
||||
@@ -164,9 +163,9 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow)
|
||||
{
|
||||
ScopedGPUTimer timer(irr_driver->getGPUTimer(Q_SUN));
|
||||
if (World::getWorld() && UserConfigParams::m_shadows && !irr_driver->needUBOWorkaround() && hasShadow)
|
||||
m_post_processing->renderShadowedSunlight(sun_ortho_matrix, m_rtts->getShadowFBO().getRTT()[0]);
|
||||
m_post_processing->renderShadowedSunlight(irr_driver->getSunDirection(), irr_driver->getSunColor(), sun_ortho_matrix, m_rtts->getShadowFBO().getRTT()[0]);
|
||||
else
|
||||
m_post_processing->renderSunlight();
|
||||
m_post_processing->renderSunlight(irr_driver->getSunDirection(), irr_driver->getSunColor());
|
||||
}
|
||||
{
|
||||
ScopedGPUTimer timer(irr_driver->getGPUTimer(Q_POINTLIGHTS));
|
||||
@@ -221,6 +220,7 @@ void IrrDriver::renderLightsScatter(unsigned pointlightcount)
|
||||
glEnable(GL_BLEND);
|
||||
// ***
|
||||
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
getFBO(FBO_COLORS).Bind();
|
||||
m_post_processing->renderPassThrough(getRenderTargetTexture(RTT_HALF1));
|
||||
}
|
||||
@@ -114,7 +114,6 @@ Shaders::Shaders()
|
||||
m_callbacks[ES_GRASS] = new GrassShaderProvider();
|
||||
m_callbacks[ES_MOTIONBLUR] = new MotionBlurProvider();
|
||||
m_callbacks[ES_MIPVIZ] = new MipVizProvider();
|
||||
m_callbacks[ES_SUNLIGHT] = new SunLightProvider();
|
||||
m_callbacks[ES_DISPLACE] = new DisplaceProvider();
|
||||
|
||||
for (s32 i = 0; i < ES_COUNT; i++)
|
||||
@@ -492,22 +491,14 @@ void Shaders::loadShaders()
|
||||
m_shaders[ES_MIPVIZ] = glslmat(dir + "pass.vert", dir + "pass.frag",
|
||||
m_callbacks[ES_MIPVIZ], EMT_SOLID);
|
||||
|
||||
m_shaders[ES_COLORIZE] = glslmat(dir + "pass.vert", dir + "pass.frag",
|
||||
m_callbacks[ES_COLORIZE], EMT_SOLID);
|
||||
|
||||
m_shaders[ES_OBJECTPASS] = glsl_noinput(dir + "pass.vert", dir + "pass.frag");
|
||||
m_shaders[ES_OBJECT_UNLIT] = glsl_noinput(dir + "pass.vert", dir + "pass.frag");
|
||||
m_shaders[ES_OBJECTPASS_REF] = glsl_noinput(dir + "pass.vert", dir + "pass.frag");
|
||||
m_shaders[ES_OBJECTPASS_RIMLIT] = glsl_noinput(dir + "pass.vert", dir + "pass.frag");
|
||||
|
||||
m_shaders[ES_SUNLIGHT] = glsl_noinput(dir + "pass.vert", dir + "pass.frag");
|
||||
|
||||
m_shaders[ES_DISPLACE] = glslmat(dir + "pass.vert", dir + "pass.frag",
|
||||
m_callbacks[ES_DISPLACE], EMT_TRANSPARENT_ALPHA_CHANNEL);
|
||||
|
||||
m_shaders[ES_PASSFAR] = glsl(dir + "pass.vert", dir + "pass.frag",
|
||||
m_callbacks[ES_COLORIZE]);
|
||||
|
||||
// Check that all successfully loaded
|
||||
for (s32 i = 0; i < ES_COUNT; i++) {
|
||||
|
||||
|
||||
@@ -690,14 +690,11 @@ public:
|
||||
ACT(ES_GAUSSIAN3H) \
|
||||
ACT(ES_GAUSSIAN3V) \
|
||||
ACT(ES_MIPVIZ) \
|
||||
ACT(ES_COLORIZE) \
|
||||
ACT(ES_OBJECT_UNLIT) \
|
||||
ACT(ES_OBJECTPASS) \
|
||||
ACT(ES_OBJECTPASS_REF) \
|
||||
ACT(ES_SUNLIGHT) \
|
||||
ACT(ES_OBJECTPASS_RIMLIT) \
|
||||
ACT(ES_DISPLACE) \
|
||||
ACT(ES_PASSFAR) \
|
||||
|
||||
#define ENUM(a) a,
|
||||
#define STR(a) #a,
|
||||
|
||||
@@ -49,11 +49,10 @@ SunNode::~SunNode()
|
||||
|
||||
void SunNode::render()
|
||||
{
|
||||
SunLightProvider * const cb = (SunLightProvider *) irr_driver->getCallback(ES_SUNLIGHT);
|
||||
cb->setColor(m_color[0], m_color[1], m_color[2]);
|
||||
irr_driver->setSunColor(video::SColorf(m_color[0], m_color[1], m_color[2]));
|
||||
|
||||
vector3df pos = getPosition();
|
||||
cb->setPosition(pos.X, pos.Y, pos.Z);
|
||||
irr_driver->setSunDirection(pos);
|
||||
return;
|
||||
|
||||
/* array<IRenderTarget> mrt;
|
||||
|
||||
@@ -214,7 +214,8 @@ void InputManager::handleStaticAction(int key, int value)
|
||||
UserConfigParams::m_camera_debug != 3) break;
|
||||
|
||||
Camera *active_cam = Camera::getActiveCamera();
|
||||
active_cam->setAngularVelocity(value ? 1 : 0);
|
||||
active_cam->setAngularVelocity(value ?
|
||||
UserConfigParams::m_fspcam_max_angular_velocity : 0);
|
||||
break;
|
||||
}
|
||||
case KEY_KEY_E:
|
||||
@@ -223,7 +224,8 @@ void InputManager::handleStaticAction(int key, int value)
|
||||
UserConfigParams::m_camera_debug != 3) break;
|
||||
|
||||
Camera *active_cam = Camera::getActiveCamera();
|
||||
active_cam->setAngularVelocity(value ? -1 : 0);
|
||||
active_cam->setAngularVelocity(value ?
|
||||
-UserConfigParams::m_fspcam_max_angular_velocity : 0);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -965,12 +967,13 @@ EventPropagation InputManager::input(const SEvent& event)
|
||||
core::vector2df screen_size = irr_driver->getCurrentScreenSize();
|
||||
int mid_x = (int) screen_size.X / 2;
|
||||
int mid_y = (int) screen_size.Y / 2;
|
||||
//const int wheel = event.MouseInput.Wheel;
|
||||
// Relative mouse movement
|
||||
int diff_x = event.MouseInput.X - m_mouse_val_x;
|
||||
int diff_y = event.MouseInput.Y - m_mouse_val_y;
|
||||
float mouse_x = ((float) diff_x) / 150;
|
||||
float mouse_y = ((float) diff_y) / -150;
|
||||
float mouse_x = ((float) diff_x) *
|
||||
UserConfigParams::m_fspcam_direction_speed;
|
||||
float mouse_y = ((float) diff_y) *
|
||||
-UserConfigParams::m_fspcam_direction_speed;
|
||||
// No movement the first time it's used
|
||||
// At the moment there's also a hard limit because the mouse
|
||||
// gets reset to the middle of the screen and sometimes there
|
||||
|
||||
Reference in New Issue
Block a user