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:
authorAlexander Romanov <a.romanov@blend4web.com>2016-03-21 14:36:33 +0300
committerAlexander Romanov <a.romanov@blend4web.com>2016-03-21 14:36:33 +0300
commitda2dfaad1a5686b899fce4f309cc0b8d4a349f49 (patch)
treeb4743a29de90d0bbc9dea505bfcbb56cf7614619 /source/blender/gpu/intern/gpu_material.c
parent112300a982380c0b87cc1836d83143c902afad14 (diff)
Mirror influence of environment texture in Blender viewport
This patch implements Mirror influence for environment textures. Approach matches the one from BI. {F281871} See the video https://youtu.be/BskgCv6dcIE Example: {F281876} Alexander (Blend4Web Team) Reviewers: campbellbarton, merwin, brecht Reviewed By: brecht Subscribers: TwisterGE, blueprintrandom, youle, Evgeny_Rodygin, AlexKowel, yurikovelenov Differential Revision: https://developer.blender.org/D1786
Diffstat (limited to 'source/blender/gpu/intern/gpu_material.c')
-rw-r--r--source/blender/gpu/intern/gpu_material.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index bf9fb4cb718..fefc18d017e 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -1270,7 +1270,7 @@ static void do_material_tex(GPUShadeInput *shi)
}
/* mapping */
- if (mtex->mapto & (MAP_COL + MAP_COLSPEC)) {
+ if (mtex->mapto & (MAP_COL | MAP_COLSPEC | MAP_COLMIR)) {
/* stencil maps on the texture control slider, not texture intensity value */
if ((rgbnor & TEX_RGB) == 0) {
GPU_link(mat, "set_rgb", GPU_uniform(&mtex->r), &tcol);
@@ -1311,6 +1311,20 @@ static void do_material_tex(GPUShadeInput *shi)
texture_rgb_blend(mat, tcol, shi->specrgb, tin, colspecfac, mtex->blendtype, &shi->specrgb);
}
+
+ if(mtex->mapto & MAP_COLMIR) {
+ GPUNodeLink *colmirfac;
+
+ if (mtex->mirrfac == 1.0f) colmirfac = stencil;
+ else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->mirrfac), stencil, &colmirfac);
+
+ /* exception for envmap only */
+ if (tex->type == TEX_ENVMAP && mtex->blendtype == MTEX_BLEND) {
+ GPU_link(mat, "mtex_mirror", tcol, shi->refcol, tin, colmirfac, &shi->refcol);
+ }
+ else
+ texture_rgb_blend(mat, tcol, shi->mir, tin, colmirfac, mtex->blendtype, &shi->mir);
+ }
}
if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_NORM)) {
@@ -1603,6 +1617,8 @@ void GPU_shadeinput_set(GPUMaterial *mat, Material *ma, GPUShadeInput *shi)
GPU_link(mat, "set_rgb", GPU_dynamic_uniform(&ma->r, GPU_DYNAMIC_MAT_DIFFRGB, NULL), &shi->rgb);
GPU_link(mat, "set_rgb", GPU_dynamic_uniform(&ma->specr, GPU_DYNAMIC_MAT_SPECRGB, NULL), &shi->specrgb);
+ GPU_link(mat, "set_rgb", GPU_dynamic_uniform(&ma->mirr, GPU_DYNAMIC_MAT_MIR, NULL), &shi->mir);
+ GPU_link(mat, "set_rgba_zero", &shi->refcol);
GPU_link(mat, "shade_norm", GPU_builtin(GPU_VIEW_NORMAL), &shi->vn);
if (mat->alpha)
@@ -1723,6 +1739,9 @@ void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr)
if (ma->mode & MA_RAMP_COL) ramp_diffuse_result(shi, &shr->combined);
if (ma->mode & MA_RAMP_SPEC) ramp_spec_result(shi, &shr->spec);
+ if (GPU_link_changed(shi->refcol))
+ GPU_link(mat, "shade_add_mirror", shi->mir, shi->refcol, shr->combined, &shr->combined);
+
if (GPU_link_changed(shi->spec) || ma->spec != 0.0f)
GPU_link(mat, "shade_add", shr->combined, shr->spec, &shr->combined);
}