#include <msp/gl/animatedobject.h>
#include <msp/gl/bloom.h>
#include <msp/gl/box.h>
+#include <msp/gl/colorcurve.h>
#include <msp/gl/cylinder.h>
#include <msp/gl/environmentmap.h>
#include <msp/gl/framebuffer.h>
GL::Light light;
GL::ShadowMap shadow_scene;
GL::Bloom bloom;
+ GL::ColorCurve colorcurve;
GL::Pipeline env_pipeline;
void DesertPillars::create_pipeline()
{
pipeline.set_multisample(8);
+ pipeline.set_hdr(true);
/* The shadow map is focused on the part of the scene that contains the
pillars and the cube. Making the ground cast shadows as well would result
either in a very low spatial resolution of the shadow map, or ugly artifacts
as the ground crosses the shadow map boundary. */
shadow_scene.set_target(GL::Vector3(0, 0, 0), 10);
+ shadow_scene.set_darkness(1);
// Put the sun pretty high in the sky
+ light.set_diffuse(GL::Color(2.0));
light.set_position(GL::Vector4(0.5, -2, 3, 0));
lighting.attach(0, light);
- lighting.set_ambient(GL::Color(0.5));
+ lighting.set_ambient(GL::Color(0.2));
// The skybox is rendered first
pipeline.add_pass(0, sky_scene);
bloom.set_strength(0.3);
pipeline.add_postprocessor(bloom);
+ /* Lighting calculations are best done in linear color space, so the final
+ image must be converted to srgb for display. */
+ colorcurve.set_srgb();
+ pipeline.add_postprocessor(colorcurve);
+
/* Initialize a second pipeline to render the environment map. It has the
same renderables and passes, but no postprocessors or camera. */
env_pipeline.add_pass(0, sky_scene);
void DesertPillars::create_skybox()
{
- skybox_tex.storage(GL::RGB, 128);
+ skybox_tex.storage(GL::SRGB, 128);
skybox_tex.set_min_filter(GL::LINEAR);
skybox_tex.set_wrap(GL::CLAMP_TO_EDGE);
for(unsigned i=0; i<6; ++i)
bld.end();
// Create the four tiles
- bld.color(0.95f, 0.8f, 0.65f);
+ bld.color(GL::Color(0.95f, 0.8f, 0.65f).to_linear());
for(unsigned i=0; i<2; ++i)
for(unsigned j=0; j<2; ++j)
{
unsigned width = 512;
unsigned height = 512;
- sand_texture.storage(GL::RGB, width/16, height/16);
+ sand_texture.storage(GL::SRGB, width/16, height/16);
sand_texture.set_min_filter(GL::LINEAR_MIPMAP_LINEAR);
sand_texture.set_max_anisotropy(4);
sand_texture.set_auto_generate_mipmap(true);
void DesertPillars::create_pillars()
{
// The pillars are a matt off-white
- pillar_material.set_diffuse(GL::Color(0.9, 0.88, 0.8));
+ pillar_material.set_diffuse(GL::Color(0.9, 0.89, 0.85).to_linear());
pillar_material.set_receive_shadows(true);
GL::RenderPass *pass = &pillar_tech.add_pass(0);
{
/* The cube is bluish-gray, with a hard specular reflection to produce a
sun-like spot */
- cube_material.set_diffuse(GL::Color(0.5, 0.5, 0.55));
+ cube_material.set_diffuse(GL::Color(0.5, 0.5, 0.55).to_linear());
cube_material.set_specular(GL::Color(1.0));
cube_material.set_shininess(120);
cube_material.set_reflectivity(0.5);