[Bf-blender-cvs] [e5fd559] master: Fix T40566: Light instances disappears in rendered viewport (Blender Internal)

Sergey Sharybin noreply at git.blender.org
Tue Aug 12 21:55:50 CEST 2014


Commit: e5fd5599bc53183b3c919e9644ea6fd1eaa399e0
Author: Sergey Sharybin
Date:   Wed Aug 13 01:48:15 2014 +0600
Branches: master
https://developer.blender.org/rBe5fd5599bc53183b3c919e9644ea6fd1eaa399e0

Fix T40566: Light instances disappears in rendered viewport (Blender Internal)

This is just another issue caused by convertblender overwriting the object
matrix at the time of creating render object. What's even worse here is that
original matrix is not stored for the lamps, only lamp_matrix*view_matrix is
stored.

For sure we can combine lar->co and lar->mat back to mat4, multiply by the
inverse view matrix and get object matrix, but this is not suitable for the
viewport render because every viewport rotation will accumulate the error.

For now let's store worldspace lamp matrix in the LampRen structure and use
it when rotating the scene.

===================================================================

M	source/blender/render/intern/include/render_types.h
M	source/blender/render/intern/source/convertblender.c
M	source/blender/render/intern/source/envmap.c

===================================================================

diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h
index 536a2b8..b87b1e6 100644
--- a/source/blender/render/intern/include/render_types.h
+++ b/source/blender/render/intern/include/render_types.h
@@ -595,7 +595,9 @@ typedef struct LampRen {
 	float imat[3][3];
 	float spottexfac;
 	float sh_invcampos[3], sh_zfac;	/* sh_= spothalo */
-	
+
+	float lampmat[4][4];	/* worls space lamp matrix, used for scene rotation */
+
 	float mat[3][3];	/* 3x3 part from lampmat x viewmat */
 	float area[8][3], areasize;
 	
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
index c6ebe44..5514616 100644
--- a/source/blender/render/intern/source/convertblender.c
+++ b/source/blender/render/intern/source/convertblender.c
@@ -3650,6 +3650,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob)
 	mul_m4_m4m4(mat, re->viewmat, ob->obmat);
 	invert_m4_m4(ob->imat, mat);
 
+	copy_m4_m4(lar->lampmat, ob->obmat);
 	copy_m3_m4(lar->mat, mat);
 	copy_m3_m4(lar->imat, ob->imat);
 
diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c
index 28b2926..06be00a 100644
--- a/source/blender/render/intern/source/envmap.c
+++ b/source/blender/render/intern/source/envmap.c
@@ -329,9 +329,9 @@ void env_rotate_scene(Render *re, float mat[4][4], int do_rotate)
 		
 		/* copy from add_render_lamp */
 		if (do_rotate == 1)
-			mul_m4_m4m4(tmpmat, re->viewmat, go->ob->obmat);
+			mul_m4_m4m4(tmpmat, re->viewmat, lar->lampmat);
 		else
-			mul_m4_m4m4(tmpmat, re->viewmat_orig, go->ob->obmat);
+			mul_m4_m4m4(tmpmat, re->viewmat_orig, lar->lampmat);
 		invert_m4_m4(go->ob->imat, tmpmat);
 		
 		copy_m3_m4(lar->mat, tmpmat);




More information about the Bf-blender-cvs mailing list