Give smoke quads random rotation to reduce artifacts from repitition

This commit is contained in:
bkuker 2013-11-27 19:36:43 -05:00
parent 857f978504
commit 9069277573
2 changed files with 3 additions and 2 deletions

View File

@ -4,7 +4,7 @@ uniform sampler2D uSmoke;
void main(void) void main(void)
{ {
vec3 normal = 2.0 * texture2D (uNormal, gl_TexCoord[0].st).rgb - 1.0; vec3 normal = 2.0 * texture2D (uNormal, gl_TexCoord[0].st).rgb - 1.0;
normal = normalize (normal); normal = normalize (gl_NormalMatrix * normal);
float lamberFactor = max (dot (gl_LightSource[1].position.xyz, normal), 0.0) ; float lamberFactor = max (dot (gl_LightSource[1].position.xyz, normal), 0.0) ;

View File

@ -308,7 +308,8 @@ public final class FlameRenderer {
mvmatrix[1] = mvmatrix[2] = mvmatrix[4] = mvmatrix[6] = mvmatrix[8] = mvmatrix[9] = 0; mvmatrix[1] = mvmatrix[2] = mvmatrix[4] = mvmatrix[6] = mvmatrix[8] = mvmatrix[9] = 0;
gl.glLoadMatrixd(mvmatrix, 0); gl.glLoadMatrixd(mvmatrix, 0);
//TODO Add a random rotation to prevent artifacts from texture. //Add a random rotation to prevent artifacts from texture.
gl.glRotatef(r.nextFloat()*45f, 0,0,1);
gl.glBegin(GL.GL_TRIANGLE_FAN); gl.glBegin(GL.GL_TRIANGLE_FAN);
float d = radius.f(z) * scale * 2; float d = radius.f(z) * scale * 2;