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
This commit is contained in:
parent
fe44eacf78
commit
4aaf5baccf
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue