diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-02-04 20:28:16 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-02-04 20:30:06 +0300 |
commit | d80f8baba5ffaaa277065e648ca812f2b4ec87cf (patch) | |
tree | 02af5a72fb01c461707ad96fdb37327e25f59adb /source/blender/gpu/intern/gpu_material.c | |
parent | 45071fa0f584572c409272c182c86493f2a29350 (diff) |
Support for cubemap reflections in the viewport
D1756 by @youle, uses existing texture mapping option.
Diffstat (limited to 'source/blender/gpu/intern/gpu_material.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_material.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 67f30be6a12..cc401dc63c4 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -1221,8 +1221,19 @@ static void do_material_tex(GPUShadeInput *shi) talpha = 0; - if (tex && tex->type == TEX_IMAGE && tex->ima) { - GPU_link(mat, "mtex_image", texco, GPU_image(tex->ima, &tex->iuser, false), &tin, &trgb); + if (tex && tex->ima && + ((tex->type == TEX_IMAGE) || + ((tex->type == TEX_ENVMAP) && (mtex->texco == TEXCO_REFL)))) + { + if (tex->type == TEX_IMAGE) { + GPU_link(mat, "mtex_image", texco, GPU_image(tex->ima, &tex->iuser, false), &tin, &trgb); + } + else { + GPU_link(mat, "mtex_cube_map_refl", + GPU_cube_map(tex->ima, &tex->iuser, false), shi->view, shi->vn, + GPU_builtin(GPU_INVERSE_VIEW_MATRIX), + GPU_builtin(GPU_VIEW_MATRIX), &tin, &trgb); + } rgbnor = TEX_RGB; talpha = ((tex->imaflag & TEX_USEALPHA) && tex->ima && (tex->ima->flag & IMA_IGNORE_ALPHA) == 0); @@ -1268,9 +1279,13 @@ static void do_material_tex(GPUShadeInput *shi) GPU_link(mat, "set_value_one", &tin); } - if (tex->type == TEX_IMAGE) - if (GPU_material_do_color_management(mat)) + if ((tex->type == TEX_IMAGE) || + ((tex->type == TEX_ENVMAP) && (mtex->texco == TEXCO_REFL))) + { + if (GPU_material_do_color_management(mat)) { GPU_link(mat, "srgb_to_linearrgb", tcol, &tcol); + } + } if (mtex->mapto & MAP_COL) { GPUNodeLink *colfac; |