Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2016-03-11 12:30:26 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2016-03-18 13:44:21 +0300
commitde80ecc8fbd41981d11605c89b9b10b31922ae2d (patch)
tree93a542f5ae1d9a095093c8c8015331d105a039e5
parentfc2f0a1a25d616a84829df848216501e5318d6dc (diff)
Fix T47753: World equirectangular regression
D1729 fixed 'View' projection but broke 'Equirectangular'. This commit also changes equirectangular projection to match Cycles and the viewport.
-rw-r--r--source/blender/render/intern/include/texture.h4
-rw-r--r--source/blender/render/intern/source/pixelshading.c11
-rw-r--r--source/blender/render/intern/source/render_texture.c14
3 files changed, 23 insertions, 6 deletions
diff --git a/source/blender/render/intern/include/texture.h b/source/blender/render/intern/include/texture.h
index 1141449f2ab..dfb491f46b0 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 f577333fcd7..97d6b060e0a 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 29d8f17a72b..d1f79203e56 100644
--- a/source/blender/render/intern/source/render_texture.c
+++ b/source/blender/render/intern/source/render_texture.c
@@ -3014,13 +3014,14 @@ 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;
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;
@@ -3031,6 +3032,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;
@@ -3092,8 +3095,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;
@@ -3119,6 +3122,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 */