[Bf-blender-cvs] [c149b6b] master: Fix T47753: World equirectangular regression

Campbell Barton noreply at git.blender.org
Fri Mar 11 10:44:49 CET 2016


Commit: c149b6b7d72f9d399a8e49160be8a2788b3f2c0e
Author: Campbell Barton
Date:   Fri Mar 11 20:30:26 2016 +1100
Branches: master
https://developer.blender.org/rBc149b6b7d72f9d399a8e49160be8a2788b3f2c0e

Fix T47753: World equirectangular regression

D1729 fixed 'View' projection but broke 'Equirectangular'.

This commit also changes equirectangular projection to match Cycles and the viewport.

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

M	source/blender/render/intern/include/texture.h
M	source/blender/render/intern/source/pixelshading.c
M	source/blender/render/intern/source/render_texture.c

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

diff --git a/source/blender/render/intern/include/texture.h b/source/blender/render/intern/include/texture.h
index 1141449..dfb491f 100644
--- a/source/blender/render/intern/include/texture.h
+++ b/source/blender/render/intern/include/texture.h
@@ -74,7 +74,9 @@ struct ImagePool;
 /* texture.h */
 
 void do_halo_tex(struct HaloRen *har, float xn, float yn, float col_r[4]);
-void do_sky_tex(const float rco[3], const float lo[3], const float dxyview[2], float hor[3], float zen[3], float *blend, int skyflag, short thread);
+void do_sky_tex(
+        const float rco[3], const float view[3], const float lo[3], const float dxyview[2],
+        float hor[3], float zen[3], float *blend, int skyflag, short thread);
 void do_material_tex(struct ShadeInput *shi, struct Render *re);
 void do_lamp_tex(LampRen *la, const float lavec[3], struct ShadeInput *shi, float col_r[3], int effect);
 void do_volume_tex(struct ShadeInput *shi, const float xyz[3], int mapto_flag, float col_r[3], float *val, struct Render *re);
diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c
index f577333..97d6b06 100644
--- a/source/blender/render/intern/source/pixelshading.c
+++ b/source/blender/render/intern/source/pixelshading.c
@@ -521,7 +521,16 @@ void shadeSkyView(float col_r[3], const float rco[3], const float view[3], const
 	/* Careful: SKYTEX and SKYBLEND are NOT mutually exclusive! If           */
 	/* SKYBLEND is active, the texture and color blend are added.           */
 	if (R.wrld.skytype & WO_SKYTEX) {
-		do_sky_tex(rco, view, dxyview, hor, zen, &blend, skyflag, thread);
+		float lo[3];
+		copy_v3_v3(lo, view);
+		if (R.wrld.skytype & WO_SKYREAL) {
+
+			mul_m3_v3(R.imat, lo);
+
+			SWAP(float, lo[1],  lo[2]);
+
+		}
+		do_sky_tex(rco, view, lo, dxyview, hor, zen, &blend, skyflag, thread);
 	}
 	
 	if (blend>1.0f) blend= 1.0f;
diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c
index 807686a..5cb5c34 100644
--- a/source/blender/render/intern/source/render_texture.c
+++ b/source/blender/render/intern/source/render_texture.c
@@ -3109,14 +3109,15 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float col_r[4])
 /* ------------------------------------------------------------------------- */
 
 /* hor and zen are RGB vectors, blend is 1 float, should all be initialized */
-void do_sky_tex(const float rco[3], const float lo[3], const float dxyview[2], float hor[3], float zen[3], float *blend, int skyflag, short thread)
+void do_sky_tex(
+        const float rco[3], const float view[3], const float lo[3], const float dxyview[2],
+        float hor[3], float zen[3], float *blend, int skyflag, short thread)
 {
 	const bool skip_load_image = (R.r.scemode & R_NO_IMAGE_LOAD) != 0;
 	const bool texnode_preview = (R.r.scemode & R_TEXNODE_PREVIEW) != 0;
 	MTex *mtex;
 	Tex *tex;
 	TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
-	const float *co;
 	float fact, stencilTin=1.0;
 	float tempvec[3], texvec[3], dxt[3], dyt[3];
 	int tex_nr, rgb= 0;
@@ -3127,6 +3128,8 @@ void do_sky_tex(const float rco[3], const float lo[3], const float dxyview[2], f
 	
 	for (tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) {
 		if (R.wrld.mtex[tex_nr]) {
+			const float *co;
+
 			mtex= R.wrld.mtex[tex_nr];
 			
 			tex= mtex->tex;
@@ -3188,8 +3191,8 @@ void do_sky_tex(const float rco[3], const float lo[3], const float dxyview[2], f
 				}
 				break;
 			case TEXCO_EQUIRECTMAP:
-				tempvec[0]= atan2f(lo[0], lo[2]) / (float)M_PI;
-				tempvec[1]= 1.0f - 2.0f*saacos(lo[1]) / (float)M_PI;
+				tempvec[0]= -atan2f(lo[2], lo[0]) / M_PI;
+				tempvec[1]=  atan2f(lo[1], hypot(lo[0], lo[2])) / M_PI_2;
 				tempvec[2]= 0.0f;
 				co= tempvec;
 				break;
@@ -3215,6 +3218,9 @@ void do_sky_tex(const float rco[3], const float lo[3], const float dxyview[2], f
 //				copy_v3_v3(shi->dygl, shi->dyco);
 //				mul_m3_v3(R.imat, shi->dyco);
 				break;
+			case TEXCO_VIEW:
+				co = view;
+				break;
 			}
 			
 			/* placement */




More information about the Bf-blender-cvs mailing list