Merge branch 'master' of github.com:supertuxkart/stk-code
Conflicts: src/graphics/stkinstancedscenenode.cpp
This commit is contained in:
commit
f338282a15
@ -136,6 +136,9 @@ include_directories(${OPENGL_INCLUDE_DIR})
|
||||
if(UNIX AND NOT APPLE)
|
||||
if(USE_XRANDR)
|
||||
find_package(Xrandr REQUIRED)
|
||||
if(NOT XRANDR_FOUND)
|
||||
message(FATAL_ERROR "XRANDR not found.")
|
||||
endif()
|
||||
else()
|
||||
find_library(IRRLICHT_XF86VM_LIBRARY Xxf86vm)
|
||||
mark_as_advanced(IRRLICHT_XF86VM_LIBRARY)
|
||||
|
@ -1,39 +1,33 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
Particle system to simulate it's raining heavily over an item/kart.
|
||||
It should be applied no matter if kart is flying or on (any) ground,
|
||||
and rotate to always fire up, it just simulates the rain bouncing
|
||||
off the kart and being fired by wheels. It could also be applied to
|
||||
bowling balls, for example.
|
||||
-->
|
||||
<particles emitter="box" box_x="0.5" box_y="1.0" box_z="1.0">
|
||||
|
||||
<spreading angle="10" />
|
||||
<!-- For sky particles, the size of the box is ignored -->
|
||||
<particles emitter="box">
|
||||
|
||||
<spreading angle="3" />
|
||||
|
||||
<velocity x="0.000"
|
||||
y="0.009"
|
||||
z="0.000" />
|
||||
<velocity x="-0.00"
|
||||
y="-0.05"
|
||||
z="-0.00" />
|
||||
|
||||
<material file="water-splash.png" />
|
||||
<material file="rain.png" clampu="Y" clampv="Y" />
|
||||
|
||||
<!-- Amount of particles emitted per second -->
|
||||
<rate min="50"
|
||||
max="60" />
|
||||
<rate min="2000"
|
||||
max="3000" />
|
||||
|
||||
<!-- Minimal and maximal lifetime of a particle, in milliseconds. -->
|
||||
<lifetime min="1000"
|
||||
max="1000" />
|
||||
<lifetime min="10000"
|
||||
max="10000" />
|
||||
|
||||
<!-- Size of the particles -->
|
||||
<size min="0.35"
|
||||
max="0.70" />
|
||||
|
||||
<size min="0.20"
|
||||
max="0.40" />
|
||||
|
||||
<color min="255 255 255"
|
||||
max="255 255 255" />
|
||||
|
||||
max="255 255 255" />
|
||||
|
||||
<!-- How much time in milliseconds before the particle is fully faded out -->
|
||||
<fadeout time="750" />
|
||||
<fadeout time="100" />
|
||||
|
||||
|
||||
<gravity strength="-0.01"
|
||||
only-force-time="500" />
|
||||
</particles>
|
||||
|
@ -1,14 +1,14 @@
|
||||
uniform vec2 center;
|
||||
uniform vec2 size;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 position;
|
||||
#if __VERSION__ >= 330
|
||||
layout(location = 0) in vec2 Position;
|
||||
#else
|
||||
attribute vec2 position;
|
||||
in vec2 Position;
|
||||
#endif
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(position * size + center, 0., 1.);
|
||||
gl_Position = vec4(Position * size + center, 0., 1.);
|
||||
}
|
@ -3,24 +3,22 @@ uniform vec2 size;
|
||||
uniform vec2 texcenter;
|
||||
uniform vec2 texsize;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 position;
|
||||
in vec2 texcoord;
|
||||
in uvec4 color;
|
||||
out vec2 uv;
|
||||
out vec4 col;
|
||||
#if __VERSION__ >= 330
|
||||
layout(location=0) in vec2 Position;
|
||||
layout(location=3) in vec2 Texcoord;
|
||||
layout(location=2) in uvec4 Color;
|
||||
#else
|
||||
attribute vec2 position;
|
||||
attribute vec2 texcoord;
|
||||
attribute uvec4 color;
|
||||
varying vec2 uv;
|
||||
varying vec4 col;
|
||||
in vec2 Position;
|
||||
in vec2 Texcoord;
|
||||
in uvec4 Color;
|
||||
#endif
|
||||
|
||||
out vec2 uv;
|
||||
out vec4 col;
|
||||
|
||||
void main()
|
||||
{
|
||||
col = vec4(color) / 255.;
|
||||
uv = texcoord * texsize + texcenter;
|
||||
gl_Position = vec4(position * size + center, 0., 1.);
|
||||
col = vec4(Color) / 255.;
|
||||
uv = Texcoord * texsize + texcenter;
|
||||
gl_Position = vec4(Position * size + center, 0., 1.);
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
in vec2 quadcorner;
|
||||
in vec2 texcoord;
|
||||
in vec3 position;
|
||||
in float lifetime;
|
||||
in float size;
|
||||
layout(location=0) in vec3 Position;
|
||||
layout(location = 1) in float lifetime;
|
||||
layout(location = 2) in float size;
|
||||
|
||||
in vec3 rotationvec;
|
||||
in float anglespeed;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
layout(location = 4) in vec2 quadcorner;
|
||||
|
||||
layout(location = 5) in vec3 rotationvec;
|
||||
layout(location = 6) in float anglespeed;
|
||||
|
||||
out float lf;
|
||||
out vec2 tc;
|
||||
@ -13,9 +14,9 @@ out vec3 pc;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
tc = texcoord;
|
||||
tc = Texcoord;
|
||||
lf = lifetime;
|
||||
vec3 newposition = position;
|
||||
vec3 newposition = Position;
|
||||
|
||||
// from http://jeux.developpez.com/faq/math
|
||||
float angle = lf * anglespeed;
|
||||
|
@ -3,6 +3,8 @@ 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 = 5) in vec3 Tangent;
|
||||
layout(location = 6) in vec3 Bitangent;
|
||||
|
||||
layout(location = 7) in vec3 Origin;
|
||||
layout(location = 8) in vec3 Orientation;
|
||||
@ -19,6 +21,8 @@ in vec3 Scale;
|
||||
#endif
|
||||
|
||||
out vec3 nor;
|
||||
out vec3 tangent;
|
||||
out vec3 bitangent;
|
||||
out vec2 uv;
|
||||
out vec4 color;
|
||||
|
||||
@ -31,6 +35,8 @@ void main(void)
|
||||
mat4 TransposeInverseModelView = transpose(getInverseWorldMatrix(Origin, Orientation, Scale) * InverseViewMatrix);
|
||||
gl_Position = ProjectionMatrix * ViewMatrix * ModelMatrix * vec4(Position, 1.);
|
||||
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
|
||||
tangent = (TransposeInverseModelView * vec4(Tangent, 1.)).xyz;
|
||||
bitangent = (TransposeInverseModelView * vec4(Bitangent, 1.)).xyz;
|
||||
uv = Texcoord;
|
||||
color = Color.zyxw;
|
||||
}
|
||||
|
@ -1,29 +0,0 @@
|
||||
uniform mat4 ModelMatrix;
|
||||
uniform mat4 InverseModelMatrix;
|
||||
|
||||
#if __VERSION__ >= 330
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
layout(location = 5) in vec3 Tangent;
|
||||
layout(location = 6) in vec3 Bitangent;
|
||||
#else
|
||||
in vec3 Position;
|
||||
in vec2 Texcoord;
|
||||
in vec3 Tangent;
|
||||
in vec3 Bitangent;
|
||||
#endif
|
||||
|
||||
out vec3 tangent;
|
||||
out vec3 bitangent;
|
||||
out vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
mat4 ModelViewProjectionMatrix = ProjectionMatrix * ViewMatrix * ModelMatrix;
|
||||
mat4 TransposeInverseModelView = transpose(InverseModelMatrix * InverseViewMatrix);
|
||||
uv = Texcoord;
|
||||
tangent = (TransposeInverseModelView * vec4(Tangent, 1.)).xyz;
|
||||
bitangent = (TransposeInverseModelView * vec4(Bitangent, 1.)).xyz;
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
|
||||
|
||||
}
|
@ -13,6 +13,8 @@ layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec4 Color;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
layout(location = 4) in vec2 SecondTexcoord;
|
||||
layout(location = 5) in vec3 Tangent;
|
||||
layout(location = 6) in vec3 Bitangent;
|
||||
#else
|
||||
in vec3 Position;
|
||||
in vec3 Normal;
|
||||
@ -22,6 +24,8 @@ in vec2 SecondTexcoord;
|
||||
#endif
|
||||
|
||||
out vec3 nor;
|
||||
out vec3 tangent;
|
||||
out vec3 bitangent;
|
||||
out vec2 uv;
|
||||
out vec2 uv_bis;
|
||||
out vec4 color;
|
||||
@ -34,6 +38,8 @@ void main(void)
|
||||
mat4 TransposeInverseModelView = transpose(InverseModelMatrix * InverseViewMatrix);
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
|
||||
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
|
||||
tangent = (TransposeInverseModelView * vec4(Tangent, 1.)).xyz;
|
||||
bitangent = (TransposeInverseModelView * vec4(Bitangent, 1.)).xyz;
|
||||
uv = (TextureMatrix * vec4(Texcoord, 1., 1.)).xy;
|
||||
uv_bis = SecondTexcoord;
|
||||
}
|
||||
|
@ -7,17 +7,16 @@ in vec2 tc;
|
||||
in vec3 pc;
|
||||
out vec4 FragColor;
|
||||
|
||||
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 xy = gl_FragCoord.xy / screen;
|
||||
float FragZ = gl_FragCoord.z;
|
||||
float EnvZ = texture(dtex, xy).x;
|
||||
vec4 FragmentPos = invproj * (2. * vec4(xy, FragZ, 1.0) - 1.);
|
||||
FragmentPos /= FragmentPos.w;
|
||||
vec4 EnvPos = invproj * (2. * vec4(xy, EnvZ, 1.0) - 1.);
|
||||
EnvPos /= EnvPos.w;
|
||||
float alpha = clamp((EnvPos.z - FragmentPos.z) * 0.3, 0., 1.);
|
||||
vec2 xy = gl_FragCoord.xy / screen;
|
||||
float FragZ = gl_FragCoord.z;
|
||||
vec4 FragmentPos = getPosFromUVDepth(vec3(xy, FragZ), InverseProjectionMatrix);
|
||||
float EnvZ = texture(dtex, xy).x;
|
||||
vec4 EnvPos = getPosFromUVDepth(vec3(xy, EnvZ), InverseProjectionMatrix);
|
||||
float alpha = clamp((EnvPos.z - FragmentPos.z) * 0.3, 0., 1.);
|
||||
vec4 color = texture(tex, tc) * vec4(pc, 1.0);
|
||||
FragColor = color * alpha * smoothstep(1., 0.8, lf);
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
uniform vec3 color_from;
|
||||
uniform vec3 color_to;
|
||||
|
||||
in vec2 quadcorner;
|
||||
in vec2 texcoord;
|
||||
in vec3 position;
|
||||
in float lifetime;
|
||||
in float size;
|
||||
layout(location=0) in vec3 Position;
|
||||
layout(location = 1) in float lifetime;
|
||||
layout(location = 2) in float size;
|
||||
|
||||
layout(location=3) in vec2 Texcoord;
|
||||
layout(location = 4) in vec2 quadcorner;
|
||||
|
||||
out float lf;
|
||||
out vec2 tc;
|
||||
@ -13,12 +14,12 @@ out vec3 pc;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
tc = texcoord;
|
||||
lf = lifetime;
|
||||
tc = Texcoord;
|
||||
lf = lifetime;
|
||||
pc = color_from + (color_to - color_from) * lifetime;
|
||||
vec3 newposition = position;
|
||||
vec3 newposition = Position;
|
||||
|
||||
vec4 viewpos = ViewMatrix * vec4(newposition, 1.0);
|
||||
viewpos += size * vec4(quadcorner, 0., 0.);
|
||||
gl_Position = ProjectionMatrix * viewpos;
|
||||
viewpos += size * vec4(quadcorner, 0., 0.);
|
||||
gl_Position = ProjectionMatrix * viewpos;
|
||||
}
|
||||
|
@ -9,15 +9,15 @@ uniform float track_x_len;
|
||||
uniform float track_z_len;
|
||||
uniform samplerBuffer heightmap;
|
||||
|
||||
in vec3 particle_position_initial;
|
||||
in float lifetime_initial;
|
||||
in vec3 particle_velocity_initial;
|
||||
in float size_initial;
|
||||
layout (location = 4) in vec3 particle_position_initial;
|
||||
layout (location = 5) in float lifetime_initial;
|
||||
layout (location = 6) in vec3 particle_velocity_initial;
|
||||
layout (location = 7) in float size_initial;
|
||||
|
||||
in vec3 particle_position;
|
||||
in float lifetime;
|
||||
in vec3 particle_velocity;
|
||||
in float size;
|
||||
layout (location = 0) in vec3 particle_position;
|
||||
layout (location = 1) in float lifetime;
|
||||
layout (location = 2) in vec3 particle_velocity;
|
||||
layout (location = 3) in float size;
|
||||
|
||||
out vec3 new_particle_position;
|
||||
out float new_lifetime;
|
||||
|
@ -3,15 +3,15 @@ uniform mat4 sourcematrix;
|
||||
uniform int level;
|
||||
uniform float size_increase_factor;
|
||||
|
||||
in vec3 particle_position_initial;
|
||||
in float lifetime_initial;
|
||||
in vec3 particle_velocity_initial;
|
||||
in float size_initial;
|
||||
layout (location = 4) in vec3 particle_position_initial;
|
||||
layout (location = 5) in float lifetime_initial;
|
||||
layout (location = 6) in vec3 particle_velocity_initial;
|
||||
layout (location = 7) in float size_initial;
|
||||
|
||||
in vec3 particle_position;
|
||||
in float lifetime;
|
||||
in vec3 particle_velocity;
|
||||
in float size;
|
||||
layout (location = 0) in vec3 particle_position;
|
||||
layout (location = 1) in float lifetime;
|
||||
layout (location = 2) in vec3 particle_velocity;
|
||||
layout (location = 3) in float size;
|
||||
|
||||
out vec3 new_particle_position;
|
||||
out float new_lifetime;
|
||||
|
@ -3,19 +3,18 @@ uniform vec2 size;
|
||||
uniform vec2 texcenter;
|
||||
uniform vec2 texsize;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 position;
|
||||
in vec2 texcoord;
|
||||
out vec2 uv;
|
||||
#if __VERSION__ >= 330
|
||||
layout(location=0) in vec2 Position;
|
||||
layout(location=3) in vec2 Texcoord;
|
||||
#else
|
||||
attribute vec2 position;
|
||||
attribute vec2 texcoord;
|
||||
varying vec2 uv;
|
||||
in vec2 Position;
|
||||
in vec2 Texcoord;
|
||||
#endif
|
||||
|
||||
out vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
uv = texcoord * texsize + texcenter;
|
||||
gl_Position = vec4(position * size + center, 0., 1.);
|
||||
uv = Texcoord * texsize + texcenter;
|
||||
gl_Position = vec4(Position * size + center, 0., 1.);
|
||||
}
|
@ -67,8 +67,7 @@ AnimationBase::AnimationBase(Ipo *ipo)
|
||||
void AnimationBase::setInitialTransform(const Vec3 &xyz,
|
||||
const Vec3 &hpr)
|
||||
{
|
||||
Ipo* curr;
|
||||
for_in (curr, m_all_ipos)
|
||||
for_var_in(Ipo*, curr, m_all_ipos)
|
||||
{
|
||||
curr->setInitialTransform(xyz, hpr);
|
||||
}
|
||||
@ -80,8 +79,7 @@ void AnimationBase::setInitialTransform(const Vec3 &xyz,
|
||||
void AnimationBase::reset()
|
||||
{
|
||||
m_current_time = 0;
|
||||
Ipo* curr;
|
||||
for_in (curr, m_all_ipos)
|
||||
for_var_in(Ipo*, curr, m_all_ipos)
|
||||
{
|
||||
curr->reset();
|
||||
}
|
||||
@ -103,8 +101,7 @@ void AnimationBase::update(float dt, Vec3 *xyz, Vec3 *hpr, Vec3 *scale)
|
||||
|
||||
assert(!isnan(m_current_time));
|
||||
|
||||
Ipo* curr;
|
||||
for_in (curr, m_all_ipos)
|
||||
for_var_in (Ipo*, curr, m_all_ipos)
|
||||
{
|
||||
curr->update(m_current_time, xyz, hpr, scale);
|
||||
}
|
||||
|
@ -90,8 +90,7 @@ public:
|
||||
{
|
||||
float duration = -1;
|
||||
|
||||
const Ipo* currIpo;
|
||||
for_in (currIpo, m_all_ipos)
|
||||
for_var_in (const Ipo*, currIpo, m_all_ipos)
|
||||
{
|
||||
duration = std::max(duration, currIpo->getEndTime());
|
||||
}
|
||||
|
@ -167,8 +167,7 @@ PlayerManager::PlayerManager()
|
||||
PlayerManager::~PlayerManager()
|
||||
{
|
||||
// If the passwords should not be remembered, clear the saved session.
|
||||
PlayerProfile *player;
|
||||
for_in(player, m_all_players)
|
||||
for_var_in(PlayerProfile*, player, m_all_players)
|
||||
{
|
||||
if(!player->rememberPassword())
|
||||
player->clearSession();
|
||||
@ -270,8 +269,7 @@ void PlayerManager::save()
|
||||
}
|
||||
|
||||
// Save all non-guest players
|
||||
PlayerProfile *player;
|
||||
for_in(player, m_all_players)
|
||||
for_var_in(PlayerProfile*, player, m_all_players)
|
||||
{
|
||||
if(!player->isGuestAccount())
|
||||
player->save(players_file);
|
||||
@ -320,8 +318,8 @@ void PlayerManager::deletePlayer(PlayerProfile *player)
|
||||
void PlayerManager::enforceCurrentPlayer()
|
||||
{
|
||||
if (m_current_player) return;
|
||||
|
||||
PlayerProfile *player;
|
||||
|
||||
PlayerProfile* player;
|
||||
for_in(player, m_all_players)
|
||||
{
|
||||
if (!player->isGuestAccount())
|
||||
@ -408,8 +406,7 @@ void PlayerManager::createGuestPlayers(int n)
|
||||
unsigned int PlayerManager::getNumNonGuestPlayers() const
|
||||
{
|
||||
unsigned int count=0;
|
||||
const PlayerProfile *player;
|
||||
for_in(player, m_all_players)
|
||||
for_var_in(const PlayerProfile*, player, m_all_players)
|
||||
{
|
||||
if(!player->isGuestAccount()) count ++;
|
||||
}
|
||||
@ -422,8 +419,7 @@ unsigned int PlayerManager::getNumNonGuestPlayers() const
|
||||
unsigned int PlayerManager::getUniqueId() const
|
||||
{
|
||||
unsigned int max_id=0;
|
||||
const PlayerProfile *player;
|
||||
for_in(player, m_all_players)
|
||||
for_var_in(const PlayerProfile*, player, m_all_players)
|
||||
{
|
||||
if(player->getUniqueID()>max_id)
|
||||
max_id = player->getUniqueID();
|
||||
@ -439,8 +435,7 @@ unsigned int PlayerManager::getUniqueId() const
|
||||
*/
|
||||
const PlayerProfile *PlayerManager::getPlayerById(unsigned int id)
|
||||
{
|
||||
const PlayerProfile *player;
|
||||
for_in(player, m_all_players)
|
||||
for_var_in(const PlayerProfile*, player, m_all_players)
|
||||
{
|
||||
if(player->getUniqueID()==id)
|
||||
return player;
|
||||
@ -455,8 +450,7 @@ const PlayerProfile *PlayerManager::getPlayerById(unsigned int id)
|
||||
*/
|
||||
PlayerProfile *PlayerManager::getPlayer(const irr::core::stringw &name)
|
||||
{
|
||||
PlayerProfile *player;
|
||||
for_in(player, m_all_players)
|
||||
for_var_in(PlayerProfile*, player, m_all_players)
|
||||
{
|
||||
if(player->getName()==name)
|
||||
return player;
|
||||
|
@ -908,14 +908,16 @@ static void drawTexColoredQuad(const video::ITexture *texture, const video::SCol
|
||||
col[3].getRed(), col[3].getGreen(), col[3].getBlue(), col[3].getAlpha(),
|
||||
};
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, UIShader::ColoredTextureRectShader::colorvbo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, UIShader::ColoredTextureRectShader::getInstance()->colorvbo);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, 16 * sizeof(unsigned), colors);
|
||||
|
||||
glUseProgram(UIShader::ColoredTextureRectShader::Program);
|
||||
glBindVertexArray(UIShader::ColoredTextureRectShader::vao);
|
||||
glUseProgram(UIShader::ColoredTextureRectShader::getInstance()->Program);
|
||||
glBindVertexArray(UIShader::ColoredTextureRectShader::getInstance()->vao);
|
||||
|
||||
setTexture(0, static_cast<const irr::video::COpenGLTexture*>(texture)->getOpenGLTextureName(), GL_LINEAR, GL_LINEAR);
|
||||
UIShader::TextureRectShader::setUniforms(center_pos_x, center_pos_y, width, height, tex_center_pos_x, tex_center_pos_y, tex_width, tex_height, 0);
|
||||
setTexture(UIShader::ColoredTextureRectShader::getInstance()->TU_tex, static_cast<const irr::video::COpenGLTexture*>(texture)->getOpenGLTextureName(), GL_LINEAR, GL_LINEAR);
|
||||
UIShader::ColoredTextureRectShader::getInstance()->setUniforms(
|
||||
core::vector2df(center_pos_x, center_pos_y), core::vector2df(width, height),
|
||||
core::vector2df(tex_center_pos_x, tex_center_pos_y), core::vector2df(tex_width, tex_height));
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindVertexArray(0);
|
||||
@ -929,11 +931,14 @@ void drawTexQuad(GLuint texture, float width, float height,
|
||||
float center_pos_x, float center_pos_y, float tex_center_pos_x, float tex_center_pos_y,
|
||||
float tex_width, float tex_height)
|
||||
{
|
||||
glUseProgram(UIShader::TextureRectShader::Program);
|
||||
glBindVertexArray(UIShader::TextureRectShader::vao);
|
||||
glUseProgram(UIShader::TextureRectShader::getInstance()->Program);
|
||||
glBindVertexArray(SharedObject::UIVAO);
|
||||
|
||||
setTexture(0, texture, GL_LINEAR, GL_LINEAR);
|
||||
UIShader::TextureRectShader::setUniforms(center_pos_x, center_pos_y, width, height, tex_center_pos_x, tex_center_pos_y, tex_width, tex_height, 0);
|
||||
setTexture(UIShader::TextureRectShader::getInstance()->TU_tex, texture, GL_LINEAR, GL_LINEAR);
|
||||
UIShader::TextureRectShader::getInstance()->setUniforms(
|
||||
core::vector2df(center_pos_x, center_pos_y), core::vector2df(width, height),
|
||||
core::vector2df(tex_center_pos_x, tex_center_pos_y),
|
||||
core::vector2df(tex_width, tex_height));
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindVertexArray(0);
|
||||
@ -1029,11 +1034,12 @@ void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect
|
||||
clipRect->getWidth(), clipRect->getHeight());
|
||||
}
|
||||
|
||||
glUseProgram(UIShader::UniformColoredTextureRectShader::Program);
|
||||
glBindVertexArray(UIShader::UniformColoredTextureRectShader::vao);
|
||||
glUseProgram(UIShader::UniformColoredTextureRectShader::getInstance()->Program);
|
||||
glBindVertexArray(SharedObject::UIVAO);
|
||||
|
||||
setTexture(0, static_cast<const irr::video::COpenGLTexture*>(texture)->getOpenGLTextureName(), GL_LINEAR, GL_LINEAR);
|
||||
UIShader::UniformColoredTextureRectShader::setUniforms(center_pos_x, center_pos_y, width, height, tex_center_pos_x, tex_center_pos_y, tex_width, tex_height,colors, 0);
|
||||
setTexture(UIShader::UniformColoredTextureRectShader::getInstance()->TU_tex, static_cast<const irr::video::COpenGLTexture*>(texture)->getOpenGLTextureName(), GL_LINEAR, GL_LINEAR);
|
||||
UIShader::UniformColoredTextureRectShader::getInstance()->setUniforms(
|
||||
core::vector2df(center_pos_x, center_pos_y), core::vector2df(width, height), core::vector2df(tex_center_pos_x, tex_center_pos_y), core::vector2df(tex_width, tex_height), colors);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindVertexArray(0);
|
||||
@ -1064,11 +1070,14 @@ void draw2DImageFromRTT(GLuint texture, size_t texture_w, size_t texture_h,
|
||||
destRect, sourceRect, width, height, center_pos_x, center_pos_y,
|
||||
tex_width, tex_height, tex_center_pos_x, tex_center_pos_y);
|
||||
|
||||
glUseProgram(UIShader::UniformColoredTextureRectShader::Program);
|
||||
glBindVertexArray(UIShader::UniformColoredTextureRectShader::vao);
|
||||
glUseProgram(UIShader::UniformColoredTextureRectShader::getInstance()->Program);
|
||||
glBindVertexArray(SharedObject::UIVAO);
|
||||
|
||||
setTexture(0, texture, GL_LINEAR, GL_LINEAR);
|
||||
UIShader::UniformColoredTextureRectShader::setUniforms(center_pos_x, center_pos_y, width, height, tex_center_pos_x, tex_center_pos_y, tex_width, tex_height, colors, 0);
|
||||
setTexture(UIShader::UniformColoredTextureRectShader::getInstance()->TU_tex, texture, GL_LINEAR, GL_LINEAR);
|
||||
UIShader::UniformColoredTextureRectShader::getInstance()->setUniforms(
|
||||
core::vector2df(center_pos_x, center_pos_y), core::vector2df(width, height),
|
||||
core::vector2df(tex_center_pos_x, tex_center_pos_y), core::vector2df(tex_width, tex_height),
|
||||
colors);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindVertexArray(0);
|
||||
@ -1172,9 +1181,9 @@ void GL32_draw2DRectangle(video::SColor color, const core::rect<s32>& position,
|
||||
clip->getWidth(), clip->getHeight());
|
||||
}
|
||||
|
||||
glUseProgram(UIShader::ColoredRectShader::Program);
|
||||
glBindVertexArray(UIShader::ColoredRectShader::vao);
|
||||
UIShader::ColoredRectShader::setUniforms(center_pos_x, center_pos_y, width, height, color);
|
||||
glUseProgram(UIShader::ColoredRectShader::getInstance()->Program);
|
||||
glBindVertexArray(SharedObject::UIVAO);
|
||||
UIShader::ColoredRectShader::getInstance()->setUniforms(core::vector2df(center_pos_x, center_pos_y), core::vector2df(width, height), color);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
@ -24,29 +24,22 @@ scene::IParticleSystemSceneNode *ParticleSystemProxy::addParticleNode(
|
||||
return node;
|
||||
}
|
||||
|
||||
GLuint ParticleSystemProxy::quad_vertex_buffer = 0;
|
||||
|
||||
ParticleSystemProxy::ParticleSystemProxy(bool createDefaultEmitter,
|
||||
ISceneNode* parent, scene::ISceneManager* mgr, s32 id,
|
||||
const core::vector3df& position,
|
||||
const core::vector3df& rotation,
|
||||
const core::vector3df& scale) : CParticleSystemSceneNode(createDefaultEmitter, parent, mgr, id, position, rotation, scale), m_alpha_additive(false)
|
||||
const core::vector3df& scale) : CParticleSystemSceneNode(createDefaultEmitter, parent, mgr, id, position, rotation, scale), m_alpha_additive(false), m_first_execution(true)
|
||||
{
|
||||
glGenBuffers(1, &initial_values_buffer);
|
||||
glGenBuffers(2, tfb_buffers);
|
||||
glGenBuffers(1, &quaternionsbuffer);
|
||||
glGenVertexArrays(1, ¤t_rendering_vao);
|
||||
glGenVertexArrays(1, &non_current_rendering_vao);
|
||||
size_increase_factor = 0.;
|
||||
ParticleParams = nullptr;
|
||||
InitialValues = nullptr;
|
||||
|
||||
m_color_from[0] = m_color_from[1] = m_color_from[2] = 1.0;
|
||||
m_color_to[0] = m_color_to[1] = m_color_to[2] = 1.0;
|
||||
|
||||
|
||||
|
||||
// We set these later but avoid coverity report them
|
||||
heighmapbuffer = 0;
|
||||
heightmaptexture = 0;
|
||||
current_simulation_vao = 0;
|
||||
has_height_map = false;
|
||||
flip = false;
|
||||
track_x = 0;
|
||||
@ -54,27 +47,16 @@ ParticleSystemProxy::ParticleSystemProxy(bool createDefaultEmitter,
|
||||
track_x_len = 0;
|
||||
track_z_len = 0;
|
||||
texture = 0;
|
||||
|
||||
if (quad_vertex_buffer)
|
||||
return;
|
||||
static const GLfloat quad_vertex[] = {
|
||||
-.5, -.5, 0., 0.,
|
||||
.5, -.5, 1., 0.,
|
||||
-.5, .5, 0., 1.,
|
||||
.5, .5, 1., 1.,
|
||||
};
|
||||
glGenBuffers(1, &quad_vertex_buffer);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, quad_vertex_buffer);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(quad_vertex), quad_vertex, GL_STATIC_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
ParticleSystemProxy::~ParticleSystemProxy()
|
||||
{
|
||||
glDeleteBuffers(2, tfb_buffers);
|
||||
glDeleteBuffers(1, &initial_values_buffer);
|
||||
if (quaternionsbuffer)
|
||||
glDeleteBuffers(1, &quaternionsbuffer);
|
||||
if (InitialValues)
|
||||
free(InitialValues);
|
||||
if (ParticleParams)
|
||||
free(ParticleParams);
|
||||
if (!m_first_execution)
|
||||
cleanGL();
|
||||
if (heighmapbuffer)
|
||||
glDeleteBuffers(1, &heighmapbuffer);
|
||||
if (heightmaptexture)
|
||||
@ -137,51 +119,32 @@ void generateLifetimeSizeDirection(scene::IParticleEmitter *emitter, float &life
|
||||
dirZ = particledir.Z;
|
||||
}
|
||||
|
||||
struct ParticleData
|
||||
{
|
||||
float PositionX;
|
||||
float PositionY;
|
||||
float PositionZ;
|
||||
float Lifetime;
|
||||
float DirectionX;
|
||||
float DirectionY;
|
||||
float DirectionZ;
|
||||
float Size;
|
||||
};
|
||||
|
||||
void ParticleSystemProxy::generateParticlesFromPointEmitter(scene::IParticlePointEmitter *emitter)
|
||||
{
|
||||
ParticleData *particles = new ParticleData[count], *initialvalue = new ParticleData[count];
|
||||
ParticleParams = (ParticleData *) realloc(ParticleParams, sizeof(ParticleData) * count);
|
||||
InitialValues = (ParticleData *)realloc(InitialValues, sizeof(ParticleData)* count);
|
||||
|
||||
for (unsigned i = 0; i < count; i++)
|
||||
{
|
||||
particles[i].PositionX = 0;
|
||||
particles[i].PositionY = 0;
|
||||
particles[i].PositionZ = 0;
|
||||
ParticleParams[i].PositionX = 0;
|
||||
ParticleParams[i].PositionY = 0;
|
||||
ParticleParams[i].PositionZ = 0;
|
||||
// Initial lifetime is >1
|
||||
particles[i].Lifetime = 2.;
|
||||
InitialValues[i].Lifetime = 2.;
|
||||
|
||||
memcpy(&(initialvalue[i].PositionX), &(particles[i].PositionX), 3 * sizeof(float));
|
||||
memcpy(&(InitialValues[i].PositionX), &(ParticleParams[i].PositionX), 3 * sizeof(float));
|
||||
|
||||
generateLifetimeSizeDirection(emitter, initialvalue[i].Lifetime, initialvalue[i].Size,
|
||||
initialvalue[i].DirectionX, initialvalue[i].DirectionY, initialvalue[i].DirectionZ);
|
||||
generateLifetimeSizeDirection(emitter, ParticleParams[i].Lifetime, ParticleParams[i].Size,
|
||||
ParticleParams[i].DirectionX, ParticleParams[i].DirectionY, ParticleParams[i].DirectionZ);
|
||||
|
||||
memcpy(&(particles[i].DirectionX), &(initialvalue[i].DirectionX), 4 * sizeof(float));
|
||||
memcpy(&(InitialValues[i].DirectionX), &(ParticleParams[i].DirectionX), 4 * sizeof(float));
|
||||
}
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, initial_values_buffer);
|
||||
glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), initialvalue, GL_STREAM_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, tfb_buffers[0]);
|
||||
glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), particles, GL_STREAM_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, tfb_buffers[1]);
|
||||
glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), 0, GL_STREAM_DRAW);
|
||||
delete[] particles;
|
||||
delete[] initialvalue;
|
||||
}
|
||||
|
||||
void ParticleSystemProxy::generateParticlesFromBoxEmitter(scene::IParticleBoxEmitter *emitter)
|
||||
{
|
||||
ParticleData *particles = new ParticleData[count], *initialvalue = new ParticleData[count];
|
||||
ParticleParams = (ParticleData *)realloc(ParticleParams, sizeof(ParticleData)* count);
|
||||
InitialValues = (ParticleData *)realloc(InitialValues, sizeof(ParticleData)* count);
|
||||
|
||||
const core::vector3df& extent = emitter->getBox().getExtent();
|
||||
|
||||
@ -189,33 +152,26 @@ void ParticleSystemProxy::generateParticlesFromBoxEmitter(scene::IParticleBoxEmi
|
||||
|
||||
for (unsigned i = 0; i < count; i++)
|
||||
{
|
||||
particles[i].PositionX = emitter->getBox().MinEdge.X + os::Randomizer::frand() * extent.X;
|
||||
particles[i].PositionY = emitter->getBox().MinEdge.Y + os::Randomizer::frand() * extent.Y;
|
||||
particles[i].PositionZ = emitter->getBox().MinEdge.Z + os::Randomizer::frand() * extent.Z;
|
||||
ParticleParams[i].PositionX = emitter->getBox().MinEdge.X + os::Randomizer::frand() * extent.X;
|
||||
ParticleParams[i].PositionY = emitter->getBox().MinEdge.Y + os::Randomizer::frand() * extent.Y;
|
||||
ParticleParams[i].PositionZ = emitter->getBox().MinEdge.Z + os::Randomizer::frand() * extent.Z;
|
||||
// Initial lifetime is random
|
||||
particles[i].Lifetime = os::Randomizer::frand();
|
||||
InitialValues[i].Lifetime = os::Randomizer::frand();
|
||||
|
||||
memcpy(&(initialvalue[i].PositionX), &(particles[i].PositionX), 3 * sizeof(float));
|
||||
generateLifetimeSizeDirection(emitter, initialvalue[i].Lifetime, initialvalue[i].Size,
|
||||
initialvalue[i].DirectionX, initialvalue[i].DirectionY, initialvalue[i].DirectionZ);
|
||||
memcpy(&(particles[i].DirectionX), &(initialvalue[i].DirectionX), 4 * sizeof(float));
|
||||
memcpy(&(InitialValues[i].PositionX), &(ParticleParams[i].PositionX), 3 * sizeof(float));
|
||||
generateLifetimeSizeDirection(emitter, ParticleParams[i].Lifetime, ParticleParams[i].Size,
|
||||
ParticleParams[i].DirectionX, ParticleParams[i].DirectionY, ParticleParams[i].DirectionZ);
|
||||
memcpy(&(InitialValues[i].DirectionX), &(ParticleParams[i].DirectionX), 4 * sizeof(float));
|
||||
|
||||
if (randomize_initial_y)
|
||||
particles[i].PositionY = os::Randomizer::frand()*50.0f; // -100.0f;
|
||||
InitialValues[i].PositionY = os::Randomizer::frand()*50.0f; // -100.0f;
|
||||
}
|
||||
glBindBuffer(GL_ARRAY_BUFFER, initial_values_buffer);
|
||||
glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), initialvalue, GL_STREAM_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, tfb_buffers[0]);
|
||||
glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), particles, GL_STREAM_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, tfb_buffers[1]);
|
||||
glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), 0, GL_STREAM_DRAW);
|
||||
delete[] particles;
|
||||
delete[] initialvalue;
|
||||
}
|
||||
|
||||
void ParticleSystemProxy::generateParticlesFromSphereEmitter(scene::IParticleSphereEmitter *emitter)
|
||||
{
|
||||
ParticleData *particles = new ParticleData[count], *initialvalue = new ParticleData[count];
|
||||
ParticleParams = (ParticleData *)realloc(ParticleParams, sizeof(ParticleData)* count);
|
||||
InitialValues = (ParticleData *)realloc(InitialValues, sizeof(ParticleData)* count);
|
||||
|
||||
for (unsigned i = 0; i < count; i++) {
|
||||
// Random distance from center
|
||||
@ -227,25 +183,17 @@ void ParticleSystemProxy::generateParticlesFromSphereEmitter(scene::IParticleSph
|
||||
pos.rotateYZBy(os::Randomizer::frand() * 360.f, emitter->getCenter());
|
||||
pos.rotateXZBy(os::Randomizer::frand() * 360.f, emitter->getCenter());
|
||||
|
||||
particles[i].PositionX = pos.X;
|
||||
particles[i].PositionY = pos.Y;
|
||||
particles[i].PositionZ = pos.Z;
|
||||
ParticleParams[i].PositionX = pos.X;
|
||||
ParticleParams[i].PositionY = pos.Y;
|
||||
ParticleParams[i].PositionZ = pos.Z;
|
||||
// Initial lifetime is > 1
|
||||
particles[i].Lifetime = 2.;
|
||||
InitialValues[i].Lifetime = 2.;
|
||||
|
||||
memcpy(&(initialvalue[i].PositionX), &(particles[i].PositionX), 3 * sizeof(float));
|
||||
generateLifetimeSizeDirection(emitter, initialvalue[i].Lifetime, initialvalue[i].Size,
|
||||
initialvalue[i].DirectionX, initialvalue[i].DirectionY, initialvalue[i].DirectionZ);
|
||||
memcpy(&(particles[i].DirectionX), &(initialvalue[i].DirectionX), 4 * sizeof(float));
|
||||
memcpy(&(InitialValues[i].PositionX), &(ParticleParams[i].PositionX), 3 * sizeof(float));
|
||||
generateLifetimeSizeDirection(emitter, ParticleParams[i].Lifetime, ParticleParams[i].Size,
|
||||
ParticleParams[i].DirectionX, ParticleParams[i].DirectionY, ParticleParams[i].DirectionZ);
|
||||
memcpy(&(InitialValues[i].DirectionX), &(ParticleParams[i].DirectionX), 4 * sizeof(float));
|
||||
}
|
||||
glBindBuffer(GL_ARRAY_BUFFER, initial_values_buffer);
|
||||
glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), initialvalue, GL_STREAM_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, tfb_buffers[0]);
|
||||
glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), particles, GL_STREAM_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, tfb_buffers[1]);
|
||||
glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), 0, GL_STREAM_DRAW);
|
||||
delete[] particles;
|
||||
delete[] initialvalue;
|
||||
}
|
||||
|
||||
static bool isGPUParticleType(scene::E_PARTICLE_EMITTER_TYPE type)
|
||||
@ -261,91 +209,16 @@ static bool isGPUParticleType(scene::E_PARTICLE_EMITTER_TYPE type)
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void setPositionQuadAttributes(GLuint quad_vbo, GLuint position_vbo)
|
||||
{
|
||||
glBindBuffer(GL_ARRAY_BUFFER, quad_vbo);
|
||||
glEnableVertexAttribArray(T::attrib_quadcorner);
|
||||
glVertexAttribPointer(T::attrib_quadcorner, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
|
||||
glEnableVertexAttribArray(T::attrib_texcoord);
|
||||
glVertexAttribPointer(T::attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid *)(2 * sizeof(float)));
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, position_vbo);
|
||||
glEnableVertexAttribArray(T::attrib_pos);
|
||||
glVertexAttribPointer(T::attrib_pos, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleData), 0);
|
||||
glVertexAttribDivisor(T::attrib_pos, 1);
|
||||
glEnableVertexAttribArray(T::attrib_lf);
|
||||
glVertexAttribPointer(T::attrib_lf, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid *)(3 * sizeof(float)));
|
||||
glVertexAttribDivisor(T::attrib_lf, 1);
|
||||
glEnableVertexAttribArray(T::attrib_sz);
|
||||
glVertexAttribPointer(T::attrib_sz, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid *)(7 * sizeof(float)));
|
||||
glVertexAttribDivisor(T::attrib_sz, 1);
|
||||
}
|
||||
|
||||
void ParticleSystemProxy::FlipParticleVAOBind(GLuint PositionBuffer, GLuint QuaternionBuffer)
|
||||
{
|
||||
setPositionQuadAttributes<ParticleShader::FlipParticleRender>(quad_vertex_buffer, PositionBuffer);
|
||||
glEnableVertexAttribArray(ParticleShader::FlipParticleRender::attrib_rotationvec);
|
||||
glEnableVertexAttribArray(ParticleShader::FlipParticleRender::attrib_anglespeed);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, QuaternionBuffer);
|
||||
glVertexAttribPointer(ParticleShader::FlipParticleRender::attrib_rotationvec, 3, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
|
||||
glVertexAttribPointer(ParticleShader::FlipParticleRender::attrib_anglespeed, 1, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid *)(3 * sizeof(float)));
|
||||
|
||||
glVertexAttribDivisor(ParticleShader::FlipParticleRender::attrib_rotationvec, 1);
|
||||
glVertexAttribDivisor(ParticleShader::FlipParticleRender::attrib_anglespeed, 1);
|
||||
}
|
||||
|
||||
void ParticleSystemProxy::SimpleParticleVAOBind(GLuint PositionBuffer)
|
||||
{
|
||||
setPositionQuadAttributes<ParticleShader::SimpleParticleRender>(quad_vertex_buffer, PositionBuffer);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void setSimulationBind(GLuint position_vbo, GLuint initialValues_vbo)
|
||||
{
|
||||
glBindBuffer(GL_ARRAY_BUFFER, position_vbo);
|
||||
glEnableVertexAttribArray(T::attrib_position);
|
||||
glVertexAttribPointer(T::attrib_position, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)0);
|
||||
glEnableVertexAttribArray(T::attrib_lifetime);
|
||||
glVertexAttribPointer(T::attrib_lifetime, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(3 * sizeof(float)));
|
||||
glEnableVertexAttribArray(T::attrib_velocity);
|
||||
glVertexAttribPointer(T::attrib_velocity, 4, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(4 * sizeof(float)));
|
||||
if (T::attrib_size < 30)
|
||||
{
|
||||
glEnableVertexAttribArray(T::attrib_size);
|
||||
glVertexAttribPointer(T::attrib_size, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(7 * sizeof(float)));
|
||||
}
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, initialValues_vbo);
|
||||
glEnableVertexAttribArray(T::attrib_initial_position);
|
||||
glVertexAttribPointer(T::attrib_initial_position, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)0);
|
||||
glEnableVertexAttribArray(T::attrib_initial_lifetime);
|
||||
glVertexAttribPointer(T::attrib_initial_lifetime, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(3 * sizeof(float)));
|
||||
glEnableVertexAttribArray(T::attrib_initial_velocity);
|
||||
glVertexAttribPointer(T::attrib_initial_velocity, 4, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(4 * sizeof(float)));
|
||||
glEnableVertexAttribArray(T::attrib_initial_size);
|
||||
glVertexAttribPointer(T::attrib_initial_size, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(7 * sizeof(float)));
|
||||
}
|
||||
|
||||
void ParticleSystemProxy::SimpleSimulationBind(GLuint PositionBuffer, GLuint InitialValuesBuffer)
|
||||
{
|
||||
setSimulationBind<ParticleShader::SimpleSimulationShader>(PositionBuffer, InitialValuesBuffer);
|
||||
}
|
||||
|
||||
void ParticleSystemProxy::HeightmapSimulationBind(GLuint PositionBuffer, GLuint InitialValuesBuffer)
|
||||
{
|
||||
setSimulationBind<ParticleShader::HeightmapSimulationShader>(PositionBuffer, InitialValuesBuffer);
|
||||
}
|
||||
|
||||
|
||||
void ParticleSystemProxy::setEmitter(scene::IParticleEmitter* emitter)
|
||||
{
|
||||
CParticleSystemSceneNode::setEmitter(emitter);
|
||||
if (!emitter || !isGPUParticleType(emitter->getType()))
|
||||
return;
|
||||
if (!m_first_execution)
|
||||
cleanGL();
|
||||
has_height_map = false;
|
||||
flip = false;
|
||||
m_first_execution = true;
|
||||
|
||||
count = emitter->getMaxParticlesPerSecond() * emitter->getMaxLifeTime() / 1000;
|
||||
switch (emitter->getType())
|
||||
@ -363,96 +236,122 @@ void ParticleSystemProxy::setEmitter(scene::IParticleEmitter* emitter)
|
||||
assert(0 && "Wrong particle type");
|
||||
}
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindVertexArray(0);
|
||||
video::ITexture *tex = getMaterial(0).getTexture(0);
|
||||
compressTexture(tex, true, true);
|
||||
texture = getTextureGLuint(getMaterial(0).getTexture(0));
|
||||
}
|
||||
|
||||
void ParticleSystemProxy::simulateHeightmap()
|
||||
void ParticleSystemProxy::cleanGL()
|
||||
{
|
||||
int timediff = int(GUIEngine::getLatestDt() * 1000.f);
|
||||
int active_count = getEmitter()->getMaxLifeTime() * getEmitter()->getMaxParticlesPerSecond() / 1000;
|
||||
core::matrix4 matrix = getAbsoluteTransformation();
|
||||
glUseProgram(ParticleShader::HeightmapSimulationShader::Program);
|
||||
glEnable(GL_RASTERIZER_DISCARD);
|
||||
|
||||
glUniform1i(ParticleShader::HeightmapSimulationShader::uniform_dt, timediff);
|
||||
glUniform1i(ParticleShader::HeightmapSimulationShader::uniform_level, active_count);
|
||||
glUniformMatrix4fv(ParticleShader::HeightmapSimulationShader::uniform_sourcematrix, 1, GL_FALSE, matrix.pointer());
|
||||
glUniform1f(ParticleShader::HeightmapSimulationShader::uniform_size_increase_factor, size_increase_factor);
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, heightmaptexture);
|
||||
glUniform1i(ParticleShader::HeightmapSimulationShader::uniform_heightmap, 2);
|
||||
glUniform1f(ParticleShader::HeightmapSimulationShader::uniform_track_x, track_x);
|
||||
glUniform1f(ParticleShader::HeightmapSimulationShader::uniform_track_z, track_z);
|
||||
glUniform1f(ParticleShader::HeightmapSimulationShader::uniform_track_x_len, track_x_len);
|
||||
glUniform1f(ParticleShader::HeightmapSimulationShader::uniform_track_z_len, track_z_len);
|
||||
|
||||
glBindVertexArray(current_simulation_vao);
|
||||
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, tfb_buffers[1]);
|
||||
|
||||
glBeginTransformFeedback(GL_POINTS);
|
||||
glDrawArrays(GL_POINTS, 0, count);
|
||||
glEndTransformFeedback();
|
||||
glBindVertexArray(0);
|
||||
|
||||
glDisable(GL_RASTERIZER_DISCARD);
|
||||
std::swap(tfb_buffers[0], tfb_buffers[1]);
|
||||
std::swap(current_rendering_vao, non_current_rendering_vao);
|
||||
std::swap(current_simulation_vao, non_current_simulation_vao);
|
||||
if (flip)
|
||||
glDeleteBuffers(1, &quaternionsbuffer);
|
||||
glDeleteBuffers(2, tfb_buffers);
|
||||
glDeleteBuffers(1, &initial_values_buffer);
|
||||
glDeleteVertexArrays(1, ¤t_rendering_vao);
|
||||
glDeleteVertexArrays(1, &non_current_rendering_vao);
|
||||
glDeleteVertexArrays(1, ¤t_simulation_vao);
|
||||
glDeleteVertexArrays(1, &non_current_simulation_vao);
|
||||
}
|
||||
|
||||
void ParticleSystemProxy::simulateNoHeightmap()
|
||||
void ParticleSystemProxy::CommonRenderingVAO(GLuint PositionBuffer)
|
||||
{
|
||||
int timediff = int(GUIEngine::getLatestDt() * 1000.f);
|
||||
int active_count = getEmitter()->getMaxLifeTime() * getEmitter()->getMaxParticlesPerSecond() / 1000;
|
||||
core::matrix4 matrix = getAbsoluteTransformation();
|
||||
glUseProgram(ParticleShader::SimpleSimulationShader::Program);
|
||||
glEnable(GL_RASTERIZER_DISCARD);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, SharedObject::ParticleQuadVBO);
|
||||
glEnableVertexAttribArray(4);
|
||||
glVertexAttribPointer(4, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
|
||||
glEnableVertexAttribArray(3);
|
||||
glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid *)(2 * sizeof(float)));
|
||||
|
||||
glUniform1i(ParticleShader::SimpleSimulationShader::uniform_dt, timediff);
|
||||
glUniform1i(ParticleShader::SimpleSimulationShader::uniform_level, active_count);
|
||||
glUniformMatrix4fv(ParticleShader::SimpleSimulationShader::uniform_sourcematrix, 1, GL_FALSE, matrix.pointer());
|
||||
glUniform1f(ParticleShader::SimpleSimulationShader::uniform_size_increase_factor, size_increase_factor);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, PositionBuffer);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleData), 0);
|
||||
glVertexAttribDivisor(0, 1);
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid *)(3 * sizeof(float)));
|
||||
glVertexAttribDivisor(1, 1);
|
||||
glEnableVertexAttribArray(2);
|
||||
glVertexAttribPointer(2, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid *)(7 * sizeof(float)));
|
||||
glVertexAttribDivisor(2, 1);
|
||||
}
|
||||
|
||||
glBindVertexArray(current_simulation_vao);
|
||||
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, tfb_buffers[1]);
|
||||
void ParticleSystemProxy::AppendQuaternionRenderingVAO(GLuint QuaternionBuffer)
|
||||
{
|
||||
glBindBuffer(GL_ARRAY_BUFFER, QuaternionBuffer);
|
||||
glEnableVertexAttribArray(5);
|
||||
|
||||
glBeginTransformFeedback(GL_POINTS);
|
||||
glDrawArrays(GL_POINTS, 0, count);
|
||||
glEndTransformFeedback();
|
||||
glBindVertexArray(0);
|
||||
glVertexAttribPointer(5, 3, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
|
||||
glVertexAttribDivisor(5, 1);
|
||||
|
||||
glDisable(GL_RASTERIZER_DISCARD);
|
||||
std::swap(tfb_buffers[0], tfb_buffers[1]);
|
||||
std::swap(current_rendering_vao, non_current_rendering_vao);
|
||||
std::swap(current_simulation_vao, non_current_simulation_vao);
|
||||
glEnableVertexAttribArray(6);
|
||||
glVertexAttribPointer(6, 1, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid *)(3 * sizeof(float)));
|
||||
glVertexAttribDivisor(6, 1);
|
||||
}
|
||||
|
||||
void ParticleSystemProxy::CommonSimulationVAO(GLuint position_vbo, GLuint initialValues_vbo)
|
||||
{
|
||||
glBindBuffer(GL_ARRAY_BUFFER, position_vbo);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleSystemProxy::ParticleData), (GLvoid*)0);
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleSystemProxy::ParticleData), (GLvoid*)(3 * sizeof(float)));
|
||||
glEnableVertexAttribArray(2);
|
||||
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(ParticleSystemProxy::ParticleData), (GLvoid*)(4 * sizeof(float)));
|
||||
glEnableVertexAttribArray(3);
|
||||
glVertexAttribPointer(3, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleSystemProxy::ParticleData), (GLvoid*)(7 * sizeof(float)));
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, initialValues_vbo);
|
||||
glEnableVertexAttribArray(4);
|
||||
glVertexAttribPointer(4, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleSystemProxy::ParticleData), (GLvoid*)0);
|
||||
glEnableVertexAttribArray(5);
|
||||
glVertexAttribPointer(5, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleSystemProxy::ParticleData), (GLvoid*)(3 * sizeof(float)));
|
||||
glEnableVertexAttribArray(6);
|
||||
glVertexAttribPointer(6, 4, GL_FLOAT, GL_FALSE, sizeof(ParticleSystemProxy::ParticleData), (GLvoid*)(4 * sizeof(float)));
|
||||
glEnableVertexAttribArray(7);
|
||||
glVertexAttribPointer(7, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleSystemProxy::ParticleData), (GLvoid*)(7 * sizeof(float)));
|
||||
}
|
||||
|
||||
void ParticleSystemProxy::simulate()
|
||||
{
|
||||
int timediff = int(GUIEngine::getLatestDt() * 1000.f);
|
||||
int active_count = getEmitter()->getMaxLifeTime() * getEmitter()->getMaxParticlesPerSecond() / 1000;
|
||||
core::matrix4 matrix = getAbsoluteTransformation();
|
||||
|
||||
glEnable(GL_RASTERIZER_DISCARD);
|
||||
if (has_height_map)
|
||||
simulateHeightmap();
|
||||
{
|
||||
glUseProgram(ParticleShader::HeightmapSimulationShader::getInstance()->Program);
|
||||
glActiveTexture(GL_TEXTURE0 + ParticleShader::HeightmapSimulationShader::getInstance()->TU_heightmap);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, heightmaptexture);
|
||||
ParticleShader::HeightmapSimulationShader::getInstance()->setUniforms(matrix, timediff, active_count, size_increase_factor, track_x, track_x_len, track_z, track_z_len);
|
||||
}
|
||||
else
|
||||
simulateNoHeightmap();
|
||||
{
|
||||
glUseProgram(ParticleShader::SimpleSimulationShader::getInstance()->Program);
|
||||
ParticleShader::SimpleSimulationShader::getInstance()->setUniforms(matrix, timediff, active_count, size_increase_factor);
|
||||
}
|
||||
|
||||
glBindVertexArray(current_simulation_vao);
|
||||
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, tfb_buffers[1]);
|
||||
|
||||
glBeginTransformFeedback(GL_POINTS);
|
||||
glDrawArrays(GL_POINTS, 0, count);
|
||||
glEndTransformFeedback();
|
||||
glBindVertexArray(0);
|
||||
|
||||
glDisable(GL_RASTERIZER_DISCARD);
|
||||
std::swap(tfb_buffers[0], tfb_buffers[1]);
|
||||
std::swap(current_rendering_vao, non_current_rendering_vao);
|
||||
std::swap(current_simulation_vao, non_current_simulation_vao);
|
||||
}
|
||||
|
||||
void ParticleSystemProxy::drawFlip()
|
||||
{
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glUseProgram(ParticleShader::FlipParticleRender::Program);
|
||||
glUseProgram(ParticleShader::FlipParticleRender::getInstance()->Program);
|
||||
|
||||
float screen[2] = {
|
||||
(float)UserConfigParams::m_width,
|
||||
(float)UserConfigParams::m_height
|
||||
};
|
||||
setTexture(ParticleShader::FlipParticleRender::getInstance()->TU_tex, texture, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR);
|
||||
setTexture(ParticleShader::FlipParticleRender::getInstance()->TU_dtex, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
|
||||
setTexture(0, texture, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR);
|
||||
setTexture(1, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
|
||||
ParticleShader::FlipParticleRender::setUniforms(irr_driver->getViewMatrix(), irr_driver->getProjMatrix(), irr_driver->getInvProjMatrix(), screen[0], screen[1], 0, 1);
|
||||
ParticleShader::FlipParticleRender::getInstance()->setUniforms();
|
||||
|
||||
glBindVertexArray(current_rendering_vao);
|
||||
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, count);
|
||||
@ -464,18 +363,14 @@ void ParticleSystemProxy::drawNotFlip()
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
else
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glUseProgram(ParticleShader::SimpleParticleRender::Program);
|
||||
glUseProgram(ParticleShader::SimpleParticleRender::getInstance()->Program);
|
||||
|
||||
float screen[2] = {
|
||||
(float)UserConfigParams::m_width,
|
||||
(float)UserConfigParams::m_height
|
||||
};
|
||||
setTexture(ParticleShader::SimpleParticleRender::getInstance()->TU_tex, texture, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR);
|
||||
setTexture(ParticleShader::SimpleParticleRender::getInstance()->TU_dtex, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
video::SColorf ColorFrom = video::SColorf(getColorFrom()[0], getColorFrom()[1], getColorFrom()[2]);
|
||||
video::SColorf ColorTo = video::SColorf(getColorTo()[0], getColorTo()[1], getColorTo()[2]);
|
||||
|
||||
setTexture(0, texture, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR);
|
||||
setTexture(1, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
|
||||
ParticleShader::SimpleParticleRender::setUniforms(irr_driver->getViewMatrix(), irr_driver->getProjMatrix(),
|
||||
irr_driver->getInvProjMatrix(), screen[0], screen[1], 0, 1, this);
|
||||
ParticleShader::SimpleParticleRender::getInstance()->setUniforms(ColorFrom, ColorTo);
|
||||
|
||||
glBindVertexArray(current_rendering_vao);
|
||||
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, count);
|
||||
@ -491,26 +386,32 @@ void ParticleSystemProxy::draw()
|
||||
|
||||
void ParticleSystemProxy::generateVAOs()
|
||||
{
|
||||
glBindVertexArray(0);
|
||||
glGenBuffers(1, &initial_values_buffer);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, initial_values_buffer);
|
||||
glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), ParticleParams, GL_STREAM_DRAW);
|
||||
glGenBuffers(2, tfb_buffers);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, tfb_buffers[0]);
|
||||
glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), InitialValues, GL_STREAM_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, tfb_buffers[1]);
|
||||
glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), 0, GL_STREAM_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
glGenVertexArrays(1, ¤t_rendering_vao);
|
||||
glGenVertexArrays(1, &non_current_rendering_vao);
|
||||
glGenVertexArrays(1, ¤t_simulation_vao);
|
||||
glGenVertexArrays(1, &non_current_simulation_vao);
|
||||
|
||||
glBindVertexArray(current_simulation_vao);
|
||||
if (has_height_map)
|
||||
HeightmapSimulationBind(tfb_buffers[0], initial_values_buffer);
|
||||
else
|
||||
SimpleSimulationBind(tfb_buffers[0], initial_values_buffer);
|
||||
CommonSimulationVAO(tfb_buffers[0], initial_values_buffer);
|
||||
glBindVertexArray(non_current_simulation_vao);
|
||||
if (has_height_map)
|
||||
HeightmapSimulationBind(tfb_buffers[1], initial_values_buffer);
|
||||
else
|
||||
SimpleSimulationBind(tfb_buffers[1], initial_values_buffer);
|
||||
CommonSimulationVAO(tfb_buffers[1], initial_values_buffer);
|
||||
|
||||
|
||||
float *quaternions = new float[4 * count];
|
||||
glBindVertexArray(0);
|
||||
if (flip)
|
||||
{
|
||||
float *quaternions = new float[4 * count];
|
||||
for (unsigned i = 0; i < count; i++)
|
||||
{
|
||||
core::vector3df rotationdir(0., 1., 0.);
|
||||
@ -523,22 +424,19 @@ void ParticleSystemProxy::generateVAOs()
|
||||
glGenBuffers(1, &quaternionsbuffer);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, quaternionsbuffer);
|
||||
glBufferData(GL_ARRAY_BUFFER, 4 * count * sizeof(float), quaternions, GL_STATIC_DRAW);
|
||||
delete[] quaternions;
|
||||
}
|
||||
|
||||
glBindVertexArray(current_rendering_vao);
|
||||
CommonRenderingVAO(tfb_buffers[0]);
|
||||
if (flip)
|
||||
FlipParticleVAOBind(tfb_buffers[0], quaternionsbuffer);
|
||||
else
|
||||
SimpleParticleVAOBind(tfb_buffers[0]);
|
||||
AppendQuaternionRenderingVAO(quaternionsbuffer);
|
||||
|
||||
glBindVertexArray(non_current_rendering_vao);
|
||||
CommonRenderingVAO(tfb_buffers[1]);
|
||||
if (flip)
|
||||
FlipParticleVAOBind(tfb_buffers[1], quaternionsbuffer);
|
||||
else
|
||||
SimpleParticleVAOBind(tfb_buffers[1]);
|
||||
AppendQuaternionRenderingVAO(quaternionsbuffer);
|
||||
glBindVertexArray(0);
|
||||
|
||||
delete[] quaternions;
|
||||
}
|
||||
|
||||
void ParticleSystemProxy::render() {
|
||||
@ -547,8 +445,9 @@ void ParticleSystemProxy::render() {
|
||||
CParticleSystemSceneNode::render();
|
||||
return;
|
||||
}
|
||||
if (!current_rendering_vao || !non_current_rendering_vao || !current_simulation_vao || !non_current_simulation_vao)
|
||||
if (m_first_execution)
|
||||
generateVAOs();
|
||||
m_first_execution = false;
|
||||
simulate();
|
||||
draw();
|
||||
}
|
||||
|
@ -19,24 +19,38 @@ protected:
|
||||
float size_increase_factor, track_x, track_z, track_x_len, track_z_len;
|
||||
float m_color_from[3];
|
||||
float m_color_to[3];
|
||||
|
||||
static GLuint quad_vertex_buffer;
|
||||
bool m_first_execution;
|
||||
|
||||
GLuint texture;
|
||||
unsigned count;
|
||||
static void SimpleParticleVAOBind(GLuint PositionBuffer);
|
||||
static void FlipParticleVAOBind(GLuint PositionBuffer, GLuint QuaternionBuffer);
|
||||
static void SimpleSimulationBind(GLuint PositionBuffer, GLuint InitialValuesBuffer);
|
||||
static void HeightmapSimulationBind(GLuint PositionBuffer, GLuint InitialValuesBuffer);
|
||||
static void CommonRenderingVAO(GLuint PositionBuffer);
|
||||
static void AppendQuaternionRenderingVAO(GLuint QuaternionBuffer);
|
||||
static void CommonSimulationVAO(GLuint position_vbo, GLuint initialValues_vbo);
|
||||
|
||||
void generateVAOs();
|
||||
void cleanGL();
|
||||
|
||||
void simulateHeightmap();
|
||||
void simulateNoHeightmap();
|
||||
void drawFlip();
|
||||
void drawNotFlip();
|
||||
virtual void simulate();
|
||||
virtual void draw();
|
||||
|
||||
public:
|
||||
struct ParticleData
|
||||
{
|
||||
float PositionX;
|
||||
float PositionY;
|
||||
float PositionZ;
|
||||
float Lifetime;
|
||||
float DirectionX;
|
||||
float DirectionY;
|
||||
float DirectionZ;
|
||||
float Size;
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
ParticleData *ParticleParams, *InitialValues;
|
||||
void generateParticlesFromPointEmitter(scene::IParticlePointEmitter *);
|
||||
void generateParticlesFromBoxEmitter(scene::IParticleBoxEmitter *);
|
||||
void generateParticlesFromSphereEmitter(scene::IParticleSphereEmitter *);
|
||||
|
@ -367,6 +367,7 @@ private:
|
||||
void renderParticles();
|
||||
void computeSunVisibility();
|
||||
void renderShadows();
|
||||
void renderRSM();
|
||||
void renderGlow(std::vector<GlowData>& glows);
|
||||
void renderSSAO();
|
||||
void renderLights(unsigned pointlightCount);
|
||||
|
@ -281,7 +281,11 @@ void IrrDriver::renderScene(scene::ICameraSceneNode * const camnode, unsigned po
|
||||
m_scene_manager->setActiveCamera(m_suncam);
|
||||
if (!m_mipviz && !m_wireframe && UserConfigParams::m_dynamic_lights &&
|
||||
UserConfigParams::m_shadows && !irr_driver->needUBOWorkaround() && hasShadow)
|
||||
{
|
||||
renderShadows();
|
||||
if (UserConfigParams::m_gi)
|
||||
renderRSM();
|
||||
}
|
||||
m_scene_manager->setActiveCamera(camnode);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
}
|
||||
|
@ -172,13 +172,17 @@ struct instanced_custom_unroll_args<N, List...>
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Shader, int ...List, typename... TupleType>
|
||||
template<typename Shader, enum E_VERTEX_TYPE VertexType, int ...List, typename... TupleType>
|
||||
void renderInstancedMeshes1stPass(const std::vector<TexUnit> &TexUnits, std::vector<STK::Tuple<TupleType...> > *meshes)
|
||||
{
|
||||
glUseProgram(Shader::getInstance()->Program);
|
||||
for (unsigned i = 0; i < meshes->size(); i++)
|
||||
{
|
||||
GLMesh &mesh = *(STK::tuple_get<0>(meshes->at(i)));
|
||||
#ifdef DEBUG
|
||||
if (mesh.VAOType != VertexType)
|
||||
Log::error("RenderGeometry", "Wrong instanced vertex format");
|
||||
#endif
|
||||
glBindVertexArray(mesh.vao);
|
||||
for (unsigned j = 0; j < TexUnits.size(); j++)
|
||||
{
|
||||
@ -215,6 +219,7 @@ void IrrDriver::renderSolidFirstPass()
|
||||
ListInstancedMatDefault::getInstance()->clear();
|
||||
ListInstancedMatAlphaRef::getInstance()->clear();
|
||||
ListInstancedMatGrass::getInstance()->clear();
|
||||
ListInstancedMatNormalMap::getInstance()->clear();
|
||||
m_scene_manager->drawAll(scene::ESNRP_SOLID);
|
||||
|
||||
if (!UserConfigParams::m_dynamic_lights)
|
||||
@ -236,15 +241,18 @@ void IrrDriver::renderSolidFirstPass()
|
||||
TexUnit(MeshShader::NormalMapShader::getInstance()->TU_normalmap, false)
|
||||
), ListMatNormalMap::getInstance());
|
||||
|
||||
renderInstancedMeshes1stPass<MeshShader::InstancedObjectPass1Shader>(
|
||||
renderInstancedMeshes1stPass<MeshShader::InstancedObjectPass1Shader, video::EVT_STANDARD>(
|
||||
TexUnits(TexUnit(MeshShader::InstancedObjectPass1Shader::getInstance()->TU_tex, true)),
|
||||
ListInstancedMatDefault::getInstance());
|
||||
renderInstancedMeshes1stPass<MeshShader::InstancedObjectRefPass1Shader>(
|
||||
renderInstancedMeshes1stPass<MeshShader::InstancedObjectRefPass1Shader, video::EVT_STANDARD>(
|
||||
TexUnits(TexUnit(MeshShader::InstancedObjectRefPass1Shader::getInstance()->TU_tex, true)),
|
||||
ListInstancedMatAlphaRef::getInstance());
|
||||
renderInstancedMeshes1stPass<MeshShader::InstancedGrassPass1Shader, 2>(
|
||||
renderInstancedMeshes1stPass<MeshShader::InstancedGrassPass1Shader, video::EVT_STANDARD, 2>(
|
||||
TexUnits(TexUnit(MeshShader::InstancedGrassPass1Shader::getInstance()->TU_tex, true)),
|
||||
ListInstancedMatGrass::getInstance());
|
||||
renderInstancedMeshes1stPass<MeshShader::InstancedNormalMapShader, video::EVT_TANGENTS>(
|
||||
TexUnits(TexUnit(MeshShader::InstancedNormalMapShader::getInstance()->TU_glossy, true), TexUnit(MeshShader::InstancedNormalMapShader::getInstance()->TU_normalmap, false)),
|
||||
ListInstancedMatNormalMap::getInstance());
|
||||
}
|
||||
}
|
||||
|
||||
@ -388,6 +396,9 @@ void IrrDriver::renderSolidSecondPass()
|
||||
renderInstancedMeshes2ndPass<MeshShader::InstancedObjectPass2Shader>(
|
||||
TexUnits(TexUnit(MeshShader::InstancedObjectPass2Shader::getInstance()->TU_Albedo, true)),
|
||||
ListInstancedMatDefault::getInstance());
|
||||
renderInstancedMeshes2ndPass<MeshShader::InstancedObjectPass2Shader>(
|
||||
TexUnits(TexUnit(MeshShader::InstancedObjectPass2Shader::getInstance()->TU_Albedo, true)),
|
||||
ListInstancedMatNormalMap::getInstance());
|
||||
renderInstancedMeshes2ndPass<MeshShader::InstancedObjectRefPass2Shader>(
|
||||
TexUnits(TexUnit(MeshShader::InstancedObjectRefPass2Shader::getInstance()->TU_Albedo, true)),
|
||||
ListInstancedMatAlphaRef::getInstance());
|
||||
@ -592,7 +603,7 @@ struct shadow_custom_unroll_args<N, List...>
|
||||
};
|
||||
|
||||
template<typename T, enum E_VERTEX_TYPE VertexType, int...List, typename... Args>
|
||||
void renderShadow(const std::vector<GLuint> TextureUnits, const std::vector<STK::Tuple<GLMesh *, core::matrix4, Args...> > *t)
|
||||
void renderShadow(const std::vector<GLuint> TextureUnits, const std::vector<STK::Tuple<Args...> > *t)
|
||||
{
|
||||
glUseProgram(T::getInstance()->Program);
|
||||
glBindVertexArray(getVAO(VertexType));
|
||||
@ -609,94 +620,52 @@ void renderShadow(const std::vector<GLuint> TextureUnits, const std::vector<STK:
|
||||
}
|
||||
}
|
||||
|
||||
static void drawShadowDefault(GLMesh &mesh, size_t instance_count)
|
||||
{
|
||||
irr_driver->IncreaseObjectCount();
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
|
||||
MeshShader::InstancedShadowShader::getInstance()->setUniforms();
|
||||
|
||||
glBindVertexArray(mesh.vao_shadow_pass);
|
||||
glDrawElementsInstanced(ptype, count, itype, 0, 4 * instance_count);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void drawShadowAlphaRefTexture(GLMesh &mesh, size_t instance_count)
|
||||
{
|
||||
irr_driver->IncreaseObjectCount();
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
|
||||
compressTexture(mesh.textures[0], true);
|
||||
setTexture(MeshShader::InstancedRefShadowShader::getInstance()->TU_tex, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
MeshShader::InstancedRefShadowShader::getInstance()->setUniforms();
|
||||
|
||||
glBindVertexArray(mesh.vao_shadow_pass);
|
||||
glDrawElementsInstanced(ptype, count, itype, 0, 4 * instance_count);
|
||||
}
|
||||
|
||||
static void drawShadowGrass(GLMesh &mesh, const core::vector3df &windDir, size_t instance_count)
|
||||
{
|
||||
irr_driver->IncreaseObjectCount();
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
|
||||
compressTexture(mesh.textures[0], true);
|
||||
setTexture(MeshShader::InstancedGrassShadowShader::getInstance()->TU_tex, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
MeshShader::InstancedGrassShadowShader::getInstance()->setUniforms(windDir);
|
||||
|
||||
glBindVertexArray(mesh.vao_shadow_pass);
|
||||
glDrawElementsInstanced(ptype, count, itype, 0, 4 * instance_count);
|
||||
}
|
||||
|
||||
|
||||
template<int...List>
|
||||
struct rsm_custom_unroll_args;
|
||||
struct instanced_shadow_custom_unroll_args;
|
||||
|
||||
template<>
|
||||
struct rsm_custom_unroll_args<>
|
||||
struct instanced_shadow_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)
|
||||
static void exec(const T *Shader, const STK::Tuple<TupleTypes...> &t, Args... args)
|
||||
{
|
||||
draw<T>(T::getInstance(), STK::tuple_get<0>(t), rsm_matrix, args...);
|
||||
const GLMesh *mesh = STK::tuple_get<0>(t);
|
||||
size_t instance_count = STK::tuple_get<1>(t);
|
||||
irr_driver->IncreaseObjectCount();
|
||||
GLenum ptype = mesh->PrimitiveType;
|
||||
GLenum itype = mesh->IndexType;
|
||||
size_t count = mesh->IndexCount;
|
||||
|
||||
Shader->setUniforms(args...);
|
||||
glDrawElementsInstanced(ptype, count, itype, 0, 4 * instance_count);
|
||||
}
|
||||
};
|
||||
|
||||
template<int N, int...List>
|
||||
struct rsm_custom_unroll_args<N, List...>
|
||||
struct instanced_shadow_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)
|
||||
static void exec(const T *Shader, const STK::Tuple<TupleTypes...> &t, Args... args)
|
||||
{
|
||||
rsm_custom_unroll_args<List...>::template exec<T>(rsm_matrix, t, STK::tuple_get<N>(t), args...);
|
||||
instanced_shadow_custom_unroll_args<List...>::template exec<T>(Shader, 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)
|
||||
template<typename T, int...List, typename... Args>
|
||||
void renderInstancedShadow(const std::vector<GLuint> TextureUnits, const std::vector<STK::Tuple<Args...> > *t)
|
||||
{
|
||||
glUseProgram(T::getInstance()->Program);
|
||||
glBindVertexArray(getVAO(VertexType));
|
||||
for (unsigned i = 0; i < t->size(); i++)
|
||||
{
|
||||
GLMesh *mesh = STK::tuple_get<0>(t->at(i));
|
||||
const GLMesh *mesh = STK::tuple_get<0>(t->at(i));
|
||||
glBindVertexArray(mesh->vao_shadow_pass);
|
||||
for (unsigned j = 0; j < TextureUnits.size(); j++)
|
||||
{
|
||||
if (!mesh->textures[j])
|
||||
mesh->textures[j] = getUnicolorTexture(video::SColor(255, 255, 255, 255));
|
||||
compressTexture(mesh->textures[j], true);
|
||||
setTexture(TextureUnits[j], getTextureGLuint(mesh->textures[j]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
}
|
||||
rsm_custom_unroll_args<Selector...>::template exec<T>(rsm_matrix, t->at(i));
|
||||
|
||||
instanced_shadow_custom_unroll_args<List...>::template exec<T>(T::getInstance(), t->at(i));
|
||||
}
|
||||
}
|
||||
|
||||
@ -722,6 +691,10 @@ void IrrDriver::renderShadows()
|
||||
ListMatNormalMap::getInstance()->clear();
|
||||
ListMatGrass::getInstance()->clear();
|
||||
ListMatSplatting::getInstance()->clear();
|
||||
ListInstancedMatDefault::getInstance()->clear();
|
||||
ListInstancedMatAlphaRef::getInstance()->clear();
|
||||
ListInstancedMatGrass::getInstance()->clear();
|
||||
ListInstancedMatNormalMap::getInstance()->clear();
|
||||
m_scene_manager->drawAll(scene::ESNRP_SOLID);
|
||||
|
||||
std::vector<GLuint> noTexUnits;
|
||||
@ -734,17 +707,66 @@ void IrrDriver::renderShadows()
|
||||
renderShadow<MeshShader::RefShadowShader, EVT_STANDARD, 1>(std::vector<GLuint>{ MeshShader::RefShadowShader::getInstance()->TU_tex }, ListMatUnlit::getInstance());
|
||||
renderShadow<MeshShader::GrassShadowShader, EVT_STANDARD, 3, 1>(std::vector<GLuint>{ MeshShader::GrassShadowShader::getInstance()->TU_tex }, ListMatGrass::getInstance());
|
||||
|
||||
renderInstancedShadow<MeshShader::InstancedShadowShader>(noTexUnits, ListInstancedMatDefault::getInstance());
|
||||
renderInstancedShadow<MeshShader::InstancedRefShadowShader>(std::vector<GLuint>{ MeshShader::InstancedRefShadowShader::getInstance()->TU_tex }, ListInstancedMatAlphaRef::getInstance());
|
||||
renderInstancedShadow<MeshShader::InstancedGrassShadowShader, 2>(std::vector<GLuint>{ MeshShader::InstancedGrassShadowShader::getInstance()->TU_tex }, ListInstancedMatGrass::getInstance());
|
||||
renderInstancedShadow<MeshShader::InstancedShadowShader>(noTexUnits, ListInstancedMatNormalMap::getInstance());
|
||||
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
}
|
||||
|
||||
if (!UserConfigParams::m_gi)
|
||||
return;
|
||||
|
||||
|
||||
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, std::vector<STK::Tuple<Args...> > *t)
|
||||
{
|
||||
glUseProgram(T::getInstance()->Program);
|
||||
glBindVertexArray(getVAO(VertexType));
|
||||
for (unsigned i = 0; i < t->size(); i++)
|
||||
{
|
||||
GLMesh *mesh = STK::tuple_get<0>(t->at(i));
|
||||
for (unsigned j = 0; j < TextureUnits.size(); j++)
|
||||
{
|
||||
if (!mesh->textures[j])
|
||||
mesh->textures[j] = getUnicolorTexture(video::SColor(255, 255, 255, 255));
|
||||
compressTexture(mesh->textures[j], true);
|
||||
setTexture(TextureUnits[j], getTextureGLuint(mesh->textures[j]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
}
|
||||
rsm_custom_unroll_args<Selector...>::template exec<T>(rsm_matrix, t->at(i));
|
||||
}
|
||||
}
|
||||
|
||||
void IrrDriver::renderRSM()
|
||||
{
|
||||
m_rtts->getRSM().Bind();
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
drawRSM<MeshShader::RSMShader, EVT_STANDARD, 3, 1>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::getInstance()->TU_tex }, ListMatDefault::getInstance());
|
||||
drawRSM<MeshShader::RSMShader, EVT_STANDARD, 3, 1>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::getInstance()->TU_tex }, ListMatAlphaRef::getInstance());
|
||||
// drawRSM<EVT_STANDARD, 2, 1>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::getInstance()->TU_tex }, ListMatSphereMap::getInstance());
|
||||
drawRSM<MeshShader::RSMShader, EVT_TANGENTS, 3, 1>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::getInstance()->TU_tex }, ListMatNormalMap::getInstance());
|
||||
drawRSM<MeshShader::RSMShader, EVT_STANDARD, 3, 1>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::getInstance()->TU_tex }, ListMatUnlit::getInstance());
|
||||
drawRSM<MeshShader::RSMShader, EVT_2TCOORDS, 3, 1>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::getInstance()->TU_tex }, ListMatDetails::getInstance());
|
||||
drawRSM<MeshShader::SplattingRSMShader, EVT_2TCOORDS, 1>(rsm_matrix,
|
||||
|
@ -161,9 +161,10 @@ void IrrDriver::renderLights(unsigned pointlightcount)
|
||||
m_post_processing->renderGI(rh_matrix, rh_extend, m_rtts->getRH().getRTT()[0], m_rtts->getRH().getRTT()[1], m_rtts->getRH().getRTT()[2]);
|
||||
}
|
||||
|
||||
|
||||
ScopedGPUTimer timer(irr_driver->getGPUTimer(Q_ENVMAP));
|
||||
m_post_processing->renderDiffuseEnvMap(blueSHCoeff, greenSHCoeff, redSHCoeff);
|
||||
{
|
||||
ScopedGPUTimer timer(irr_driver->getGPUTimer(Q_ENVMAP));
|
||||
m_post_processing->renderDiffuseEnvMap(blueSHCoeff, greenSHCoeff, redSHCoeff);
|
||||
}
|
||||
|
||||
m_rtts->getFBO(FBO_COMBINED_TMP1_TMP2).Bind();
|
||||
|
||||
|
@ -133,6 +133,7 @@ Shaders::Shaders()
|
||||
GLuint quad_vbo, tri_vbo;
|
||||
|
||||
GLuint SharedObject::FullScreenQuadVAO = 0;
|
||||
GLuint SharedObject::UIVAO = 0;
|
||||
|
||||
static void initQuadVBO()
|
||||
{
|
||||
@ -179,6 +180,15 @@ static void initQuadBuffer()
|
||||
glGenBuffers(1, &quad_buffer);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, quad_buffer);
|
||||
glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(float), quad_vertex, GL_STATIC_DRAW);
|
||||
|
||||
glGenVertexArrays(1, &SharedObject::UIVAO);
|
||||
glBindVertexArray(SharedObject::UIVAO);
|
||||
glEnableVertexAttribArray(0);
|
||||
glEnableVertexAttribArray(3);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, quad_buffer);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
|
||||
glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid *)(2 * sizeof(float)));
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
GLuint SharedObject::billboardvbo = 0;
|
||||
@ -288,6 +298,22 @@ static void initShadowVPMUBO()
|
||||
glBindBuffer(GL_UNIFORM_BUFFER, 0);
|
||||
}
|
||||
|
||||
GLuint SharedObject::ParticleQuadVBO = 0;
|
||||
|
||||
static void initParticleQuadVBO()
|
||||
{
|
||||
static const GLfloat quad_vertex[] = {
|
||||
-.5, -.5, 0., 0.,
|
||||
.5, -.5, 1., 0.,
|
||||
-.5, .5, 0., 1.,
|
||||
.5, .5, 1., 1.,
|
||||
};
|
||||
glGenBuffers(1, &SharedObject::ParticleQuadVBO);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, SharedObject::ParticleQuadVBO);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(quad_vertex), quad_vertex, GL_STATIC_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
void Shaders::loadShaders()
|
||||
{
|
||||
const std::string &dir = file_manager->getAsset(FileManager::SHADER, "");
|
||||
@ -382,19 +408,12 @@ void Shaders::loadShaders()
|
||||
initCubeVBO();
|
||||
initFrustrumVBO();
|
||||
initShadowVPMUBO();
|
||||
initParticleQuadVBO();
|
||||
FullScreenShader::DiffuseEnvMapShader::init();
|
||||
MeshShader::BubbleShader::init();
|
||||
LightShader::PointLightShader::init();
|
||||
MeshShader::SkyboxShader::init();
|
||||
MeshShader::ViewFrustrumShader::init();
|
||||
ParticleShader::FlipParticleRender::init();
|
||||
ParticleShader::HeightmapSimulationShader::init();
|
||||
ParticleShader::SimpleParticleRender::init();
|
||||
ParticleShader::SimpleSimulationShader::init();
|
||||
UIShader::ColoredRectShader::init();
|
||||
UIShader::ColoredTextureRectShader::init();
|
||||
UIShader::TextureRectShader::init();
|
||||
UIShader::UniformColoredTextureRectShader::init();
|
||||
UtilShader::ColoredLine::init();
|
||||
}
|
||||
|
||||
@ -628,7 +647,7 @@ namespace MeshShader
|
||||
NormalMapShader::NormalMapShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/normalmap.vert").c_str(),
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/normalmap.frag").c_str());
|
||||
AssignUniforms("ModelMatrix", "InverseModelMatrix");
|
||||
@ -649,6 +668,7 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass1.frag").c_str());
|
||||
TU_tex = 0;
|
||||
AssignUniforms();
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
@ -663,6 +683,7 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass1.frag").c_str());
|
||||
TU_tex = 0;
|
||||
AssignUniforms();
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
@ -684,6 +705,23 @@ namespace MeshShader
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
InstancedNormalMapShader::InstancedNormalMapShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/utils/getworldmatrix.vert").c_str(),
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/instanced_object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/normalmap.frag").c_str());
|
||||
AssignUniforms();
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
|
||||
TU_normalmap = 1;
|
||||
TU_glossy = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_normalmap, "normalMap"), TexUnit(TU_glossy, "DiffuseForAlpha"));
|
||||
}
|
||||
|
||||
// Solid Lit pass shaders
|
||||
ObjectPass2Shader::ObjectPass2Shader()
|
||||
{
|
||||
@ -1337,21 +1375,7 @@ namespace LightShader
|
||||
|
||||
namespace ParticleShader
|
||||
{
|
||||
GLuint SimpleSimulationShader::Program;
|
||||
GLuint SimpleSimulationShader::attrib_position;
|
||||
GLuint SimpleSimulationShader::attrib_velocity;
|
||||
GLuint SimpleSimulationShader::attrib_lifetime;
|
||||
GLuint SimpleSimulationShader::attrib_initial_position;
|
||||
GLuint SimpleSimulationShader::attrib_initial_velocity;
|
||||
GLuint SimpleSimulationShader::attrib_initial_lifetime;
|
||||
GLuint SimpleSimulationShader::attrib_size;
|
||||
GLuint SimpleSimulationShader::attrib_initial_size;
|
||||
GLuint SimpleSimulationShader::uniform_sourcematrix;
|
||||
GLuint SimpleSimulationShader::uniform_dt;
|
||||
GLuint SimpleSimulationShader::uniform_level;
|
||||
GLuint SimpleSimulationShader::uniform_size_increase_factor;
|
||||
|
||||
void SimpleSimulationShader::init()
|
||||
SimpleSimulationShader::SimpleSimulationShader()
|
||||
{
|
||||
const char *varyings[] = {
|
||||
"new_particle_position",
|
||||
@ -1360,42 +1384,10 @@ namespace ParticleShader
|
||||
"new_size",
|
||||
};
|
||||
Program = LoadTFBProgram(file_manager->getAsset("shaders/pointemitter.vert").c_str(), varyings, 4);
|
||||
|
||||
uniform_dt = glGetUniformLocation(Program, "dt");
|
||||
uniform_sourcematrix = glGetUniformLocation(Program, "sourcematrix");
|
||||
uniform_level = glGetUniformLocation(Program, "level");
|
||||
uniform_size_increase_factor = glGetUniformLocation(Program, "size_increase_factor");
|
||||
|
||||
attrib_position = glGetAttribLocation(Program, "particle_position");
|
||||
attrib_lifetime = glGetAttribLocation(Program, "lifetime");
|
||||
attrib_velocity = glGetAttribLocation(Program, "particle_velocity");
|
||||
attrib_size = glGetAttribLocation(Program, "size");
|
||||
attrib_initial_position = glGetAttribLocation(Program, "particle_position_initial");
|
||||
attrib_initial_lifetime = glGetAttribLocation(Program, "lifetime_initial");
|
||||
attrib_initial_velocity = glGetAttribLocation(Program, "particle_velocity_initial");
|
||||
attrib_initial_size = glGetAttribLocation(Program, "size_initial");
|
||||
AssignUniforms("sourcematrix", "dt", "level", "size_increase_factor");
|
||||
}
|
||||
|
||||
GLuint HeightmapSimulationShader::Program;
|
||||
GLuint HeightmapSimulationShader::attrib_position;
|
||||
GLuint HeightmapSimulationShader::attrib_velocity;
|
||||
GLuint HeightmapSimulationShader::attrib_lifetime;
|
||||
GLuint HeightmapSimulationShader::attrib_initial_position;
|
||||
GLuint HeightmapSimulationShader::attrib_initial_velocity;
|
||||
GLuint HeightmapSimulationShader::attrib_initial_lifetime;
|
||||
GLuint HeightmapSimulationShader::attrib_size;
|
||||
GLuint HeightmapSimulationShader::attrib_initial_size;
|
||||
GLuint HeightmapSimulationShader::uniform_sourcematrix;
|
||||
GLuint HeightmapSimulationShader::uniform_dt;
|
||||
GLuint HeightmapSimulationShader::uniform_level;
|
||||
GLuint HeightmapSimulationShader::uniform_size_increase_factor;
|
||||
GLuint HeightmapSimulationShader::uniform_track_x;
|
||||
GLuint HeightmapSimulationShader::uniform_track_z;
|
||||
GLuint HeightmapSimulationShader::uniform_track_x_len;
|
||||
GLuint HeightmapSimulationShader::uniform_track_z_len;
|
||||
GLuint HeightmapSimulationShader::uniform_heightmap;
|
||||
|
||||
void HeightmapSimulationShader::init()
|
||||
HeightmapSimulationShader::HeightmapSimulationShader()
|
||||
{
|
||||
const char *varyings[] = {
|
||||
"new_particle_position",
|
||||
@ -1404,122 +1396,35 @@ namespace ParticleShader
|
||||
"new_size",
|
||||
};
|
||||
Program = LoadTFBProgram(file_manager->getAsset("shaders/particlesimheightmap.vert").c_str(), varyings, 4);
|
||||
|
||||
uniform_dt = glGetUniformLocation(Program, "dt");
|
||||
uniform_sourcematrix = glGetUniformLocation(Program, "sourcematrix");
|
||||
uniform_level = glGetUniformLocation(Program, "level");
|
||||
uniform_size_increase_factor = glGetUniformLocation(Program, "size_increase_factor");
|
||||
|
||||
attrib_position = glGetAttribLocation(Program, "particle_position");
|
||||
attrib_lifetime = glGetAttribLocation(Program, "lifetime");
|
||||
attrib_velocity = glGetAttribLocation(Program, "particle_velocity");
|
||||
attrib_size = glGetAttribLocation(Program, "size");
|
||||
attrib_initial_position = glGetAttribLocation(Program, "particle_position_initial");
|
||||
attrib_initial_lifetime = glGetAttribLocation(Program, "lifetime_initial");
|
||||
attrib_initial_velocity = glGetAttribLocation(Program, "particle_velocity_initial");
|
||||
attrib_initial_size = glGetAttribLocation(Program, "size_initial");
|
||||
|
||||
uniform_heightmap = glGetUniformLocation(Program, "heightmap");
|
||||
uniform_track_x = glGetUniformLocation(Program, "track_x");
|
||||
uniform_track_x_len = glGetUniformLocation(Program, "track_x_len");
|
||||
uniform_track_z = glGetUniformLocation(Program, "track_z");
|
||||
uniform_track_z_len = glGetUniformLocation(Program, "track_z_len");
|
||||
TU_heightmap = 2;
|
||||
AssignTextureUnit(Program, TexUnit(TU_heightmap, "heightmap"));
|
||||
AssignUniforms("sourcematrix", "dt", "level", "size_increase_factor", "track_x", "track_x_len", "track_z", "track_z_len");
|
||||
}
|
||||
|
||||
GLuint SimpleParticleRender::Program;
|
||||
GLuint SimpleParticleRender::attrib_pos;
|
||||
GLuint SimpleParticleRender::attrib_lf;
|
||||
GLuint SimpleParticleRender::attrib_quadcorner;
|
||||
GLuint SimpleParticleRender::attrib_texcoord;
|
||||
GLuint SimpleParticleRender::attrib_sz;
|
||||
GLuint SimpleParticleRender::uniform_matrix;
|
||||
GLuint SimpleParticleRender::uniform_viewmatrix;
|
||||
GLuint SimpleParticleRender::uniform_tex;
|
||||
GLuint SimpleParticleRender::uniform_dtex;
|
||||
GLuint SimpleParticleRender::uniform_invproj;
|
||||
GLuint SimpleParticleRender::uniform_color_from;
|
||||
GLuint SimpleParticleRender::uniform_color_to;
|
||||
|
||||
void SimpleParticleRender::init()
|
||||
SimpleParticleRender::SimpleParticleRender()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/particle.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getPosFromUVDepth.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/particle.frag").c_str());
|
||||
attrib_pos = glGetAttribLocation(Program, "position");
|
||||
attrib_sz = glGetAttribLocation(Program, "size");
|
||||
attrib_lf = glGetAttribLocation(Program, "lifetime");
|
||||
attrib_quadcorner = glGetAttribLocation(Program, "quadcorner");
|
||||
attrib_texcoord = glGetAttribLocation(Program, "texcoord");
|
||||
AssignUniforms("color_from", "color_to");
|
||||
|
||||
|
||||
uniform_matrix = glGetUniformLocation(Program, "ProjectionMatrix");
|
||||
uniform_viewmatrix = glGetUniformLocation(Program, "ViewMatrix");
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_invproj = glGetUniformLocation(Program, "invproj");
|
||||
uniform_dtex = glGetUniformLocation(Program, "dtex");
|
||||
uniform_color_from = glGetUniformLocation(Program, "color_from");
|
||||
assert(uniform_color_from != -1);
|
||||
uniform_color_to = glGetUniformLocation(Program, "color_to");
|
||||
assert(uniform_color_to != -1);
|
||||
TU_tex = 0;
|
||||
TU_dtex = 1;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"), TexUnit(TU_dtex, "dtex"));
|
||||
}
|
||||
|
||||
void SimpleParticleRender::setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix,
|
||||
const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_dtex,
|
||||
const ParticleSystemProxy* particle_system)
|
||||
{
|
||||
glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, InvProjMatrix.pointer());
|
||||
glUniformMatrix4fv(uniform_matrix, 1, GL_FALSE, irr_driver->getProjMatrix().pointer());
|
||||
glUniformMatrix4fv(uniform_viewmatrix, 1, GL_FALSE, irr_driver->getViewMatrix().pointer());
|
||||
glUniform1i(uniform_tex, TU_tex);
|
||||
glUniform1i(uniform_dtex, TU_dtex);
|
||||
|
||||
const float* color_from = particle_system->getColorFrom();
|
||||
const float* color_to = particle_system->getColorTo();
|
||||
glUniform3f(uniform_color_from, color_from[0], color_from[1], color_from[2]);
|
||||
glUniform3f(uniform_color_to, color_to[0], color_to[1], color_to[2]);
|
||||
}
|
||||
|
||||
GLuint FlipParticleRender::Program;
|
||||
GLuint FlipParticleRender::attrib_pos;
|
||||
GLuint FlipParticleRender::attrib_lf;
|
||||
GLuint FlipParticleRender::attrib_quadcorner;
|
||||
GLuint FlipParticleRender::attrib_texcoord;
|
||||
GLuint FlipParticleRender::attrib_sz;
|
||||
GLuint FlipParticleRender::attrib_rotationvec;
|
||||
GLuint FlipParticleRender::attrib_anglespeed;
|
||||
GLuint FlipParticleRender::uniform_matrix;
|
||||
GLuint FlipParticleRender::uniform_viewmatrix;
|
||||
GLuint FlipParticleRender::uniform_tex;
|
||||
GLuint FlipParticleRender::uniform_dtex;
|
||||
GLuint FlipParticleRender::uniform_invproj;
|
||||
|
||||
void FlipParticleRender::init()
|
||||
FlipParticleRender::FlipParticleRender()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/flipparticle.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getPosFromUVDepth.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/particle.frag").c_str());
|
||||
attrib_pos = glGetAttribLocation(Program, "position");
|
||||
attrib_sz = glGetAttribLocation(Program, "size");
|
||||
attrib_lf = glGetAttribLocation(Program, "lifetime");
|
||||
attrib_quadcorner = glGetAttribLocation(Program, "quadcorner");
|
||||
attrib_texcoord = glGetAttribLocation(Program, "texcoord");
|
||||
attrib_anglespeed = glGetAttribLocation(Program, "anglespeed");
|
||||
attrib_rotationvec = glGetAttribLocation(Program, "rotationvec");
|
||||
AssignUniforms();
|
||||
|
||||
uniform_matrix = glGetUniformLocation(Program, "ProjectionMatrix");
|
||||
uniform_viewmatrix = glGetUniformLocation(Program, "ViewMatrix");
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_invproj = glGetUniformLocation(Program, "invproj");
|
||||
uniform_dtex = glGetUniformLocation(Program, "dtex");
|
||||
}
|
||||
|
||||
void FlipParticleRender::setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_dtex)
|
||||
{
|
||||
glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, InvProjMatrix.pointer());
|
||||
glUniformMatrix4fv(uniform_matrix, 1, GL_FALSE, irr_driver->getProjMatrix().pointer());
|
||||
glUniformMatrix4fv(uniform_viewmatrix, 1, GL_FALSE, irr_driver->getViewMatrix().pointer());
|
||||
glUniform1i(uniform_tex, TU_tex);
|
||||
glUniform1i(uniform_dtex, TU_dtex);
|
||||
TU_tex = 0;
|
||||
TU_dtex = 1;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"), TexUnit(TU_dtex, "dtex"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1947,127 +1852,44 @@ namespace FullScreenShader
|
||||
|
||||
namespace UIShader
|
||||
{
|
||||
GLuint TextureRectShader::Program;
|
||||
GLuint TextureRectShader::attrib_position;
|
||||
GLuint TextureRectShader::attrib_texcoord;
|
||||
GLuint TextureRectShader::uniform_tex;
|
||||
GLuint TextureRectShader::uniform_center;
|
||||
GLuint TextureRectShader::uniform_size;
|
||||
GLuint TextureRectShader::uniform_texcenter;
|
||||
GLuint TextureRectShader::uniform_texsize;
|
||||
GLuint TextureRectShader::vao;
|
||||
|
||||
void TextureRectShader::init()
|
||||
TextureRectShader::TextureRectShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/texturedquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/texturedquad.frag").c_str());
|
||||
|
||||
attrib_position = glGetAttribLocation(Program, "position");
|
||||
attrib_texcoord = glGetAttribLocation(Program, "texcoord");
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_center = glGetUniformLocation(Program, "center");
|
||||
uniform_size = glGetUniformLocation(Program, "size");
|
||||
uniform_texcenter = glGetUniformLocation(Program, "texcenter");
|
||||
uniform_texsize = glGetUniformLocation(Program, "texsize");
|
||||
glGenVertexArrays(1, &vao);
|
||||
glBindVertexArray(vao);
|
||||
glEnableVertexAttribArray(attrib_position);
|
||||
glEnableVertexAttribArray(attrib_texcoord);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, quad_buffer);
|
||||
glVertexAttribPointer(attrib_position, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
|
||||
glVertexAttribPointer(attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid *)(2 * sizeof(float)));
|
||||
glBindVertexArray(0);
|
||||
AssignUniforms("center", "size", "texcenter", "texsize");
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
}
|
||||
|
||||
void TextureRectShader::setUniforms(float center_pos_x, float center_pos_y, float width, float height, float tex_center_pos_x, float tex_center_pos_y, float tex_width, float tex_height, unsigned TU_tex)
|
||||
{
|
||||
glUniform1i(uniform_tex, TU_tex);
|
||||
glUniform2f(uniform_center, center_pos_x, center_pos_y);
|
||||
glUniform2f(uniform_size, width, height);
|
||||
glUniform2f(uniform_texcenter, tex_center_pos_x, tex_center_pos_y);
|
||||
glUniform2f(uniform_texsize, tex_width, tex_height);
|
||||
}
|
||||
|
||||
GLuint UniformColoredTextureRectShader::Program;
|
||||
GLuint UniformColoredTextureRectShader::attrib_position;
|
||||
GLuint UniformColoredTextureRectShader::attrib_texcoord;
|
||||
GLuint UniformColoredTextureRectShader::uniform_tex;
|
||||
GLuint UniformColoredTextureRectShader::uniform_color;
|
||||
GLuint UniformColoredTextureRectShader::uniform_center;
|
||||
GLuint UniformColoredTextureRectShader::uniform_size;
|
||||
GLuint UniformColoredTextureRectShader::uniform_texcenter;
|
||||
GLuint UniformColoredTextureRectShader::uniform_texsize;
|
||||
GLuint UniformColoredTextureRectShader::vao;
|
||||
|
||||
void UniformColoredTextureRectShader::init()
|
||||
UniformColoredTextureRectShader::UniformColoredTextureRectShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/texturedquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/uniformcolortexturedquad.frag").c_str());
|
||||
|
||||
attrib_position = glGetAttribLocation(Program, "position");
|
||||
attrib_texcoord = glGetAttribLocation(Program, "texcoord");
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_color = glGetUniformLocation(Program, "color");
|
||||
uniform_center = glGetUniformLocation(Program, "center");
|
||||
uniform_size = glGetUniformLocation(Program, "size");
|
||||
uniform_texcenter = glGetUniformLocation(Program, "texcenter");
|
||||
uniform_texsize = glGetUniformLocation(Program, "texsize");
|
||||
glGenVertexArrays(1, &vao);
|
||||
glBindVertexArray(vao);
|
||||
glEnableVertexAttribArray(attrib_position);
|
||||
glEnableVertexAttribArray(attrib_texcoord);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, quad_buffer);
|
||||
glVertexAttribPointer(attrib_position, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
|
||||
glVertexAttribPointer(attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid *)(2 * sizeof(float)));
|
||||
glBindVertexArray(0);
|
||||
AssignUniforms("center", "size", "texcenter", "texsize", "color");
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
}
|
||||
|
||||
void UniformColoredTextureRectShader::setUniforms(float center_pos_x, float center_pos_y, float width, float height, float tex_center_pos_x, float tex_center_pos_y, float tex_width, float tex_height, const SColor &color, unsigned TU_tex)
|
||||
{
|
||||
glUniform1i(uniform_tex, TU_tex);
|
||||
glUniform2f(uniform_center, center_pos_x, center_pos_y);
|
||||
glUniform2f(uniform_size, width, height);
|
||||
glUniform2f(uniform_texcenter, tex_center_pos_x, tex_center_pos_y);
|
||||
glUniform2f(uniform_texsize, tex_width, tex_height);
|
||||
glUniform4i(uniform_color, color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
|
||||
}
|
||||
|
||||
GLuint ColoredTextureRectShader::Program;
|
||||
GLuint ColoredTextureRectShader::attrib_position;
|
||||
GLuint ColoredTextureRectShader::attrib_texcoord;
|
||||
GLuint ColoredTextureRectShader::attrib_color;
|
||||
GLuint ColoredTextureRectShader::uniform_tex;
|
||||
GLuint ColoredTextureRectShader::uniform_center;
|
||||
GLuint ColoredTextureRectShader::uniform_size;
|
||||
GLuint ColoredTextureRectShader::uniform_texcenter;
|
||||
GLuint ColoredTextureRectShader::uniform_texsize;
|
||||
GLuint ColoredTextureRectShader::colorvbo;
|
||||
GLuint ColoredTextureRectShader::vao;
|
||||
|
||||
void ColoredTextureRectShader::init()
|
||||
ColoredTextureRectShader::ColoredTextureRectShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/colortexturedquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/colortexturedquad.frag").c_str());
|
||||
AssignUniforms("center", "size", "texcenter", "texsize");
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
|
||||
attrib_position = glGetAttribLocation(Program, "position");
|
||||
attrib_texcoord = glGetAttribLocation(Program, "texcoord");
|
||||
attrib_color = glGetAttribLocation(Program, "color");
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_center = glGetUniformLocation(Program, "center");
|
||||
uniform_size = glGetUniformLocation(Program, "size");
|
||||
uniform_texcenter = glGetUniformLocation(Program, "texcenter");
|
||||
uniform_texsize = glGetUniformLocation(Program, "texsize");
|
||||
glGenVertexArrays(1, &vao);
|
||||
glBindVertexArray(vao);
|
||||
glEnableVertexAttribArray(attrib_position);
|
||||
glEnableVertexAttribArray(attrib_texcoord);
|
||||
glEnableVertexAttribArray(attrib_color);
|
||||
glEnableVertexAttribArray(0);
|
||||
glEnableVertexAttribArray(3);
|
||||
glEnableVertexAttribArray(2);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, quad_buffer);
|
||||
glVertexAttribPointer(attrib_position, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
|
||||
glVertexAttribPointer(attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid *)(2 * sizeof(float)));
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
|
||||
glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid *)(2 * sizeof(float)));
|
||||
const unsigned quad_color[] = {
|
||||
0, 0, 0, 255,
|
||||
255, 0, 0, 255,
|
||||
@ -2077,47 +1899,15 @@ namespace UIShader
|
||||
glGenBuffers(1, &colorvbo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, colorvbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(unsigned), quad_color, GL_DYNAMIC_DRAW);
|
||||
glVertexAttribIPointer(attrib_color, 4, GL_UNSIGNED_INT, 4 * sizeof(unsigned), 0);
|
||||
glVertexAttribIPointer(2, 4, GL_UNSIGNED_INT, 4 * sizeof(unsigned), 0);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
void ColoredTextureRectShader::setUniforms(float center_pos_x, float center_pos_y, float width, float height, float tex_center_pos_x, float tex_center_pos_y, float tex_width, float tex_height, unsigned TU_tex)
|
||||
{
|
||||
glUniform1i(uniform_tex, TU_tex);
|
||||
glUniform2f(uniform_center, center_pos_x, center_pos_y);
|
||||
glUniform2f(uniform_size, width, height);
|
||||
glUniform2f(uniform_texcenter, tex_center_pos_x, tex_center_pos_y);
|
||||
glUniform2f(uniform_texsize, tex_width, tex_height);
|
||||
}
|
||||
|
||||
GLuint ColoredRectShader::Program;
|
||||
GLuint ColoredRectShader::attrib_position;
|
||||
GLuint ColoredRectShader::uniform_center;
|
||||
GLuint ColoredRectShader::uniform_size;
|
||||
GLuint ColoredRectShader::uniform_color;
|
||||
GLuint ColoredRectShader::vao;
|
||||
|
||||
void ColoredRectShader::init()
|
||||
ColoredRectShader::ColoredRectShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/coloredquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/coloredquad.frag").c_str());
|
||||
attrib_position = glGetAttribLocation(Program, "position");
|
||||
uniform_color = glGetUniformLocation(Program, "color");
|
||||
uniform_center = glGetUniformLocation(Program, "center");
|
||||
uniform_size = glGetUniformLocation(Program, "size");
|
||||
glGenVertexArrays(1, &vao);
|
||||
glBindVertexArray(vao);
|
||||
glEnableVertexAttribArray(attrib_position);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, quad_buffer);
|
||||
glVertexAttribPointer(attrib_position, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
void ColoredRectShader::setUniforms(float center_pos_x, float center_pos_y, float width, float height, const video::SColor &color)
|
||||
{
|
||||
glUniform2f(uniform_center, center_pos_x, center_pos_y);
|
||||
glUniform2f(uniform_size, width, height);
|
||||
glUniform4i(uniform_color, color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
|
||||
AssignUniforms("center", "size", "color");
|
||||
}
|
||||
}
|
||||
|
@ -31,9 +31,10 @@ class SharedObject
|
||||
{
|
||||
public:
|
||||
static GLuint billboardvbo;
|
||||
static GLuint cubevbo, cubeindexes, frustrumvbo, frustrumindexes;
|
||||
static GLuint cubevbo, cubeindexes, frustrumvbo, frustrumindexes, ParticleQuadVBO;
|
||||
static GLuint ViewProjectionMatrixesUBO;
|
||||
static GLuint FullScreenQuadVAO;
|
||||
static GLuint UIVAO;
|
||||
};
|
||||
|
||||
namespace UtilShader
|
||||
@ -220,6 +221,14 @@ public:
|
||||
InstancedGrassPass1Shader();
|
||||
};
|
||||
|
||||
class InstancedNormalMapShader : public ShaderHelperSingleton<InstancedNormalMapShader>
|
||||
{
|
||||
public:
|
||||
GLuint TU_glossy, TU_normalmap;
|
||||
|
||||
InstancedNormalMapShader();
|
||||
};
|
||||
|
||||
class ObjectPass2Shader : public ShaderHelperSingleton<ObjectPass2Shader, core::matrix4, core::matrix4>
|
||||
{
|
||||
public:
|
||||
@ -477,51 +486,36 @@ namespace LightShader
|
||||
namespace ParticleShader
|
||||
{
|
||||
|
||||
class SimpleSimulationShader
|
||||
class SimpleSimulationShader : public ShaderHelperSingleton<SimpleSimulationShader, core::matrix4, int, int, float>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_velocity, attrib_lifetime, attrib_initial_position, attrib_initial_velocity, attrib_initial_lifetime, attrib_size, attrib_initial_size;
|
||||
static GLuint uniform_sourcematrix, uniform_dt, uniform_level, uniform_size_increase_factor;
|
||||
|
||||
static void init();
|
||||
SimpleSimulationShader();
|
||||
};
|
||||
|
||||
|
||||
|
||||
class HeightmapSimulationShader
|
||||
class HeightmapSimulationShader : public ShaderHelperSingleton<HeightmapSimulationShader, core::matrix4, int, int, float, float, float, float, float>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_velocity, attrib_lifetime, attrib_initial_position, attrib_initial_velocity, attrib_initial_lifetime, attrib_size, attrib_initial_size;
|
||||
static GLuint uniform_sourcematrix, uniform_dt, uniform_level, uniform_size_increase_factor;
|
||||
static GLuint uniform_track_x, uniform_track_z, uniform_track_x_len, uniform_track_z_len, uniform_heightmap;
|
||||
GLuint TU_heightmap;
|
||||
|
||||
static void init();
|
||||
HeightmapSimulationShader();
|
||||
};
|
||||
|
||||
class SimpleParticleRender
|
||||
class SimpleParticleRender : public ShaderHelperSingleton<SimpleParticleRender, video::SColorf, video::SColorf>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_pos, attrib_lf, attrib_quadcorner, attrib_texcoord, attrib_sz;
|
||||
static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_dtex, uniform_invproj, uniform_color_from, uniform_color_to;
|
||||
GLuint TU_tex, TU_dtex;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix,
|
||||
const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex,
|
||||
unsigned TU_normal_and_depth, const ParticleSystemProxy* particle_system);
|
||||
SimpleParticleRender();
|
||||
};
|
||||
|
||||
class FlipParticleRender
|
||||
class FlipParticleRender : public ShaderHelperSingleton<FlipParticleRender>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_pos, attrib_lf, attrib_quadcorner, attrib_texcoord, attrib_sz, attrib_rotationvec, attrib_anglespeed;
|
||||
static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_dtex, uniform_invproj;
|
||||
GLuint TU_tex, TU_dtex;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_normal_and_depth);
|
||||
FlipParticleRender();
|
||||
};
|
||||
}
|
||||
|
||||
@ -782,53 +776,36 @@ public:
|
||||
|
||||
namespace UIShader
|
||||
{
|
||||
class TextureRectShader
|
||||
class TextureRectShader : public ShaderHelperSingleton<TextureRectShader, core::vector2df, core::vector2df, core::vector2df, core::vector2df>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord;
|
||||
static GLuint uniform_tex, uniform_center, uniform_size, uniform_texcenter, uniform_texsize;
|
||||
static GLuint vao;
|
||||
GLuint TU_tex;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(float center_pos_x, float center_pos_y, float width, float height, float tex_center_pos_x, float tex_center_pos_y, float tex_width, float tex_height, unsigned TU_tex);
|
||||
TextureRectShader();
|
||||
};
|
||||
|
||||
class UniformColoredTextureRectShader
|
||||
class UniformColoredTextureRectShader : public ShaderHelperSingleton<UniformColoredTextureRectShader, core::vector2df, core::vector2df, core::vector2df, core::vector2df, video::SColor>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord;
|
||||
static GLuint uniform_tex, uniform_color, uniform_center, uniform_size, uniform_texcenter, uniform_texsize;
|
||||
static GLuint vao;
|
||||
GLuint TU_tex;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(float center_pos_x, float center_pos_y, float width, float height, float tex_center_pos_x, float tex_center_pos_y, float tex_width, float tex_height, const video::SColor &color, unsigned TU_tex);
|
||||
UniformColoredTextureRectShader();
|
||||
};
|
||||
|
||||
class ColoredTextureRectShader
|
||||
class ColoredTextureRectShader : public ShaderHelperSingleton<ColoredTextureRectShader, core::vector2df, core::vector2df, core::vector2df, core::vector2df>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_color;
|
||||
static GLuint uniform_tex, uniform_center, uniform_size, uniform_texcenter, uniform_texsize;
|
||||
static GLuint colorvbo;
|
||||
static GLuint vao;
|
||||
GLuint TU_tex;
|
||||
GLuint colorvbo;
|
||||
GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(float center_pos_x, float center_pos_y, float width, float height, float tex_center_pos_x, float tex_center_pos_y, float tex_width, float tex_height, unsigned TU_tex);
|
||||
ColoredTextureRectShader();
|
||||
};
|
||||
|
||||
class ColoredRectShader
|
||||
class ColoredRectShader : public ShaderHelperSingleton<ColoredRectShader, core::vector2df, core::vector2df, video::SColor>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position;
|
||||
static GLuint uniform_center, uniform_size, uniform_color;
|
||||
static GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(float center_pos_x, float center_pos_y, float width, float height, const video::SColor &color);
|
||||
ColoredRectShader();
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -170,4 +170,9 @@ void STKInstancedSceneNode::render()
|
||||
GLMesh *mesh = MeshSolidMaterial[MAT_GRASS][i];
|
||||
ListInstancedMatGrass::getInstance()->push_back(STK::make_tuple(mesh, instance_pos.size() / 9, windDir, cb->getPosition()));
|
||||
}
|
||||
}
|
||||
|
||||
for(unsigned i = 0; i < MeshSolidMaterial[MAT_NORMAL_MAP].size(); i++)
|
||||
{
|
||||
GLMesh *mesh = MeshSolidMaterial[MAT_NORMAL_MAP][i];
|
||||
ListInstancedMatNormalMap::getInstance()->push_back(STK::make_tuple(mesh, instance_pos.size() / 9));
|
||||
}
|
||||
|
@ -13,6 +13,9 @@ class ListInstancedMatAlphaRef : public MeshList<ListInstancedMatAlphaRef, GLMes
|
||||
class ListInstancedMatGrass : public MeshList<ListInstancedMatGrass, GLMesh *, size_t, core::vector3df, core::vector3df>
|
||||
{};
|
||||
|
||||
class ListInstancedMatNormalMap : public MeshList<ListInstancedMatNormalMap, GLMesh *, size_t>
|
||||
{};
|
||||
|
||||
class STKInstancedSceneNode : public irr::scene::CMeshSceneNode
|
||||
{
|
||||
protected:
|
||||
|
@ -828,8 +828,7 @@ namespace GUIEngine
|
||||
{
|
||||
// This code needs to go outside beginScene() / endScene() since
|
||||
// the model view widget will do off-screen rendering there
|
||||
GUIEngine::Widget* widget;
|
||||
for_in (widget, GUIEngine::needsUpdate)
|
||||
for_var_in(GUIEngine::Widget*, widget, GUIEngine::needsUpdate)
|
||||
{
|
||||
widget->update(dt);
|
||||
}
|
||||
|
@ -534,8 +534,7 @@ irr::core::stringw DynamicRibbonWidget::getSelectionText(const int playerID)
|
||||
// -----------------------------------------------------------------------------
|
||||
RibbonWidget* DynamicRibbonWidget::getRowContaining(Widget* w)
|
||||
{
|
||||
RibbonWidget* row;
|
||||
for_in (row, m_rows)
|
||||
for_var_in (RibbonWidget*, row, m_rows)
|
||||
{
|
||||
if (row != NULL)
|
||||
{
|
||||
@ -548,8 +547,7 @@ RibbonWidget* DynamicRibbonWidget::getRowContaining(Widget* w)
|
||||
// -----------------------------------------------------------------------------
|
||||
RibbonWidget* DynamicRibbonWidget::getSelectedRibbon(const int playerID)
|
||||
{
|
||||
RibbonWidget* row;
|
||||
for_in (row, m_rows)
|
||||
for_var_in (RibbonWidget*, row, m_rows)
|
||||
{
|
||||
if (GUIEngine::isFocusedForPlayer(row, playerID))
|
||||
{
|
||||
@ -608,8 +606,7 @@ EventPropagation DynamicRibbonWidget::leftPressed(const int playerID)
|
||||
updateLabel();
|
||||
propagateSelection();
|
||||
|
||||
DynamicRibbonHoverListener* listener;
|
||||
for_in( listener, m_hover_listeners )
|
||||
for_var_in (DynamicRibbonHoverListener*, listener, m_hover_listeners)
|
||||
{
|
||||
listener->onSelectionChanged(this, w->getSelectionIDString(playerID),
|
||||
w->getSelectionText(playerID), playerID);
|
||||
@ -666,8 +663,7 @@ EventPropagation DynamicRibbonWidget::mouseHovered(Widget* child, const int play
|
||||
|
||||
if (getSelectedRibbon(playerID) != NULL)
|
||||
{
|
||||
DynamicRibbonHoverListener* listener;
|
||||
for_in( listener, m_hover_listeners )
|
||||
for_var_in (DynamicRibbonHoverListener*, listener, m_hover_listeners)
|
||||
{
|
||||
listener->onSelectionChanged(this, getSelectedRibbon(playerID)->getSelectionIDString(playerID),
|
||||
getSelectedRibbon(playerID)->getSelectionText(playerID), playerID);
|
||||
@ -682,15 +678,13 @@ EventPropagation DynamicRibbonWidget::focused(const int playerID)
|
||||
Widget::focused(playerID);
|
||||
updateLabel();
|
||||
|
||||
DynamicRibbonHoverListener* listener;
|
||||
|
||||
if (getSelectedRibbon(playerID)->getSelectionIDString(playerID) == "")
|
||||
{
|
||||
//fprintf(stderr, "[DynamicRibbonWidget] WARNING: Can't find selection for player %i, selecting first item\n", playerID);
|
||||
getSelectedRibbon(playerID)->setSelection(0, playerID);
|
||||
}
|
||||
|
||||
for_in( listener, m_hover_listeners )
|
||||
for_var_in (DynamicRibbonHoverListener*, listener, m_hover_listeners)
|
||||
{
|
||||
listener->onSelectionChanged(this, getSelectedRibbon(playerID)->getSelectionIDString(playerID),
|
||||
getSelectedRibbon(playerID)->getSelectionText(playerID), playerID);
|
||||
@ -719,15 +713,13 @@ void DynamicRibbonWidget::onRibbonWidgetFocus(RibbonWidget* emitter, const int p
|
||||
|
||||
updateLabel(emitter);
|
||||
|
||||
DynamicRibbonHoverListener* listener;
|
||||
|
||||
if (emitter->getSelectionIDString(playerID) == "")
|
||||
{
|
||||
//fprintf(stderr, "[DynamicRibbonWidget] WARNING: Can't find selection for player %i, selecting first item\n", playerID);
|
||||
emitter->setSelection(0, playerID);
|
||||
}
|
||||
|
||||
for_in( listener, m_hover_listeners )
|
||||
for_var_in(DynamicRibbonHoverListener*, listener, m_hover_listeners)
|
||||
{
|
||||
listener->onSelectionChanged(this, emitter->getSelectionIDString(playerID),
|
||||
emitter->getSelectionText(playerID), playerID);
|
||||
@ -802,8 +794,7 @@ void DynamicRibbonWidget::propagateSelection()
|
||||
}
|
||||
|
||||
// set same selection in all ribbons
|
||||
RibbonWidget* ribbon;
|
||||
for_in( ribbon, m_rows )
|
||||
for_var_in (RibbonWidget*, ribbon, m_rows)
|
||||
{
|
||||
if (ribbon != selected_ribbon)
|
||||
{
|
||||
|
@ -443,8 +443,7 @@ void RibbonWidget::removeChildNamed(const char* name)
|
||||
// This method should only be called BEFORE a widget is added
|
||||
assert(m_element == NULL);
|
||||
|
||||
Widget* child;
|
||||
for_in (child, m_children)
|
||||
for_var_in(Widget*, child, m_children)
|
||||
{
|
||||
if (child->m_properties[PROP_ID] == name)
|
||||
{
|
||||
|
@ -99,7 +99,7 @@ TrackInfoDialog::TrackInfoDialog(const std::string& ribbonItem, const std::strin
|
||||
if (UserConfigParams::m_artist_debug_mode)
|
||||
m_spinner->setMin(0);
|
||||
|
||||
m_spinner->setValue(track->getDefaultNumberOfLaps());
|
||||
m_spinner->setValue(track->getActualNumberOfLap());
|
||||
race_manager->setNumLaps(m_spinner->getValue());
|
||||
}
|
||||
else
|
||||
@ -236,6 +236,7 @@ void TrackInfoDialog::onEnterPressedInternal()
|
||||
const int num_laps = (m_spinner == NULL ? -1 : m_spinner->getValue());
|
||||
const bool reverse_track = m_checkbox == NULL ? false
|
||||
: m_checkbox->getState();
|
||||
track_manager->getTrack(m_track_ident)->setActualNumberOfLaps(num_laps);
|
||||
race_manager->setReverseTrack(reverse_track);
|
||||
std::string track_ident = m_track_ident;
|
||||
// Disable accidentally unlocking of a challenge
|
||||
|
@ -244,16 +244,19 @@ void RegisterScreen::doRegister()
|
||||
{
|
||||
m_info_widget->setDefaultColor();
|
||||
new RegistrationDialog();
|
||||
if (local_name.size() > 0)
|
||||
{
|
||||
PlayerProfile *player = PlayerManager::get()->getPlayer(local_name);
|
||||
if (player)
|
||||
{
|
||||
player->setLastOnlineName(username);
|
||||
player->setWasOnlineLastTime(true);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
sfx_manager->quickSound( "anvil" );
|
||||
if(local_name.size()>0)
|
||||
{
|
||||
PlayerProfile *player = PlayerManager::get()->getPlayer(local_name);
|
||||
if (player)
|
||||
player->setLastOnlineName(username);
|
||||
}
|
||||
} // doRegister
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -274,6 +274,10 @@ void BaseUserScreen::eventCallback(Widget* widget,
|
||||
else if (button == "new_user")
|
||||
{
|
||||
StateManager::get()->pushScreen(RegisterScreen::getInstance());
|
||||
// Make sure the new user will have an empty online name field
|
||||
// that can also be edited.
|
||||
m_username_tb->setText("");
|
||||
m_username_tb->setActivated();
|
||||
}
|
||||
else if (button == "cancel")
|
||||
{
|
||||
|
@ -21,6 +21,7 @@ using namespace irr;
|
||||
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "graphics/lod_node.hpp"
|
||||
#include "graphics/mesh_tools.hpp"
|
||||
#include "graphics/stkinstancedscenenode.hpp"
|
||||
#include "io/xml_node.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
@ -82,14 +83,8 @@ LODNode* ModelDefinitionLoader::instanciateAsLOD(const XMLNode* node, scene::ISc
|
||||
continue;
|
||||
}
|
||||
|
||||
if (group[m].m_tangent && a_mesh->getMeshBuffer(0)->getVertexType() != video::EVT_TANGENTS)
|
||||
{
|
||||
scene::IMeshManipulator* manip = irr_driver->getVideoDriver()->getMeshManipulator();
|
||||
scene::IMesh* m2 = manip->createMeshWithTangents(a_mesh);
|
||||
// FIXME: do we need to clean up 'a_mesh' ?
|
||||
a_mesh = m2;
|
||||
irr_driver->setAllMaterialFlags(a_mesh);
|
||||
}
|
||||
a_mesh = MeshTools::createMeshWithTangents(a_mesh, &MeshTools::isNormalMap);
|
||||
irr_driver->setAllMaterialFlags(a_mesh);
|
||||
|
||||
a_mesh->grab();
|
||||
//cache.push_back(a_mesh);
|
||||
@ -130,6 +125,9 @@ STKInstancedSceneNode* ModelDefinitionLoader::instanciate(const irr::core::vecto
|
||||
}
|
||||
|
||||
scene::IMesh* mesh = irr_driver->getMesh(m_lod_groups[name][0].m_model_file);
|
||||
mesh = MeshTools::createMeshWithTangents(mesh, &MeshTools::isNormalMap);
|
||||
irr_driver->setAllMaterialFlags(mesh);
|
||||
|
||||
m_instancing_nodes[name] = new STKInstancedSceneNode(mesh,
|
||||
irr_driver->getSceneManager()->getRootSceneNode(), irr_driver->getSceneManager(), -1);
|
||||
m_track->addNode(m_instancing_nodes[name]);
|
||||
|
@ -488,10 +488,14 @@ void Track::loadTrackInfo()
|
||||
root->get("color-level-in", &m_color_inlevel);
|
||||
root->get("color-level-out", &m_color_outlevel);
|
||||
|
||||
if (m_default_number_of_laps <= 0)
|
||||
m_default_number_of_laps = 3;
|
||||
m_actual_number_of_laps = m_default_number_of_laps;
|
||||
|
||||
// Make the default for auto-rescue in battle mode and soccer mode to be false
|
||||
if(m_is_arena || m_is_soccer)
|
||||
m_enable_auto_rescue = false;
|
||||
root->get("auto-rescue", & m_enable_auto_rescue);
|
||||
root->get("auto-rescue", &m_enable_auto_rescue);
|
||||
root->get("smooth-normals", &m_smooth_normals);
|
||||
// Reverse is meaningless in arena
|
||||
if(m_is_arena || m_is_soccer)
|
||||
|
@ -398,8 +398,11 @@ private:
|
||||
/** List of all bezier curves in the track - for e.g. camera, ... */
|
||||
std::vector<BezierCurve*> m_all_curves;
|
||||
|
||||
/** The number of laps the track will be raced if no other value is given.*/
|
||||
/** The number of laps the track will be raced in a random GP.
|
||||
* m_actual_number_of_laps is initialised with this value.*/
|
||||
int m_default_number_of_laps;
|
||||
/** The number of laps that is predefined in a track info dialog. */
|
||||
int m_actual_number_of_laps;
|
||||
|
||||
void loadTrackInfo();
|
||||
void loadQuadGraph(unsigned int mode_id, const bool reverse);
|
||||
@ -614,9 +617,12 @@ public:
|
||||
|
||||
void addNode(scene::ISceneNode* node) { m_all_nodes.push_back(node); }
|
||||
|
||||
float getDisplacementSpeed() const { return m_displacement_speed; }
|
||||
float getCausticsSpeed() const { return m_caustics_speed; }
|
||||
float getDisplacementSpeed() const { return m_displacement_speed; }
|
||||
float getCausticsSpeed() const { return m_caustics_speed; }
|
||||
const int getDefaultNumberOfLaps() const { return m_default_number_of_laps;}
|
||||
const int getActualNumberOfLap() const { return m_actual_number_of_laps; }
|
||||
void setActualNumberOfLaps(unsigned int laps)
|
||||
{ m_actual_number_of_laps = laps; }
|
||||
bool operator<(const Track &other) const;
|
||||
}; // class Track
|
||||
|
||||
|
@ -303,6 +303,8 @@ public:
|
||||
#define for_in( VAR, VECTOR ) for (unsigned int _foreach_i = 0; \
|
||||
VAR = (_foreach_i < VECTOR.size() ? VECTOR.get(_foreach_i) : NULL),\
|
||||
_foreach_i < VECTOR.size(); _foreach_i++)
|
||||
|
||||
#define for_var_in( TYPE, VAR, VECTOR ) TYPE VAR; for (unsigned int _foreach_i = 0; \
|
||||
VAR = (_foreach_i < VECTOR.size() ? VECTOR.get(_foreach_i) : NULL), \
|
||||
_foreach_i < VECTOR.size(); _foreach_i++)
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user