     }
     float att = clamp(1.0 - length(eyepos)/200.0, 0.0, 1.0);
     att *= att;
-    fragColor = c * max(intensity * diffuse + spec, ambient) * att;
+    fragColor = c * max(intensity * diffuse + spec, ambient) * vec4(color, 1.0) * att;
 }
 
 


		corners[i] = (m_mv * vec4(pos, 1.0)).xyz;
	}
	EMIT_QUAD(3, 2, 0, 1, vec3( 0.0,  0.0, -1.0)); // back
	EMIT_QUAD(6, 7, 5, 4, vec3( 0.0,  0.0,  1.0)); // front
	EMIT_QUAD(7, 3, 4, 0, vec3( 1.0,  0.0,  0.0)); // right
	EMIT_QUAD(2, 6, 1, 5, vec3(-1.0,  0.0,  0.0)); // left
	EMIT_QUAD(5, 4, 1, 0, vec3( 0.0,  1.0,  0.0)); // top
	EMIT_QUAD(2, 3, 6, 7, vec3( 0.0, -1.0,  0.0)); // bottom
    EndPrimitive();
}


	vec3( 1.0, -1.0,  1.0)  // right bottom near
);

#define EMIT_V(POS, UV, NORMAL, COL) \
	uv = UV; \
	normal = normalize(m_normal * NORMAL); \
	lightdir = lightpos - POS.xyz; \
	eyepos = -POS.xyz; \
	color = COL; \
	gl_Position = m_proj * vec4(POS, 1.0); \
	EmitVertex()

#define EMIT_QUAD(P1, P2, P3, P4, NORMAL, COL) \
	EMIT_V(corners[P1], vec2(0.0, 0.0), NORMAL, COL); \
	EMIT_V(corners[P2], vec2(1.0, 0.0), NORMAL, COL); \
	EMIT_V(corners[P3], vec2(0.0, 1.0), NORMAL, COL); \
	EMIT_V(corners[P4], vec2(1.0, 1.0), NORMAL, COL); \
	EndPrimitive()

void main()
