# HG changeset patch # User John Tsiombikas # Date 1351209832 -10800 # Node ID d89b403f630b5ad17c8458a3c65570d4f59e358e # Parent f379c00eb07fdd7c61cf26e52a0b3ee7641935d3 added gamma correction (without dialing the lighting down yet) fixed the incorrect PointLight sphere radius diff -r f379c00eb07f -r d89b403f630b prototype/sdr/post.p.glsl --- a/prototype/sdr/post.p.glsl Tue Oct 23 14:57:08 2012 +0300 +++ b/prototype/sdr/post.p.glsl Fri Oct 26 03:03:52 2012 +0300 @@ -4,8 +4,10 @@ void main() { // lookup the render output color for this pixel - vec4 color = texture2D(fbtex, gl_TexCoord[0].st); - vec3 tc = (color.xyz * 15.0 + 0.5) / 16.0; + vec4 fbcolor = texture2D(fbtex, gl_TexCoord[0].st); + vec3 tc = (fbcolor.xyz * 15.0 + 0.5) / 16.0; // use that color as an index into the palette - gl_FragColor = vec4(texture3D(paltex, tc).xyz, color.a); + vec3 color = texture3D(paltex, tc).xyz; + // gamma-correction + gl_FragColor = vec4(pow(color, 1.0 / 2.2), fbcolor.a); } diff -r f379c00eb07f -r d89b403f630b prototype/src/light.cc --- a/prototype/src/light.cc Tue Oct 23 14:57:08 2012 +0300 +++ b/prototype/src/light.cc Fri Oct 26 03:03:52 2012 +0300 @@ -5,6 +5,7 @@ #include "timer.h" unsigned int PointLight::sph_vbo = 0; +int PointLight::subdiv = 8; Light::Light(const Color &col) : color(col) @@ -137,7 +138,11 @@ glMatrixMode(GL_MODELVIEW); glPushMatrix(); glTranslatef(pos.x, pos.y, pos.z); - glScalef(radius, radius, radius); + + // scale by the hypotenuse of the triangle with adjacent side: radius + // and angle M_PI / subdiv + float s = radius / cos(M_PI / subdiv); + glScalef(s, s, s); Light::draw(); @@ -168,8 +173,8 @@ printf("building sphere mesh for point light drawing\n"); - const static int udiv = 8; - const static int vdiv = 4; + const static int udiv = subdiv; + const static int vdiv = udiv / 2; int nquads = udiv * vdiv; num_faces = nquads * 2; diff -r f379c00eb07f -r d89b403f630b prototype/src/light.h --- a/prototype/src/light.h Tue Oct 23 14:57:08 2012 +0300 +++ b/prototype/src/light.h Fri Oct 26 03:03:52 2012 +0300 @@ -37,6 +37,7 @@ float radius; static unsigned int sph_vbo; + static int subdiv; bool create_mesh();