Merge branch 'master' of https://github.com/supertuxkart/stk-code into newchanges

This commit is contained in:
sachith500 2014-05-22 11:35:21 +05:30
commit 5056f2cc7e
17 changed files with 812 additions and 731 deletions

View File

@ -0,0 +1,35 @@
<?xml version="1.0"?>
<!-- For sky particles, the size of the box is ignored -->
<particles emitter="box" box_x="10.0" box_y="0.5" box_z="10.0">
<spreading angle="3" />
<velocity x="-0.00"
y="-0.002"
z="-0.00" />
<material file="gfx_leaf_a.png" clampu="Y" clampv="Y" />
<!-- Amount of particles emitted per second -->
<rate min="2"
max="5" />
<!-- Minimal and maximal lifetime of a particle, in milliseconds. -->
<lifetime min="30000"
max="30000" />
<!-- Size of the particles -->
<size min="0.40"
max="0.60" />
<color min="40 40 255"
max="255 255 255" />
<!-- How much time in milliseconds before the particle is fully faded out -->
<fadeout time="100" />
<wind speed="0.16"
flips="Y" />
</particles>

View File

@ -2,34 +2,22 @@
<materials>
<material name="banana.png"/>
<material name="gift-box.png"/>
<material name="gift-loop.png" sphere="Y"/>
<material name="gold.png" light="Y" smooth-reflection="Y"/>
<material name="silver.png" light="Y" smooth-reflection="Y"/>
<material name="bronze.png" light="Y" smooth-reflection="Y"/>
<material name="gift-loop.png" shader="spheremap"/>
<material name="gold.png" light="Y" shader="spheremap"/>
<material name="silver.png" light="Y" shader="spheremap"/>
<material name="bronze.png" light="Y" shader="spheremap"/>
<material name="stk_mod_nitroBarrel.png" />
<material name="stk_mod_nitroBottle.png" />
<material name="stk_mod_nitroLogo.png" compositing="additive" light="N" disable-z-write="Y" />
<material name="stk_mod_nitroLogo.png" shader="additive" disable-z-write="Y" />
<material name="traffic_light_green.jpg" light="N"/>
<material name="traffic_light_yellow.jpg" light="N"/>
<material name="traffic_light_red.jpg" light="N"/>
<material name="traffic_light_green.jpg" shader="unlit"/>
<material name="traffic_light_yellow.jpg" shader="unlit"/>
<material name="traffic_light_red.jpg" shader="unlit"/>
<material name="bubblegum_shield.png" compositing="blend" disable-z-write="Y"/>
<material name="bubblegum_shield_nolok.png" compositing="blend" disable-z-write="Y"/>
<material name="bubblegum_shield.png" shader="alphablend" disable-z-write="Y"/>
<material name="bubblegum_shield_nolok.png" shader="alphablend" disable-z-write="Y"/>
<material name="parachute.png" backface-culling="n" ignore="Y"/>
<material name="zipper.png" light="N" zipper="Y"/>
<material name="zipper_collect.png" light="N" zipper="Y"/>
<material name="bowling-icon.png" transparency="Y" light="N"/>
<material name="bubblegum-icon.png" transparency="Y" light="N"/>
<material name="cake-icon.png" transparency="Y" light="N" />
<material name="anchor-icon.png" clampU="Y" clampV="Y" transparency="Y" light="N" ignore="Y"/>
<material name="plunger-icon.png" transparency="Y" light="N"/>
<material name="parachute-icon.png" clampU="Y" clampV="Y" ignore="Y"/>
<material name="anchor-attach-icon.png" clampU="Y" clampV="Y" transparency="Y" light="N" ignore="Y"/>
<material name="parachute-attach-icon.png" clampU="Y" clampV="Y" ignore="Y"/>
<material name="bomb-attach-icon.png" clampU="Y" clampV="Y" ignore="Y"/>
<material name="balldimpleddark.jpg"/>
<material name="zipper.png" shader="unlit" zipper="Y"/>
</materials>

View File

@ -29,6 +29,6 @@ void main(void)
vec4 color = texture(Albedo, uv);
if (color.a < 0.5) discard;
vec3 LightFactor = scattering + getLightFactor(1.);
vec3 LightFactor = (scattering * 0.3) + getLightFactor(1.);
FragColor = vec4(color.xyz * LightFactor, 1.);
}

View File

@ -5,6 +5,7 @@ uniform mat4 ViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 InverseViewMatrix;
uniform mat4 InverseProjectionMatrix;
uniform vec2 screen;
#else
layout (std140) uniform MatrixesData
{

View File

@ -7,6 +7,7 @@ uniform mat4 ViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 InverseViewMatrix;
uniform mat4 InverseProjectionMatrix;
uniform vec2 screen;
#else
layout (std140) uniform MatrixesData
{

View File

@ -3,6 +3,7 @@ uniform mat4 ViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 InverseViewMatrix;
uniform mat4 InverseProjectionMatrix;
uniform vec2 screen;
#else
layout (std140) uniform MatrixesData
{

View File

@ -9,6 +9,7 @@ uniform mat4 ViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 InverseViewMatrix;
uniform mat4 InverseProjectionMatrix;
uniform vec2 screen;
#else
layout (std140) uniform MatrixesData
{

View File

@ -387,11 +387,11 @@ void compressTexture(irr::video::ITexture *tex, bool srgb, bool premul_alpha)
//-----------------------------------------------------------------------------
/** Try to load a compressed texture from the given file name.
* Data in the specified file need to have a specific format. See the
* saveCompressedTexture() function for a description of the format.
* \return true if the loading succeeded, false otherwise.
* \see saveCompressedTexture
*/
* Data in the specified file need to have a specific format. See the
* saveCompressedTexture() function for a description of the format.
* \return true if the loading succeeded, false otherwise.
* \see saveCompressedTexture
*/
bool loadCompressedTexture(const std::string& compressed_tex)
{
std::ifstream ifs(compressed_tex.c_str(), std::ios::in | std::ios::binary);
@ -426,14 +426,14 @@ bool loadCompressedTexture(const std::string& compressed_tex)
//-----------------------------------------------------------------------------
/** Try to save the last texture sent to glTexImage2D in a file of the given
* file name. This function should only be used for textures sent to
* glTexImage2D with a compressed internal format as argument.<br>
* \note The following format is used to save the compressed texture:<br>
* <internal-format><width><height><size><data> <br>
* The first four elements are integers and the last one is stored
* on \c size bytes.
* \see loadCompressedTexture
*/
* file name. This function should only be used for textures sent to
* glTexImage2D with a compressed internal format as argument.<br>
* \note The following format is used to save the compressed texture:<br>
* <internal-format><width><height><size><data> <br>
* The first four elements are integers and the last one is stored
* on \c size bytes.
* \see loadCompressedTexture
*/
void saveCompressedTexture(const std::string& compressed_tex)
{
int internal_format, width, height, size, compressionSuccessful;
@ -653,12 +653,12 @@ void drawTexQuad(const video::ITexture *texture, float width, float height,
static void
getSize(const video::ITexture* texture, const core::rect<s32>& destRect,
const core::rect<s32>& sourceRect,
float &width, float &height,
float &center_pos_x, float &center_pos_y,
float &tex_width, float &tex_height,
float &tex_center_pos_x, float &tex_center_pos_y
)
const core::rect<s32>& sourceRect,
float &width, float &height,
float &center_pos_x, float &center_pos_y,
float &tex_width, float &tex_height,
float &tex_center_pos_x, float &tex_center_pos_y
)
{
core::dimension2d<u32> frame_size =
irr_driver->getVideoDriver()->getCurrentRenderTargetSize();

View File

@ -54,6 +54,7 @@ const unsigned int VCLAMP = 2;
*/
Material::Material(const XMLNode *node, int index, bool deprecated)
{
m_shader_type = SHADERTYPE_SOLID;
m_deprecated = deprecated;
node->get("name", &m_texname);
@ -73,26 +74,20 @@ Material::Material(const XMLNode *node, int index, bool deprecated)
node->get("clampv", &b); if (b) m_clamp_tex |= VCLAMP; //blender 2.4 style
node->get("clampV", &b); if (b) m_clamp_tex |= VCLAMP; //blender 2.5 style
node->get("transparency", &m_alpha_testing );
node->get("lightmap", &m_lightmap );
node->get("additive-lightmap",&m_additive_lightmap );
std::string s;
node->get("adjust-image", &s );
if(s=="premultiply")
m_adjust_image = ADJ_PREMUL;
else if (s=="divide")
m_adjust_image = ADJ_DIV;
else if (s=="" || s=="none")
m_adjust_image = ADJ_NONE;
else
Log::warn("material",
"Incorrect adjust-image specification: '%s' - ignored.",
s.c_str());
node->get("alpha", &m_alpha_blending );
node->get("light", &m_lighting );
//node->get("adjust-image", &s );
//if(s=="premultiply")
// m_adjust_image = ADJ_PREMUL;
//else if (s=="divide")
// m_adjust_image = ADJ_DIV;
//else if (s=="" || s=="none")
// m_adjust_image = ADJ_NONE;
//else
// Log::warn("material",
// "Incorrect adjust-image specification: '%s' - ignored.",
// s.c_str());
node->get("smooth-reflection",&m_smooth_reflection_shader);
node->get("high-adhesion", &m_high_tire_adhesion);
node->get("reset", &m_drive_reset );
@ -135,7 +130,6 @@ Material::Material(const XMLNode *node, int index, bool deprecated)
node->get("surface", &m_surface );
node->get("ignore", &m_ignore );
node->get("additive", &m_add );
node->get("max-speed", &m_max_speed_fraction);
node->get("slowdown-time", &m_slowdown_time );
node->get("backface-culling", &m_backface_culling );
@ -160,21 +154,120 @@ Material::Material(const XMLNode *node, int index, bool deprecated)
}
s="";
s = "";
if (node->get("shader", &s))
{
if (s == "solid")
{
m_shader_type = SHADERTYPE_SOLID;
}
else if (s == "unlit")
{
m_shader_type = SHADERTYPE_SOLID_UNLIT;
}
else if (s == "additive")
{
m_shader_type = SHADERTYPE_ADDITIVE;
}
else if (s == "alphatest")
{
m_shader_type = SHADERTYPE_ALPHA_TEST;
}
else if (s == "alphablend")
{
m_shader_type = SHADERTYPE_ALPHA_BLEND;
}
else if (s == "spheremap")
{
m_shader_type = SHADERTYPE_SPHERE_MAP;
}
else if (s == "water_shader")
{
m_shader_type = SHADERTYPE_WATER;
node->get("water-shader-speed-1", &m_water_shader_speed_1);
node->get("water-shader-speed-2", &m_water_shader_speed_2);
}
else if (s == "grass")
{
m_shader_type = SHADERTYPE_VEGETATION;
m_grass_speed = 1.5f;
m_grass_amplitude = 0.25f;
node->get("grass-speed", &m_grass_speed);
node->get("grass-amplitude", &m_grass_amplitude);
}
else if (s == "splatting")
{
m_shader_type = SHADERTYPE_SPLATTING;
node->get("splatting-texture-1", &m_splatting_texture_1);
node->get("splatting-texture-2", &m_splatting_texture_2);
node->get("splatting-texture-3", &m_splatting_texture_3);
node->get("splatting-texture-4", &m_splatting_texture_4);
}
else if (s == "bubble")
{
m_shader_type = SHADERTYPE_BUBBLE;
}
else
{
Log::warn("Material", "Unknown shader type <%s> for <%s>", s.c_str(), m_texname.c_str());
}
}
else
{
// BACKWARS COMPATIBILITY, EVENTUALLY REMOVE
bool b = false;
node->get("additive", &b);
if (b)
m_shader_type = SHADERTYPE_ADDITIVE;
b = false;
node->get("transparency", &b);
if (b)
m_shader_type = SHADERTYPE_ALPHA_TEST;
//node->get("lightmap", &m_lightmap);
b = false;
node->get("alpha", &b);
if (b)
m_shader_type = SHADERTYPE_ALPHA_BLEND;
b = true;
node->get("light", &b);
if (!b)
m_shader_type = SHADERTYPE_SOLID_UNLIT;
b = false;
node->get("smooth-reflection", &b);
if (b)
m_shader_type = SHADERTYPE_SPHERE_MAP;
if (node->get("compositing", &s))
{
if (s == "blend") m_shader_type = SHADERTYPE_ALPHA_BLEND;
else if (s == "test") m_shader_type = SHADERTYPE_ALPHA_TEST;
else if (s == "additive") m_shader_type = SHADERTYPE_ADDITIVE;
else if (s == "coverage") m_shader_type = SHADERTYPE_ALPHA_TEST;
else if (s != "none")
Log::warn("material", "Unknown compositing mode '%s'", s.c_str());
}
s = "";
node->get("graphical-effect", &s);
if (s == "water")
{
// For backwards compatibility only, eventually remove
m_water_splash = true;
}
else if (s == "bubble")
{
m_graphical_effect = GE_BUBBLE;
m_shader_type = SHADERTYPE_BUBBLE;
}
else if (s == "grass")
{
m_graphical_effect = GE_GRASS;
m_shader_type = SHADERTYPE_VEGETATION;
m_grass_speed = 1.5f;
m_grass_amplitude = 0.25f;
node->get("grass-speed", &m_grass_speed);
@ -182,58 +275,27 @@ Material::Material(const XMLNode *node, int index, bool deprecated)
}
else if (s == "water_shader")
{
m_graphical_effect = GE_WATER_SHADER;
m_shader_type = SHADERTYPE_WATER;
node->get("water-shader-speed-1", &m_water_shader_speed_1);
node->get("water-shader-speed-2", &m_water_shader_speed_2);
}
else if (s == "normal_map")
{
m_graphical_effect = GE_NORMAL_MAP;
m_shader_type = SHADERTYPE_SOLID;
node->get("normal-map", &m_normal_map_tex);
node->get("normal-light-map", &m_normal_map_shader_lightmap);
// TODO: add support for parallax and height maps?
/*
else if (node->get("normal-heightmap", &m_normal_map_tex))
{
m_is_heightmap = true;
m_normal_map = true;
}
else if (node->get("parallax-map", &m_normal_map_tex))
{
m_parallax_map = true;
m_parallax_height = 0.2f;
node->get("parallax-height", &m_parallax_height);
}
else if (node->get("parallax-heightmap", &m_normal_map_tex))
{
m_is_heightmap = true;
m_parallax_map = true;
m_parallax_height = 0.2f;
node->get("parallax-height", &m_parallax_height);
}
*/
}
else if (s == "spheremap")
{
m_graphical_effect = GE_SPHERE_MAP;
}
else if (s == "skybox")
{
m_graphical_effect = GE_SKYBOX;
m_shader_type = SHADERTYPE_SPHERE_MAP;
}
else if (s == "splatting")
{
m_graphical_effect = GE_SPLATTING;
m_shader_type = SHADERTYPE_SPLATTING;
node->get("splatting-texture-1", &m_splatting_texture_1);
node->get("splatting-texture-2", &m_splatting_texture_2);
node->get("splatting-texture-3", &m_splatting_texture_3);
node->get("splatting-texture-4", &m_splatting_texture_4);
}
else if (s == "caustics")
{
m_graphical_effect = GE_CAUSTICS;
}
else if (s == "none")
{
}
@ -245,11 +307,9 @@ Material::Material(const XMLNode *node, int index, bool deprecated)
}
else
{
m_graphical_effect = GE_NONE;
m_shader_type = SHADERTYPE_SOLID;
}
// BACKWARDS COMPATIBILITY, remove eventually
bool use_normal_map = false;
node->get("use-normal-map", &use_normal_map);
@ -257,55 +317,40 @@ Material::Material(const XMLNode *node, int index, bool deprecated)
{
if (node->get("normal-map", &m_normal_map_tex))
{
m_graphical_effect = GE_NORMAL_MAP;
//m_graphical_effect = GE_NORMAL_MAP;
}
else
{
Log::warn("material",
"Could not find normal map image in materials.xml");
}
node->get("normal-light-map", &m_normal_map_shader_lightmap);
}
// BACKWARDS COMPATIBILITY, remove eventually
bool sphere_map = false;
node->get("sphere", &sphere_map );
node->get("sphere", &sphere_map);
if (sphere_map)
{
m_graphical_effect = GE_SPHERE_MAP;
}
if (node->get("compositing", &s))
{
if (s == "blend") m_alpha_blending = true;
else if (s == "test") m_alpha_testing = true;
else if (s == "additive") m_add = true;
// backwards compatibility only, no longer supported
else if (s == "coverage") m_alpha_testing = true;
else if (s != "none")
Log::warn("material", "Unknown compositing mode '%s'",
s.c_str());
}
if (m_disable_z_write && !m_alpha_blending && !m_add)
{
Log::warn("material", "Disabling writes to z buffer only makes sense when compositing is blending or additive (for %s)", m_texname.c_str());
m_disable_z_write = false;
m_shader_type = SHADERTYPE_SPHERE_MAP;
}
bool water_shader = false;
node->get("water-shader", &water_shader);
if (water_shader)
{
// BACKWARDS COMPATIBILITY, eventually remove
m_graphical_effect = GE_WATER_SHADER;
m_shader_type = SHADERTYPE_WATER;
node->get("water-shader-speed-1", &m_water_shader_speed_1);
node->get("water-shader-speed-2", &m_water_shader_speed_2);
}
// ---- End backwards compatibility
}
if (m_disable_z_write && m_shader_type != SHADERTYPE_ALPHA_BLEND && m_shader_type != SHADERTYPE_ADDITIVE)
{
Log::debug("material", "Disabling writes to z buffer only makes sense when compositing is blending or additive (for %s)", m_texname.c_str());
m_disable_z_write = false;
}
// Terrain-specifc sound effect
const unsigned int children_count = node->getNumNodes();
for (unsigned int i=0; i<children_count; i++)
@ -376,14 +421,10 @@ void Material::init(unsigned int index)
{
m_index = index;
m_clamp_tex = 0;
m_alpha_testing = false;
m_lightmap = false;
m_additive_lightmap = false;
m_adjust_image = ADJ_NONE;
m_alpha_blending = false;
m_lighting = true;
m_shader_type = SHADERTYPE_SOLID;
//m_lightmap = false;
//m_adjust_image = ADJ_NONE;
m_backface_culling = true;
m_smooth_reflection_shader = false;
m_high_tire_adhesion = false;
m_below_surface = false;
m_falling_effect = false;
@ -391,7 +432,6 @@ void Material::init(unsigned int index)
m_ignore = false;
m_drive_reset = false;
m_collision_reaction = NORMAL;
m_add = false;
m_disable_z_write = false;
m_water_shader_speed_1 = 6.6667f;
m_water_shader_speed_2 = 4.0f;
@ -403,7 +443,6 @@ void Material::init(unsigned int index)
m_sfx_max_speed = 30;
m_sfx_min_pitch = 1.0f;
m_sfx_max_pitch = 1.0f;
m_graphical_effect = GE_NONE;
m_zipper = false;
m_zipper_duration = -1.0f;
m_zipper_fade_out_time = -1.0f;
@ -411,8 +450,6 @@ void Material::init(unsigned int index)
m_zipper_speed_gain = -1.0f;
m_zipper_engine_force = -1.0f;
m_zipper_min_speed = -1.0f;
m_parallax_map = false;
m_is_heightmap = false;
m_water_splash = false;
m_is_jump_texture = false;
m_has_gravity = false;
@ -438,8 +475,8 @@ void Material::install(bool is_full_path, bool complain_if_not_found)
else
{
m_texture = irr_driver->getTexture(full_path,
isPreMul(),
isPreDiv(),
false, //isPreMul(),
false, //isPreDiv(),
complain_if_not_found);
}
@ -659,36 +696,35 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
}
int modes = 0;
if (!m_lighting && irr_driver->isGLSL() && !m_alpha_blending && !m_add)
if (m_shader_type == SHADERTYPE_SOLID_UNLIT)
{
m->MaterialType = irr_driver->getShader(ES_OBJECT_UNLIT);
modes++;
m->AmbientColor = video::SColor(255, 255, 255, 255);
m->DiffuseColor = video::SColor(255, 255, 255, 255);
m->EmissiveColor = video::SColor(255, 255, 255, 255);
m->SpecularColor = video::SColor(255, 255, 255, 255);
}
if (m_alpha_testing)
if (m_shader_type == SHADERTYPE_ALPHA_TEST)
{
m->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
modes++;
}
if (m_alpha_blending)
{
//m->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
// EMT_TRANSPARENT_ALPHA_CHANNEL does include vertex color alpha into
if (m_shader_type == SHADERTYPE_ALPHA_BLEND)
{
// EMT_TRANSPARENT_ALPHA_CHANNEL doesn't include vertex color alpha into
// account, which messes up fading in/out effects. So we use the more
// customizable EMT_ONETEXTURE_BLEND instead.
m->MaterialType = video::EMT_ONETEXTURE_BLEND ;
m->MaterialType = video::EMT_ONETEXTURE_BLEND;
m->MaterialTypeParam =
pack_textureBlendFunc(video::EBF_SRC_ALPHA,
video::EBF_ONE_MINUS_SRC_ALPHA,
video::EMFN_MODULATE_1X,
video::EAS_TEXTURE | video::EAS_VERTEX_COLOR);
modes++;
}
if (m_smooth_reflection_shader)
if (m_shader_type == SHADERTYPE_SPHERE_MAP)
{
if (irr_driver->isGLSL())
{
@ -697,58 +733,17 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
else
{
m->MaterialType = video::EMT_SPHERE_MAP;
// sphere map + alpha blending is a supported combination so in
// this case don't increase mode count
if (m_alpha_blending)
{
m->BlendOperation = video::EBO_ADD;
}
else
{
modes++;
}
}
}
if (m_graphical_effect == GE_SPHERE_MAP)
{
if (irr_driver->isGLSL())
{
m->MaterialType = irr_driver->getShader(ES_SPHERE_MAP);
}
else
{
m->MaterialType = video::EMT_SPHERE_MAP;
// sphere map + alpha blending is a supported combination so in
// this case don't increase mode count
if (m_alpha_blending)
{
m->BlendOperation = video::EBO_ADD;
}
else
{
modes++;
}
}
}
if (m_lightmap)
{
m->MaterialType = video::EMT_LIGHTMAP;
modes++;
}
if (m_additive_lightmap)
{
m->MaterialType = video::EMT_LIGHTMAP_ADD;
modes++;
}
//if (m_lightmap)
//{
// m->MaterialType = video::EMT_LIGHTMAP;
//}
if (m_add)
if (m_shader_type == SHADERTYPE_ADDITIVE)
{
//m->MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
// EMT_TRANSPARENT_ADD_COLOR does include vertex color alpha into
// EMT_TRANSPARENT_ADD_COLOR doesn't include vertex color alpha into
// account, which messes up fading in/out effects. So we use the
// more customizable EMT_ONETEXTURE_BLEND instead
m->MaterialType = video::EMT_ONETEXTURE_BLEND ;
@ -757,39 +752,39 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
video::EMFN_MODULATE_1X,
video::EAS_TEXTURE |
video::EAS_VERTEX_COLOR);
modes++;
}
if (m_graphical_effect == GE_NORMAL_MAP)
if (m_shader_type == SHADERTYPE_SOLID && m_normal_map_tex.size() > 0)
{
IVideoDriver* video_driver = irr_driver->getVideoDriver();
if (irr_driver->isGLSL())
{
if (mb->getVertexType() != video::EVT_TANGENTS)
Log::error("material", "Requiring normal map without tangent enabled mesh");
ITexture* tex = irr_driver->getTexture(m_normal_map_tex);
if (m_is_heightmap)
{
video_driver->makeNormalMapTexture( tex );
Log::warn("material", "Requiring normal map without tangent enabled mesh for <%s>",
m_texname.c_str());
}
else
{
ITexture* tex = irr_driver->getTexture(m_normal_map_tex);
m->setTexture(1, tex);
bool with_lightmap = false;
if (m_normal_map_shader_lightmap.size() > 0)
{
ITexture* lm_tex = irr_driver->getTexture(m_normal_map_shader_lightmap);
m->setTexture(2, lm_tex);
with_lightmap = true;
}
//if (m_normal_map_shader_lightmap.size() > 0)
//{
// ITexture* lm_tex = irr_driver->getTexture(m_normal_map_shader_lightmap);
// m->setTexture(2, lm_tex);
// with_lightmap = true;
//}
// Material and shaders
m->MaterialType = irr_driver->getShader(
with_lightmap ? ES_NORMAL_MAP_LIGHTMAP : ES_NORMAL_MAP );
with_lightmap ? ES_NORMAL_MAP_LIGHTMAP : ES_NORMAL_MAP);
m->Lighting = false;
m->ZWriteEnable = true;
modes++;
}
}
else
{
@ -797,29 +792,30 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
m->setTexture(1, NULL);
}
}
if (m_parallax_map)
{
video::ITexture* tex = irr_driver->getTexture(m_normal_map_tex);
if (m_is_heightmap)
{
irr_driver->getVideoDriver()->makeNormalMapTexture( tex );
}
m->setTexture(1, tex);
m->MaterialType = video::EMT_PARALLAX_MAP_SOLID;
m->MaterialTypeParam = m_parallax_height;
m->SpecularColor.set(0,0,0,0);
modes++;
}
//if (m_parallax_map)
//{
// video::ITexture* tex = irr_driver->getTexture(m_normal_map_tex);
// if (m_is_heightmap)
// {
// irr_driver->getVideoDriver()->makeNormalMapTexture( tex );
// }
// m->setTexture(1, tex);
// m->MaterialType = video::EMT_PARALLAX_MAP_SOLID;
// m->MaterialTypeParam = m_parallax_height;
// m->SpecularColor.set(0,0,0,0);
// modes++;
//}
if(m_graphical_effect == GE_SKYBOX && irr_driver->isGLSL())
{
ITexture* tex = irr_driver->getTexture("cloud_mask.png");
m->setTexture(1, tex);
//if(m_graphical_effect == GE_SKYBOX && irr_driver->isGLSL())
//{
// ITexture* tex = irr_driver->getTexture("cloud_mask.png");
// m->setTexture(1, tex);
//
//
// m->MaterialType = irr_driver->getShader(ES_SKYBOX);
//}
m->MaterialType = irr_driver->getShader(ES_SKYBOX);
}
if (m_graphical_effect == GE_SPLATTING)
if (m_shader_type == SHADERTYPE_SPLATTING)
{
if (irr_driver->supportsSplatting())
{
@ -866,7 +862,7 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
m->SpecularColor = video::SColor(255, 255, 255, 255);
}
if (m_graphical_effect == GE_BUBBLE && mb != NULL)
if (m_shader_type == SHADERTYPE_BUBBLE && mb != NULL)
{
if (irr_driver->isGLSL())
{
@ -876,18 +872,11 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
m->MaterialType = irr_driver->getShader(ES_BUBBLES);
m->BlendOperation = video::EBO_ADD;
// alpha blending and bubble shading can work together so when both are enabled
// don't increment the 'modes' counter to not get the 'too many modes' warning
if (!m_alpha_blending)
{
modes++;
}
}
}
if (m_graphical_effect == GE_WATER_SHADER)
if (m_shader_type == SHADERTYPE_WATER)
{
if (irr_driver->isGLSL())
{
@ -901,10 +890,9 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
m->MaterialType = irr_driver->getShader(ES_WATER);
}
modes++;
}
if (m_graphical_effect == GE_GRASS)
if (m_shader_type == SHADERTYPE_VEGETATION)
{
if (UserConfigParams::m_weather_effects &&
irr_driver->isGLSL())
@ -916,22 +904,20 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
setAmplitude(m_grass_amplitude);
// Material and shaders
if (m_alpha_testing)
{
//if (m_alpha_testing)
//{
m->MaterialType = irr_driver->getShader(ES_GRASS_REF);
//}
//else
//{
// m->MaterialType = irr_driver->getShader(ES_GRASS);
// m->BlendOperation = video::EBO_ADD;
//}
}
else {
m->MaterialType = irr_driver->getShader(ES_GRASS);
m->BlendOperation = video::EBO_ADD;
}
}
}
if (modes > 1)
else
{
std::cerr << "[Material::setMaterialProperties] More than one main "
"mode set for " << m_texname.c_str() << "\n";
m->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
}
}
if (m_disable_z_write)
@ -939,15 +925,6 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
m->ZWriteEnable = false;
}
if (!m_lighting)
{
//m->setFlag( video::EMF_LIGHTING, false );
m->AmbientColor = video::SColor(255, 255, 255, 255);
m->DiffuseColor = video::SColor(255, 255, 255, 255);
m->EmissiveColor = video::SColor(255, 255, 255, 255);
m->SpecularColor = video::SColor(255, 255, 255, 255);
}
#ifdef DEBUG
if(UserConfigParams::m_rendering_debug)
{
@ -1024,7 +1001,7 @@ void Material::adjustForFog(scene::ISceneNode* parent, video::SMaterial *m,
// to disable fog in the new pipeline, we slightly abuse the steps :
// moving an object into the transparent pass will make it rendered
// above fog and thus unaffected by it
if (use_fog && !m_fog && !m_alpha_blending && !m_add)
if (use_fog && !m_fog && m_shader_type != SHADERTYPE_ALPHA_BLEND && m_shader_type != SHADERTYPE_ADDITIVE)
{
m->ZWriteEnable = true;
m->MaterialType = video::EMT_ONETEXTURE_BLEND;

View File

@ -46,17 +46,21 @@ class ParticleKind;
class Material : public NoCopy
{
public:
enum GraphicalEffect {GE_NONE,
enum ShaderType
{
SHADERTYPE_SOLID,
SHADERTYPE_ALPHA_TEST,
SHADERTYPE_ALPHA_BLEND,
SHADERTYPE_ADDITIVE,
SHADERTYPE_SOLID_UNLIT,
/** Effect where the UV texture is moved in a wave pattern */
GE_BUBBLE,
SHADERTYPE_BUBBLE,
/** Effect that makes grass wave as in the wind */
GE_GRASS,
GE_WATER_SHADER,
GE_SPHERE_MAP,
GE_SPLATTING,
GE_SKYBOX,
GE_NORMAL_MAP,
GE_CAUSTICS};
SHADERTYPE_VEGETATION,
SHADERTYPE_WATER,
SHADERTYPE_SPHERE_MAP,
SHADERTYPE_SPLATTING
};
enum ParticleConditions
{
@ -82,7 +86,9 @@ private:
/** Name of a special sfx to play when a kart is on this terrain, or
* "" if no special sfx exists. */
std::string m_sfx_name;
GraphicalEffect m_graphical_effect;
ShaderType m_shader_type;
/** Set if being on this surface means being under some other mesh.
* This is used to simulate that a kart is in water: the ground under
* the water is marked as 'm_below_surface', which will then trigger a raycast
@ -117,11 +123,11 @@ private:
bool m_has_gravity;
/** Speed of the 'main' wave in the water shader. Only used if
m_graphical_effect == WATER_SHADER */
m_shader_type == SHDERTYPE_WATER */
float m_water_shader_speed_1;
/** Speed of the 'secondary' waves in the water shader. Only used if
m_graphical_effect == WATER_SHADER */
m_shader_type == SHADERTYPE_WATER */
float m_water_shader_speed_2;
/** If a kart is rescued when crashing into this surface. */
@ -130,13 +136,13 @@ private:
/** Particles to show on touch */
std::string m_collision_particles;
/** If m_shader_type == SHADERTYPE_VEGETATION */
float m_grass_speed;
float m_grass_amplitude;
/** If the property should be ignored in the physics. Example would be
* plants that a kart can just drive through. */
bool m_ignore;
bool m_add;
bool m_fog;
@ -144,21 +150,10 @@ private:
/** For normal maps */
std::string m_normal_map_tex;
std::string m_normal_map_shader_lightmap;
//bool m_normal_map_uv2; //!< Whether to use a second UV layer for normal map
bool m_is_heightmap;
bool m_parallax_map;
float m_parallax_height;
/** Texture clamp bitmask */
unsigned int m_clamp_tex;
bool m_lighting;
bool m_smooth_reflection_shader;
bool m_alpha_testing;
bool m_alpha_blending;
/** True if backface culliing should be enabled. */
bool m_backface_culling;
@ -167,18 +162,21 @@ private:
/** Some textures need to be pre-multiplied, some divided to give
* the intended effect. */
enum {ADJ_NONE, ADJ_PREMUL, ADJ_DIV}
m_adjust_image;
/** True if (blending) lightmapping is enabled for this material. */
bool m_lightmap;
/** True if (additive) lightmapping is enabled for this material. */
bool m_additive_lightmap;
//enum {ADJ_NONE, ADJ_PREMUL, ADJ_DIV}
// m_adjust_image;
/** True if lightmapping is enabled for this material. */
//bool m_lightmap;
/** True if the material shouldn't be "slippy" at an angle */
bool m_high_tire_adhesion;
/** How much the top speed is reduced per second. */
float m_slowdown_time;
/** Maximum speed at which no more slow down occurs. */
float m_max_speed_fraction;
/** Minimum speed on this terrain. This is used for zippers on a ramp to
* guarantee the right jump distance. A negative value indicates no
* minimum speed. */
@ -249,7 +247,6 @@ public:
bool isIgnore () const { return m_ignore; }
/** Returns true if this material is a zipper. */
bool isZipper () const { return m_zipper; }
bool isSphereMap () const { return m_graphical_effect == GE_SPHERE_MAP; }
/** Returns if this material should trigger a rescue if a kart
* is driving on it. */
bool isDriveReset () const { return m_drive_reset; }
@ -264,14 +261,19 @@ public:
getTexFname () const { return m_texname; }
int getIndex () const { return m_index; }
bool isTransparent () const { return m_alpha_testing || m_alpha_blending || m_add; }
bool isTransparent () const
{
return m_shader_type == SHADERTYPE_ADDITIVE ||
m_shader_type == SHADERTYPE_ALPHA_BLEND ||
m_shader_type == SHADERTYPE_ALPHA_TEST;
}
// ------------------------------------------------------------------------
/** Returns true if this materials need pre-multiply of alpha. */
bool isPreMul() const {return m_adjust_image==ADJ_PREMUL; }
//bool isPreMul() const {return m_adjust_image==ADJ_PREMUL; }
// ------------------------------------------------------------------------
/** Returns true if this materials need pre-division of alpha. */
bool isPreDiv() const {return m_adjust_image==ADJ_DIV; }
//bool isPreDiv() const {return m_adjust_image==ADJ_DIV; }
// ------------------------------------------------------------------------
/** Returns the fraction of maximum speed on this material. */
float getMaxSpeedFraction() const { return m_max_speed_fraction; }
@ -281,9 +283,6 @@ public:
* karts. So a short time will slowdown a kart much faster. */
float getSlowDownTime() const { return m_slowdown_time; }
// ------------------------------------------------------------------------
/** Returns true if this material should have smoke effect. */
//bool hasSmoke () const { return m_graphical_effect==GE_SMOKE;}
// ------------------------------------------------------------------------
/** Returns true if this material is under some other mesh and therefore
* requires another raycast to find the surface it is under (used for
* gfx, e.g. driving under water to find where the water splash should
@ -341,14 +340,11 @@ public:
* on lower speeds. A negative value indicates no minimum speed. */
float getZipperMinSpeed() const { return m_zipper_min_speed; }
// ------------------------------------------------------------------------
bool isNormalMap() const { return m_graphical_effect == GE_NORMAL_MAP; }
ShaderType getShaderType() const { return m_shader_type; }
// ------------------------------------------------------------------------
void onMadeVisible(scene::IMeshBuffer* who);
void onHidden(scene::IMeshBuffer* who);
void isInitiallyHidden(scene::IMeshBuffer* who);
/** For particle system : specify if the particle should be additively blended
*/
bool isAlphaAdditive() const { return !m_alpha_blending; }
} ;

View File

@ -453,7 +453,10 @@ void ParticleEmitter::setParticleType(const ParticleKind* type)
m_node = irr_driver->addParticleNode();
if (m_is_glsl)
static_cast<ParticleSystemProxy *>(m_node)->setAlphaAdditive(type->getMaterial()->isAlphaAdditive());
{
bool additive = (type->getMaterial()->getShaderType() == Material::SHADERTYPE_ADDITIVE);
static_cast<ParticleSystemProxy *>(m_node)->setAlphaAdditive(additive);
}
}
if (m_parent != NULL)

View File

@ -53,6 +53,7 @@ static GLuint generateFBO(GLuint ColorAttachement, GLuint DepthAttachement)
RTT::RTT(size_t width, size_t height)
{
m_shadow_FBO = NULL;
initGL();
using namespace video;
using namespace core;
@ -197,14 +198,14 @@ RTT::RTT(size_t width, size_t height)
somevector.clear();
somevector.push_back(shadowColorTex);
shadowFBO = new FrameBuffer(somevector, shadowDepthTex, 1024, 1024, true);
m_shadow_FBO = new FrameBuffer(somevector, shadowDepthTex, 1024, 1024, true);
}
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
RTT::~RTT()
{
delete shadowFBO;
delete m_shadow_FBO;
glDeleteTextures(RTT_COUNT, RenderTargetTextures);
glDeleteTextures(1, &DepthStencilTexture);
if (irr_driver->getGLSLVersion() >= 150)

View File

@ -37,7 +37,7 @@ public:
RTT(size_t width, size_t height);
~RTT();
FrameBuffer &getShadowFBO() { return *shadowFBO; }
FrameBuffer &getShadowFBO() { return *m_shadow_FBO; }
unsigned getShadowDepthTex() const { return shadowDepthTex; }
unsigned getDepthStencilTexture() const { return DepthStencilTexture; }
@ -49,7 +49,7 @@ private:
unsigned DepthStencilTexture;
unsigned shadowColorTex, shadowDepthTex;
FrameBuffer* shadowFBO;
FrameBuffer* m_shadow_FBO;
LEAK_CHECK();
};

View File

@ -273,8 +273,6 @@ void Shaders::loadShaders()
FullScreenShader::Gaussian17TapVShader::init();
FullScreenShader::Gaussian6HBlurShader::init();
FullScreenShader::Gaussian6VBlurShader::init();
FullScreenShader::PenumbraHShader::init();
FullScreenShader::PenumbraVShader::init();
FullScreenShader::GlowShader::init();
FullScreenShader::PassThroughShader::init();
FullScreenShader::LinearizeDepthShader::init();
@ -394,9 +392,12 @@ namespace UtilShader
glEnableVertexAttribArray(attrib_position);
glVertexAttribPointer(attrib_position, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), 0);
uniform_color = glGetUniformLocation(Program, "color");
if (!UserConfigParams::m_ubo_disabled)
{
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
}
void ColoredLine::setUniforms(const irr::video::SColor &col)
{
@ -429,9 +430,12 @@ namespace MeshShader
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix");
uniform_tex = glGetUniformLocation(Program, "tex");
if (!UserConfigParams::m_ubo_disabled)
{
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
}
void ObjectPass1Shader::setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &InverseModelMatrix, unsigned TU_tex)
{
@ -464,9 +468,12 @@ namespace MeshShader
uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix");
uniform_TM = glGetUniformLocation(Program, "TextureMatrix");
uniform_tex = glGetUniformLocation(Program, "tex");
if (!UserConfigParams::m_ubo_disabled)
{
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
}
void ObjectRefPass1Shader::setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &InverseModelMatrix, const core::matrix4 &TextureMatrix, unsigned TU_tex)
{
@ -536,9 +543,12 @@ namespace MeshShader
uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix");
uniform_normalMap = glGetUniformLocation(Program, "normalMap");
uniform_DiffuseForAlpha = glGetUniformLocation(Program, "DiffuseForAlpha");
if (!UserConfigParams::m_ubo_disabled)
{
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
}
void NormalMapShader::setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &InverseModelMatrix, unsigned TU_normalMap, unsigned TU_uniform_DiffuseForAlpha)
{
@ -573,9 +583,12 @@ namespace MeshShader
attrib_normal = glGetAttribLocation(Program, "Normal");
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
uniform_tex = glGetUniformLocation(Program, "tex");
if (!UserConfigParams::m_ubo_disabled)
{
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
}
void InstancedObjectPass1Shader::setUniforms(unsigned TU_tex)
{
@ -607,9 +620,12 @@ namespace MeshShader
attrib_normal = glGetAttribLocation(Program, "Normal");
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
uniform_tex = glGetUniformLocation(Program, "tex");
if (!UserConfigParams::m_ubo_disabled)
{
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
}
void InstancedObjectRefPass1Shader::setUniforms(unsigned TU_tex)
{
@ -645,9 +661,12 @@ namespace MeshShader
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
uniform_windDir = glGetUniformLocation(Program, "windDir");
uniform_tex = glGetUniformLocation(Program, "tex");
if (!UserConfigParams::m_ubo_disabled)
{
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
}
void InstancedGrassPass1Shader::setUniforms(const core::vector3df &windDir, unsigned TU_tex)
{
@ -682,8 +701,11 @@ namespace MeshShader
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
uniform_ambient = glGetUniformLocation(Program, "ambient");
if (!UserConfigParams::m_ubo_disabled)
{
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
TU_Albedo = 3;
glUseProgram(Program);
@ -743,9 +765,12 @@ namespace MeshShader
glUniform1i(uniform_Albedo, TU_Albedo);
glUseProgram(0);
if (!UserConfigParams::m_ubo_disabled)
{
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
}
void InstancedObjectPass2Shader::setUniforms(const core::matrix4 &ViewProjectionMatrix, const core::matrix4 &TextureMatrix)
{
@ -873,8 +898,11 @@ namespace MeshShader
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
GLuint uniform_tex = glGetUniformLocation(Program, "tex");
if (!UserConfigParams::m_ubo_disabled)
{
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
TU_tex = 3;
glUseProgram(Program);
@ -916,8 +944,11 @@ namespace MeshShader
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
uniform_ambient = glGetUniformLocation(Program, "ambient");
GLuint uniform_tex = glGetUniformLocation(Program, "tex");
if (!UserConfigParams::m_ubo_disabled)
{
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
TU_Albedo = 3;
glUseProgram(Program);
@ -960,8 +991,11 @@ namespace MeshShader
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
uniform_ambient = glGetUniformLocation(Program, "ambient");
if (!UserConfigParams::m_ubo_disabled)
{
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
glUseProgram(Program);
glUniform1i(uniform_DiffuseMap, 0);
@ -1004,8 +1038,11 @@ namespace MeshShader
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
uniform_ambient = glGetUniformLocation(Program, "ambient");
if (!UserConfigParams::m_ubo_disabled)
{
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
TU_Albedo = 3;
glUseProgram(Program);
@ -1160,11 +1197,21 @@ namespace MeshShader
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix");
GLuint uniform_tex = glGetUniformLocation(Program, "tex");
GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo");
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
if (!UserConfigParams::m_ubo_disabled)
{
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
TU_tex = 3;
glUseProgram(Program);
glUniform1i(uniform_DiffuseMap, 0);
glUniform1i(uniform_SpecularMap, 1);
glUniform1i(uniform_SSAO, 2);
glUniform1i(uniform_tex, TU_tex);
glUseProgram(0);
}
@ -1319,9 +1366,12 @@ namespace MeshShader
uniform_start = glGetUniformLocation(Program, "start");
uniform_end = glGetUniformLocation(Program, "end");
uniform_col = glGetUniformLocation(Program, "col");
if (!UserConfigParams::m_ubo_disabled)
{
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
}
void TransparentFogShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_tex)
{
@ -1385,9 +1435,12 @@ namespace MeshShader
attrib_position = glGetAttribLocation(Program, "Position");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
uniform_col = glGetUniformLocation(Program, "col");
if (!UserConfigParams::m_ubo_disabled)
{
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
}
void ColorizeShader::setUniforms(const core::matrix4 &ModelMatrix, float r, float g, float b)
{
@ -1669,8 +1722,11 @@ namespace MeshShader
attrib_position = glGetAttribLocation(Program, "Position");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
uniform_tex = glGetUniformLocation(Program, "tex");
if (!UserConfigParams::m_ubo_disabled)
{
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
glGenVertexArrays(1, &cubevao);
glBindVertexArray(cubevao);
@ -2090,9 +2146,12 @@ namespace FullScreenShader
uniform_direction = glGetUniformLocation(Program, "direction");
uniform_col = glGetUniformLocation(Program, "col");
vao = createVAO(Program);
if (!UserConfigParams::m_ubo_disabled)
{
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
}
void SunLightShader::setUniforms(const core::vector3df &direction, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex)
{
@ -2157,9 +2216,12 @@ namespace FullScreenShader
uniform_direction = glGetUniformLocation(Program, "direction");
uniform_col = glGetUniformLocation(Program, "col");
vao = createVAO(Program);
if (!UserConfigParams::m_ubo_disabled)
{
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
}
void ShadowedSunLightShader::setUniforms(const core::vector3df &direction, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_shadowtex)
{
@ -2193,9 +2255,12 @@ namespace FullScreenShader
uniform_direction = glGetUniformLocation(Program, "direction");
uniform_col = glGetUniformLocation(Program, "col");
vao = createVAO(Program);
if (!UserConfigParams::m_ubo_disabled)
{
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
}
void ShadowedSunLightDebugShader::setUniforms(const core::vector3df &direction, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_shadowtex)
{
@ -2292,46 +2357,6 @@ namespace FullScreenShader
vao = createVAO(Program);
}
GLuint PenumbraHShader::Program;
GLuint PenumbraHShader::uniform_tex;
GLuint PenumbraHShader::uniform_pixel;
GLuint PenumbraHShader::vao;
void PenumbraHShader::init()
{
Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/penumbrah.frag").c_str());
uniform_tex = glGetUniformLocation(Program, "tex");
uniform_pixel = glGetUniformLocation(Program, "pixel");
vao = createVAO(Program);
}
void PenumbraHShader::setUniforms(const core::vector2df &pixels, GLuint TU_tex)
{
glUniform2f(uniform_pixel, pixels.X, pixels.Y);
glUniform1i(uniform_tex, TU_tex);
}
GLuint PenumbraVShader::Program;
GLuint PenumbraVShader::uniform_tex;
GLuint PenumbraVShader::uniform_pixel;
GLuint PenumbraVShader::vao;
void PenumbraVShader::init()
{
Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/penumbrav.frag").c_str());
uniform_tex = glGetUniformLocation(Program, "tex");
uniform_pixel = glGetUniformLocation(Program, "pixel");
vao = createVAO(Program);
}
void PenumbraVShader::setUniforms(const core::vector2df &pixels, GLuint TU_tex)
{
glUniform2f(uniform_pixel, pixels.X, pixels.Y);
glUniform1i(uniform_tex, TU_tex);
}
GLuint ShadowGenShader::Program;
GLuint ShadowGenShader::uniform_halft;
GLuint ShadowGenShader::uniform_quarter;
@ -2422,8 +2447,11 @@ namespace FullScreenShader
uniform_noise_texture = glGetUniformLocation(Program, "noise_texture");
uniform_samplePoints = glGetUniformLocation(Program, "samplePoints[0]");
vao = createVAO(Program);
if (!UserConfigParams::m_ubo_disabled)
{
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
// SSAOSamples[4 * i] and SSAOSamples[4 * i + 1] can be negative
@ -2573,9 +2601,12 @@ namespace FullScreenShader
uniform_end = glGetUniformLocation(Program, "end");
uniform_col = glGetUniformLocation(Program, "col");
vao = createVAO(Program);
if (!UserConfigParams::m_ubo_disabled)
{
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
}
void FogShader::setUniforms(float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, unsigned TU_ntex)
{

View File

@ -283,6 +283,16 @@ static void drawSMDefault(GLMesh &mesh, const core::matrix4 &ModelViewProjection
size_t count = mesh.IndexCount;
setTexture(MeshShader::InstancedObjectPass2Shader::TU_Albedo, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (irr_driver->getLightViz())
{
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
else
{
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
MeshShader::InstancedObjectPass2Shader::setUniforms(ModelViewProjectionMatrix, core::matrix4::EM4CONST_IDENTITY);
@ -299,6 +309,16 @@ static void drawSMAlphaRefTexture(GLMesh &mesh, const core::matrix4 &ModelViewPr
compressTexture(mesh.textures[0], true);
setTexture(MeshShader::InstancedObjectRefPass2Shader::TU_Albedo, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (irr_driver->getLightViz())
{
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
else
{
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
MeshShader::InstancedObjectRefPass2Shader::setUniforms(ModelViewProjectionMatrix, core::matrix4::EM4CONST_IDENTITY);
@ -315,6 +335,16 @@ static void drawSMGrass(GLMesh &mesh, const core::matrix4 &ModelViewProjectionMa
compressTexture(mesh.textures[0], true);
setTexture(MeshShader::InstancedGrassPass2Shader::TU_Albedo, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
if (irr_driver->getLightViz())
{
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
else
{
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
setTexture(MeshShader::InstancedGrassPass2Shader::TU_dtex, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
SunLightProvider * const cb = (SunLightProvider *)irr_driver->getCallback(ES_SUNLIGHT);

View File

@ -308,6 +308,16 @@ void drawSphereMap(const GLMesh &mesh, const core::matrix4 &ModelMatrix, const c
size_t count = mesh.IndexCount;
compressTexture(mesh.textures[0], true);
if (irr_driver->getLightViz())
{
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
else
{
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
setTexture(MeshShader::SphereMapShader::TU_tex, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
MeshShader::SphereMapShader::setUniforms(ModelMatrix, InverseModelMatrix);

View File

@ -101,6 +101,12 @@ void RegisterScreen::doRegister()
{
m_info_widget->setText(_("Email has to be between 4 and 50 characters long!"), false);
}
else if ( email.find(L"@")== -1 || email.find(L".")== -1 ||
(email.findLast(L'.') - email.findLast(L'@') <= 2 ) ||
email.findLast(L'@')==0 )
{
m_info_widget->setText(_("Email is invalid!"), false);
}
else
{
m_info_widget->setDefaultColor();