Browse Source

tutorial: nicer blur and colour effect in the FBO tutorial.

legacy
Sam Hocevar sam 12 years ago
parent
commit
98756e277f
2 changed files with 18 additions and 9 deletions
  1. +7
    -4
      tutorial/08_fbo.cpp
  2. +11
    -5
      tutorial/08_fbo.lolfx

+ 7
- 4
tutorial/08_fbo.cpp View File

@@ -47,9 +47,12 @@ public:
m_hotspot = 0.4f * vec3(lol::cos(m_time * 2.f) + lol::cos(m_time * 3.3f), m_hotspot = 0.4f * vec3(lol::cos(m_time * 2.f) + lol::cos(m_time * 3.3f),
lol::sin(m_time * 4.4f) + lol::sin(m_time * 3.2f), lol::sin(m_time * 4.4f) + lol::sin(m_time * 3.2f),
lol::sin(m_time * 5.f)); lol::sin(m_time * 5.f));
m_color = 0.25f * vec3(3.f + lol::sin(m_time * 4.5f + 1.f),
3.f + lol::sin(m_time * 2.8f + 1.3f),
3.f + lol::sin(m_time * 3.7f));
m_color = 0.25f * vec3(1.1f + lol::sin(m_time * 1.5f + 1.f),
1.1f + lol::sin(m_time * 1.8f + 1.3f),
1.1f + lol::sin(m_time * 1.7f));
/* Saturate dot color */
float x = std::max(m_color.x, std::max(m_color.y, m_color.z));
m_color /= x;
} }


virtual void TickDraw(float seconds) virtual void TickDraw(float seconds)
@@ -60,9 +63,9 @@ public:
{ {
m_shader = Shader::Create(lolfx_08_fbo); m_shader = Shader::Create(lolfx_08_fbo);
m_coord = m_shader->GetAttribLocation("in_Position", VertexUsage::Position, 0); m_coord = m_shader->GetAttribLocation("in_Position", VertexUsage::Position, 0);
m_uni_flag = m_shader->GetUniformLocation("in_Flag");
m_uni_point = m_shader->GetUniformLocation("in_Point"); m_uni_point = m_shader->GetUniformLocation("in_Point");
m_uni_color = m_shader->GetUniformLocation("in_Color"); m_uni_color = m_shader->GetUniformLocation("in_Color");
m_uni_flag = m_shader->GetUniformLocation("in_Flag");
m_uni_texture = m_shader->GetUniformLocation("in_Texture"); m_uni_texture = m_shader->GetUniformLocation("in_Texture");


m_vdecl = new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position)); m_vdecl = new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position));


+ 11
- 5
tutorial/08_fbo.lolfx View File

@@ -31,11 +31,17 @@ void main(void)
{ {
if (in_Flag == 0.0) if (in_Flag == 0.0)
{ {
float s = 4.0 + 4.0 * in_Point.z;
vec2 p = pass_Position - in_Point.xy * 0.8;
float f = clamp(1.0 - dot(s * p, s * p), 0.0, 1.0);
f = sqrt(f);
gl_FragColor = vec4(f * in_Color, f + 0.1);
float tc = 0.0, ta = 0.0;
{
float s = 4.0 + 3.0 * in_Point.z;
vec2 p = pass_Position - in_Point.xy * 0.8;
float t = clamp(1.2 - dot(s * p, s * p), 0.0, 1.0);
float u = t * t;
tc += 3.0 * t * t - 2.0 * t * t * t;
ta += 3.0 * u * u - 2.0 * u * u * u;
}

gl_FragColor = vec4(tc * in_Color, ta + 0.1);
} }
else else
{ {


Loading…
Cancel
Save