diff options
Diffstat (limited to 'source/blender/gpu/intern/gpu_codegen.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_codegen.c | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index fb46b167f0f..c3f79bc9492 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -177,6 +177,9 @@ static void gpu_parse_functions_string(GHash *hash, char *code) } } + if (!type && gpu_str_prefix(code, "samplerCube")) { + type = GPU_TEXCUBE; + } if (!type && gpu_str_prefix(code, "sampler2DShadow")) { type = GPU_SHADOW2D; } @@ -505,8 +508,9 @@ static int codegen_print_uniforms_functions(DynStr *ds, ListBase *nodes) /* create exactly one sampler for each texture */ if (codegen_input_has_texture(input) && input->bindtex) { BLI_dynstr_appendf(ds, "uniform %s samp%d;\n", - (input->textype == GPU_TEX2D) ? "sampler2D" : "sampler2DShadow", - input->texid); + (input->textype == GPU_TEX2D) ? "sampler2D" : + (input->textype == GPU_TEXCUBE) ? "samplerCube" : "sampler2DShadow", + input->texid); } } else if (input->source == GPU_SOURCE_BUILTIN) { @@ -1015,7 +1019,7 @@ void GPU_pass_bind(GPUPass *pass, double time, int mipmap) /* create the textures */ for (input = inputs->first; input; input = input->next) { if (input->ima) - input->tex = GPU_texture_from_blender(input->ima, input->iuser, input->image_isdata, time, mipmap); + input->tex = GPU_texture_from_blender(input->ima, input->iuser, input->textarget, input->image_isdata, time, mipmap); else if (input->prv) input->tex = GPU_texture_from_preview(input->prv, mipmap); } @@ -1192,15 +1196,25 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, const GPUType input->type = GPU_VEC4; input->source = GPU_SOURCE_TEX; - if (link->image == GPU_NODE_LINK_IMAGE_PREVIEW) + if (link->image == GPU_NODE_LINK_IMAGE_PREVIEW) { input->prv = link->ptr1; - else { + input->textarget = GL_TEXTURE_2D; + input->textype = GPU_TEX2D; + } + else if (link->image == GPU_NODE_LINK_IMAGE_BLENDER) { input->ima = link->ptr1; input->iuser = link->ptr2; input->image_isdata = link->image_isdata; + input->textarget = GL_TEXTURE_2D; + input->textype = GPU_TEX2D; + } + else if (link->image == GPU_NODE_LINK_IMAGE_CUBE_MAP) { + input->ima = link->ptr1; + input->iuser = link->ptr2; + input->image_isdata = link->image_isdata; + input->textarget = GL_TEXTURE_CUBE_MAP; + input->textype = GPU_TEXCUBE; } - input->textarget = GL_TEXTURE_2D; - input->textype = GPU_TEX2D; MEM_freeN(link); } else if (link->attribtype) { @@ -1405,6 +1419,18 @@ GPUNodeLink *GPU_image(Image *ima, ImageUser *iuser, bool is_data) return link; } +GPUNodeLink *GPU_cube_map(Image *ima, ImageUser *iuser, bool is_data) +{ + GPUNodeLink *link = GPU_node_link_create(); + + link->image = GPU_NODE_LINK_IMAGE_CUBE_MAP; + link->ptr1 = ima; + link->ptr2 = iuser; + link->image_isdata = is_data; + + return link; +} + GPUNodeLink *GPU_image_preview(PreviewImage *prv) { GPUNodeLink *link = GPU_node_link_create(); |