Fix T47753: World equirectangular regression

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

This commit also changes equirectangular projection to match Cycles and the viewport.
This commit is contained in:
Campbell Barton 2016-03-11 20:30:26 +11:00
parent b5b269ac11
commit c149b6b7d7
Notes: blender-bot 2023-02-14 11:35:46 +01:00
Referenced by issue #47753, [BI] 2.77 World texture has no reaction to parented camera rotation
3 changed files with 23 additions and 6 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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 */