Commit: 4aaf5baccf1b2f6bb0d618ab5005848431e168d0 Author: Alexander Romanov Date: Mon Jul 4 11:08:48 2016 +0300 Branches: master https://developer.blender.org/rB4aaf5baccf1b2f6bb0d618ab5005848431e168d0
Fix input for Texture node (envmap+world_space_shading) This patch fixes shortcoming of D2046. The original behavior without world_space_shading flag is that Texture node expects the reflected vector in view space. But with world_space_shading it should be in world space. In attached file you will see a simple material setup and a node material analogue. Simple material must have the same behavior regardless world_space_shading flag. {F318866} Alexander (Blend4Web Team) Reviewers: brecht Reviewed By: brecht Subscribers: campbellbarton, homyachetser, Evgeny_Rodygin, AlexKowel, yurikovelenov Differential Revision: https://developer.blender.org/D2072 =================================================================== M source/blender/render/intern/source/envmap.c M source/blender/render/intern/source/render_texture.c =================================================================== diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index b1afb86..d97e18d 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -52,6 +52,7 @@ #include "BKE_main.h" #include "BKE_image.h" /* BKE_imbuf_write */ #include "BKE_texture.h" +#include "BKE_scene.h" /* this module */ #include "render_types.h" @@ -737,21 +738,28 @@ int envmaptex(Tex *tex, const float texvec[3], float dxt[3], float dyt[3], int o /* rotate to envmap space, if object is set */ copy_v3_v3(vec, texvec); - if (env->object) mul_m3_v3(env->obimat, vec); - else mul_mat3_m4_v3(R.viewinv, vec); + if (env->object) { + mul_m3_v3(env->obimat, vec); + if (osatex) { + mul_m3_v3(env->obimat, dxt); + mul_m3_v3(env->obimat, dyt); + } + } + else { + if (!BKE_scene_use_world_space_shading(R.scene)) { + // texvec is in view space + mul_mat3_m4_v3(R.viewinv, vec); + if (osatex) { + mul_mat3_m4_v3(R.viewinv, dxt); + mul_mat3_m4_v3(R.viewinv, dyt); + } + } + } face = envcube_isect(env, vec, sco); ibuf = env->cube[face]; if (osatex) { - if (env->object) { - mul_m3_v3(env->obimat, dxt); - mul_m3_v3(env->obimat, dyt); - } - else { - mul_mat3_m4_v3(R.viewinv, dxt); - mul_mat3_m4_v3(R.viewinv, dyt); - } set_dxtdyt(dxts, dyts, dxt, dyt, face); imagewraposa(tex, NULL, ibuf, sco, dxts, dyts, texres, pool, skip_load_image); diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 530ebc0..dc22859 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -1720,6 +1720,21 @@ static void texco_mapping(ShadeInput *shi, Tex *tex, MTex *mtex, } else dxt[2]= dyt[2] = 0.f; } + + if (mtex->tex->type == TEX_ENVMAP) { + EnvMap *env = tex->env; + if (!env->object) { + // env->object is a view point for envmap rendering + // if it's not set, return the result depending on the world_space_shading flag + if (BKE_scene_use_world_space_shading(R.scene)) { + mul_mat3_m4_v3(R.viewinv, texvec); + if (shi->osatex) { + mul_mat3_m4_v3(R.viewinv, dxt); + mul_mat3_m4_v3(R.viewinv, dyt); + } + } + } + } } } _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs