// Declared as an array for compatibility reasons
LightSourceParameters light_sources[1];
vec4 ambient_color;
- vec4 sky_color;
- vec3 world_zenith_dir;
- float horizon_limit;
vec4 fog_color;
float fog_density;
};
add("spot_direction", &Loader::spot_direction);
add("spot_exponent", &Loader::spot_exponent);
add("spot_cutoff", &Loader::spot_cutoff);
-
- // Deprecated
- add("diffuse", &Loader::color);
- add("specular");
}
void Light::Loader::attenuation(float c, float l, float q)
const Color &get_color() const { return color; }
const Color &get_transmittance() const { return transmittance; }
- DEPRECATED void set_diffuse(const Color &c) { set_color(c); }
- DEPRECATED void set_specular(const Color &) { }
- DEPRECATED const Color &get_diffuse() const { return color; }
- DEPRECATED const Color &get_specular() const { return color; }
-
/** Sets the postion and orientation of the Light from a matrix. Negative Z
axis is used as the spot direction, other axes are ignored. */
virtual void set_matrix(const Matrix &);
namespace Msp {
namespace GL {
-Lighting::Lighting():
- zenith_direction(0, 0, 1),
- horizon_angle(Geometry::Angle<float>::zero())
+Lighting::Lighting()
{
set_ambient(0.2f);
set_fog_color(Color(0.0f, 0.0f, 0.0f, 0.0f));
shdata.uniform("ambient_color", ambient);
}
-void Lighting::set_sky_color(const Color &s)
-{
- sky_color = s;
- shdata.uniform("sky_color", sky_color);
-}
-
-void Lighting::set_zenith_direction(const Vector3 &d)
-{
- zenith_direction = d;
- shdata.uniform("world_zenith_dir", zenith_direction);
-}
-
-void Lighting::set_horizon_angle(const Geometry::Angle<float> &a)
-{
- horizon_angle = a;
- shdata.uniform("horizon_limit", horizon_angle.radians());
-}
-
void Lighting::set_fog_color(const Color &c)
{
fog_color = c;
lights.erase(i);
}
-void Lighting::detach(unsigned i)
-{
- if(i>=lights.size())
- return;
-
- detach(*lights[i].light);
-}
-
-const Light *Lighting::get_attached_light(unsigned i) const
-{
- return i<lights.size() ? lights[i].light : 0;
-}
-
-void Lighting::update_shader_data(ProgramData &sd, const Matrix &) const
-{
- sd.uniform("ambient_color", ambient);
- sd.uniform("sky_color", sky_color);
- sd.uniform("world_zenith_dir", zenith_direction);
- sd.uniform("horizon_limit", horizon_angle.radians());
- sd.uniform("fog_color", fog_color);
- sd.uniform("fog_density", fog_density);
-
- for(unsigned i=0; i<lights.size(); ++i)
- if(lights[i].light)
- lights[i].light->update_shader_data(sd, i);
-}
-
const ProgramData &Lighting::get_shader_data() const
{
for(unsigned i=0; i<lights.size(); ++i)
add("fog_half_distance", &Loader::fog_half_distance);
add("light", &Loader::light);
add("light", &Loader::light_inline);
-
- // Deprecated
- add("horizon_angle", &Loader::horizon_angle);
- add("light", &Loader::light_inline_index);
- add("sky_color", &Loader::sky_color);
- add("zenith_direction", &Loader::zenith_direction);
}
void Lighting::Loader::ambient(float r, float g, float b)
obj.set_fog_half_distance(d);
}
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-void Lighting::Loader::horizon_angle(float a)
-{
- obj.set_horizon_angle(Geometry::Angle<float>::from_degrees(a));
-}
-#pragma GCC diagnostic pop
-
void Lighting::Loader::light(const string &name)
{
obj.attach(get_collection().get<Light>(name));
obj.attach(*lgt.release());
}
-void Lighting::Loader::light_inline_index(unsigned)
-{
- light_inline();
-}
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-void Lighting::Loader::sky_color(float r, float g, float b)
-{
- obj.set_sky_color(Color(r, g, b));
-}
-
-void Lighting::Loader::zenith_direction(float x, float y, float z)
-{
- obj.set_zenith_direction(Vector3(x, y, z));
-}
-#pragma GCC diagnostic pop
-
} // namespace GL
} // namespace Msp
void fog_color(float, float, float);
void fog_density(float);
void fog_half_distance(float);
- void horizon_angle(float);
void light(const std::string &);
void light_inline();
- void light_inline_index(unsigned);
- void sky_color(float, float, float);
- void zenith_direction(float, float, float);
};
private:
};
Color ambient;
- Color sky_color;
- Vector3 zenith_direction;
- Geometry::Angle<float> horizon_angle;
Color fog_color;
float fog_density;
std::vector<AttachedLight> lights;
const Color &get_ambient() const { return ambient; }
- /** Sets the color of the sky at zenith. Has no effect without shaders. */
- DEPRECATED void set_sky_color(const Color &);
-
- /** Sets the direction of the zenith. Defaults to positive Z axis. Has no
- effect without shaders. */
- DEPRECATED void set_zenith_direction(const Vector3 &);
-
- /** Sets the angle where skylight cuts off, counted from the true horizon.
- Has no effect without shaders. */
- DEPRECATED void set_horizon_angle(const Geometry::Angle<float> &);
-
/** Sets the fog color, which is blended into distant surfaces. */
void set_fog_color(const Color &);
/** Detaches a light source. If the light was not attached, does nothing. */
void detach(const Light &);
- DEPRECATED void attach(unsigned, const Light &l) { attach(l); }
- DEPRECATED void detach(unsigned);
-
- /** Returns an attached light. If no light is attached at that index, null
- is returned. */
- DEPRECATED const Light *get_attached_light(unsigned) const;
-
- /** Updates a ProgramData object with the uniforms for the Lighting,
- including all attached light sources. A view matrix must be passed in. */
- DEPRECATED void update_shader_data(ProgramData &, const Matrix &) const;
-
const ProgramData &get_shader_data() const;
void set_debug_name(const std::string &);
#include <msp/core/algorithm.h>
#include <msp/datafile/collection.h>
-#include <msp/io/print.h>
#include <msp/strings/format.h>
#include "error.h"
#include "renderpass.h"
obj.maybe_create_material_shader();
}
-// Temporary compatibility feature
-string RenderPass::Loader::get_shader_name(const string &n)
-{
- if(n.size()>=5 && !n.compare(n.size()-5, 5, ".glsl"))
- {
- IO::print(IO::cerr, "Warning: Loading module '%s' as shader is deprecated\n", n);
- return n+".shader";
- }
- return n;
-}
-
void RenderPass::Loader::material_inline()
{
Material::GenericLoader ldr(coll);
void RenderPass::Loader::shader(const string &n)
{
- obj.shprog = &get_collection().get<Program>(get_shader_name(n));
+ obj.shprog = &get_collection().get<Program>(n);
obj.shprog_from_material = false;
if(obj.shdata)
obj.shdata = new ProgramData(*obj.shdata, obj.shprog);
private:
virtual void finish();
- static std::string get_shader_name(const std::string &);
-
void material_inline();
void material(const std::string &);
void shader(const std::string &);
return replaced;
}
-bool Technique::has_shaders() const
-{
- for(const auto &kvp: passes)
- if(kvp.second.get_shader_program())
- return true;
- return false;
-}
-
void Technique::set_debug_name(const string &name)
{
#ifdef DEBUG
bool replace_texture(const std::string &, const Texture &);
bool replace_material(const std::string &, const Material &);
bool replace_uniforms(const ProgramData &);
- DEPRECATED bool has_shaders() const;
void set_debug_name(const std::string &);
};