Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/modes/paint_texture_mode.c
| Show First 20 Lines • Show All 188 Lines • ▼ Show 20 Lines | static void PAINT_TEXTURE_cache_init(void *vedata) | ||||
| if (!stl->g_data) { | if (!stl->g_data) { | ||||
| /* Alloc transient pointers */ | /* Alloc transient pointers */ | ||||
| stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__); | stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__); | ||||
| stl->g_data->shgroup_image_array = NULL; | stl->g_data->shgroup_image_array = NULL; | ||||
| } | } | ||||
| { | { | ||||
| /* Create a pass */ | /* Create a pass */ | ||||
| DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND; | DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_MULTIPLY; | ||||
| psl->image_faces = DRW_pass_create("Image Color Pass", state); | psl->image_faces = DRW_pass_create("Image Color Pass", state); | ||||
| stl->g_data->shgroup_fallback = DRW_shgroup_create(e_data.fallback_sh, psl->image_faces); | stl->g_data->shgroup_fallback = DRW_shgroup_create(e_data.fallback_sh, psl->image_faces); | ||||
| /* Uniforms need a pointer to it's value so be sure it's accessible at | /* Uniforms need a pointer to it's value so be sure it's accessible at | ||||
| * any given time (i.e. use static vars) */ | * any given time (i.e. use static vars) */ | ||||
| static float color[4] = {1.0f, 0.0f, 1.0f, 1.0}; | static float color[4] = {1.0f, 0.0f, 1.0f, 1.0}; | ||||
| DRW_shgroup_uniform_vec4(stl->g_data->shgroup_fallback, "color", color, 1); | DRW_shgroup_uniform_vec4(stl->g_data->shgroup_fallback, "color", color, 1); | ||||
| Show All 15 Lines | if (ob && ob->type == OB_MESH) { | ||||
| Material *ma = give_current_material(ob, i + 1); | Material *ma = give_current_material(ob, i + 1); | ||||
| Image *ima = (ma && ma->texpaintslot) ? ma->texpaintslot[ma->paint_active_slot].ima : NULL; | Image *ima = (ma && ma->texpaintslot) ? ma->texpaintslot[ma->paint_active_slot].ima : NULL; | ||||
| GPUTexture *tex = ima ? | GPUTexture *tex = ima ? | ||||
| GPU_texture_from_blender(ima, NULL, GL_TEXTURE_2D, false, 0.0f) : NULL; | GPU_texture_from_blender(ima, NULL, GL_TEXTURE_2D, false, 0.0f) : NULL; | ||||
| if (tex) { | if (tex) { | ||||
| DRWShadingGroup *grp = DRW_shgroup_create(e_data.image_sh, psl->image_faces); | DRWShadingGroup *grp = DRW_shgroup_create(e_data.image_sh, psl->image_faces); | ||||
| DRW_shgroup_uniform_texture(grp, "image", tex); | DRW_shgroup_uniform_texture(grp, "image", tex); | ||||
| DRW_shgroup_uniform_float(grp, "alpha", &draw_ctx->v3d->overlay.texture_paint_mode_opacity, 1); | DRW_shgroup_uniform_float_copy(grp, "white_factor", 1.0f - draw_ctx->v3d->overlay.texture_paint_mode_opacity); | ||||
| DRW_shgroup_uniform_block(grp, "globalsBlock", globals_ubo); | DRW_shgroup_uniform_block(grp, "globalsBlock", globals_ubo); | ||||
| stl->g_data->shgroup_image_array[i] = grp; | stl->g_data->shgroup_image_array[i] = grp; | ||||
| } | } | ||||
| else { | else { | ||||
| stl->g_data->shgroup_image_array[i] = NULL; | stl->g_data->shgroup_image_array[i] = NULL; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| Image *ima = scene->toolsettings->imapaint.canvas; | Image *ima = scene->toolsettings->imapaint.canvas; | ||||
| GPUTexture *tex = ima ? | GPUTexture *tex = ima ? | ||||
| GPU_texture_from_blender(ima, NULL, GL_TEXTURE_2D, false, 0.0f) : NULL; | GPU_texture_from_blender(ima, NULL, GL_TEXTURE_2D, false, 0.0f) : NULL; | ||||
| if (tex) { | if (tex) { | ||||
| DRWShadingGroup *grp = DRW_shgroup_create(e_data.image_sh, psl->image_faces); | DRWShadingGroup *grp = DRW_shgroup_create(e_data.image_sh, psl->image_faces); | ||||
| DRW_shgroup_uniform_texture(grp, "image", tex); | DRW_shgroup_uniform_texture(grp, "image", tex); | ||||
| DRW_shgroup_uniform_float(grp, "alpha", &draw_ctx->v3d->overlay.texture_paint_mode_opacity, 1); | DRW_shgroup_uniform_float_copy(grp, "white_factor", 1.0f - draw_ctx->v3d->overlay.texture_paint_mode_opacity); | ||||
| DRW_shgroup_uniform_block(grp, "globalsBlock", globals_ubo); | DRW_shgroup_uniform_block(grp, "globalsBlock", globals_ubo); | ||||
| stl->g_data->shgroup_image_array[0] = grp; | stl->g_data->shgroup_image_array[0] = grp; | ||||
| } | } | ||||
| else { | else { | ||||
| stl->g_data->shgroup_image_array[0] = NULL; | stl->g_data->shgroup_image_array[0] = NULL; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 147 Lines • Show Last 20 Lines | |||||