Godray/Godfade now declared in new pipeline.

This commit is contained in:
Vincent Lejeune 2014-02-23 18:59:24 +01:00
parent a00abffb01
commit 778cdcf3ce
4 changed files with 69 additions and 4 deletions

View File

@ -1,11 +1,13 @@
#version 330 compatibility
#version 330
uniform sampler2D tex;
uniform vec3 col;
in vec2 uv;
out vec4 FragColor;
void main()
{
vec4 res = texture(tex, gl_TexCoord[0].xy);
vec4 res = texture(tex, uv);
// Keep the sun fully bright, but fade the sky
float mul = distance(res.xyz, col);

View File

@ -1,4 +1,4 @@
#version 330 compatibility
#version 330
uniform sampler2D tex;
uniform vec2 sunpos;
@ -6,11 +6,12 @@ uniform vec2 sunpos;
const float decaystep = 0.88;
in vec2 uv;
out vec4 FragColor;
void main()
{
vec2 texc = gl_TexCoord[0].xy;
vec2 texc = uv;
vec2 tosun = sunpos - texc;
if (dot(tosun, tosun) > 0.49) discard;

View File

@ -239,6 +239,8 @@ void Shaders::loadShaders()
FullScreenShader::SunLightShader::init();
FullScreenShader::ShadowedSunLightShader::init();
FullScreenShader::MotionBlurShader::init();
FullScreenShader::GodFadeShader::init();
FullScreenShader::GodRayShader::init();
MeshShader::ColorizeShader::init();
MeshShader::NormalMapShader::init();
MeshShader::ObjectPass1Shader::init();
@ -1724,6 +1726,44 @@ namespace FullScreenShader
glUniform1f(uniform_max_tex_height, max_tex_height);
glUniform1i(uniform_color_buffer, TU_cb);
}
GLuint GodFadeShader::Program;
GLuint GodFadeShader::uniform_tex;
GLuint GodFadeShader::uniform_col;
GLuint GodFadeShader::vao;
void GodFadeShader::init()
{
Program = LoadProgram(file_manager->getAsset("shaders/screenquad.vert").c_str(), file_manager->getAsset("shaders/godfade.frag").c_str());
uniform_tex = glGetUniformLocation(Program, "tex");
uniform_col = glGetUniformLocation(Program, "col");
vao = createVAO(Program);
}
void GodFadeShader::setUniforms(const SColor &col, unsigned TU_tex)
{
glUniform3f(uniform_col, col.getRed() / 255., col.getGreen() / 255., col.getBlue() / 255.);
glUniform1i(uniform_tex, TU_tex);
}
GLuint GodRayShader::Program;
GLuint GodRayShader::uniform_tex;
GLuint GodRayShader::uniform_sunpos;
GLuint GodRayShader::vao;
void GodRayShader::init()
{
Program = LoadProgram(file_manager->getAsset("shaders/screenquad.vert").c_str(), file_manager->getAsset("shaders/godray.frag").c_str());
uniform_tex = glGetUniformLocation(Program, "tex");
uniform_sunpos = glGetUniformLocation(Program, "sunpos");
vao = createVAO(Program);
}
void GodRayShader::setUniforms(const core::vector2df &sunpos, unsigned TU_tex)
{
glUniform2f(uniform_sunpos, sunpos.X, sunpos.Y);
glUniform1i(uniform_tex, TU_tex);
}
}
namespace UIShader

View File

@ -534,6 +534,28 @@ public:
static void setUniforms(float boost_amount, const core::vector2df &center, const core::vector2df &direction, float mask_radius, float max_tex_height, unsigned TU_cb);
};
class GodFadeShader
{
public:
static GLuint Program;
static GLuint uniform_tex, uniform_col;
static GLuint vao;
static void init();
static void setUniforms(const video::SColor &col, unsigned TU_tex);
};
class GodRayShader
{
public:
static GLuint Program;
static GLuint uniform_tex, uniform_sunpos;
static GLuint vao;
static void init();
static void setUniforms(const core::vector2df &sunpos, unsigned TU_tex);
};
}
namespace UIShader