World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport. It supports: - "View", "AngMap" and "Equirectangular" types of mapping. - Different types of texture blending (according to BI world render). - Same color blending as when it lacked textures (but render via glsl). {F207734} {F207735} Example: {F275180} Original author: @valentin_b4w Regards, Alexander (Blend4Web Team). Reviewers: sergey, valentin_b4w, brecht, merwin Reviewed By: merwin Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin Projects: #rendering, #opengl_gfx, #bf_blender:_next Differential Revision: https://developer.blender.org/D1414
This commit is contained in:
@@ -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();
|
||||
|
Reference in New Issue
Block a user