Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/overlay_grid.c
| Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | void OVERLAY_grid_init(OVERLAY_Data *vedata) | ||||
| OVERLAY_ShadingData *shd = &pd->shdata; | OVERLAY_ShadingData *shd = &pd->shdata; | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| shd->grid_flag = 0; | shd->grid_flag = 0; | ||||
| shd->zneg_flag = 0; | shd->zneg_flag = 0; | ||||
| shd->zpos_flag = 0; | shd->zpos_flag = 0; | ||||
| shd->grid_line_size = max_ff(0.0f, U.pixelsize - 1.0f) * 0.5f; | shd->grid_line_size = max_ff(0.0f, U.pixelsize - 1.0f) * 0.5f; | ||||
| if (pd->is_image_editor) { | if (pd->space_type == SPACE_IMAGE) { | ||||
| SpaceImage *sima = (SpaceImage *)draw_ctx->space_data; | SpaceImage *sima = (SpaceImage *)draw_ctx->space_data; | ||||
| shd->grid_flag = ED_space_image_has_buffer(sima) ? 0 : PLANE_IMAGE | SHOW_GRID; | shd->grid_flag = ED_space_image_has_buffer(sima) ? 0 : PLANE_IMAGE | SHOW_GRID; | ||||
| shd->grid_distance = 1.0f; | shd->grid_distance = 1.0f; | ||||
| copy_v3_fl3( | copy_v3_fl3( | ||||
| shd->grid_size, (float)sima->tile_grid_shape[0], (float)sima->tile_grid_shape[1], 1.0f); | shd->grid_size, (float)sima->tile_grid_shape[0], (float)sima->tile_grid_shape[1], 1.0f); | ||||
| for (int step = 0; step < 8; step++) { | for (int step = 0; step < 8; step++) { | ||||
| shd->grid_steps[step] = powf(4, step) * (1.0f / 16.0f); | shd->grid_steps[step] = powf(4, step) * (1.0f / 16.0f); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | void OVERLAY_grid_cache_init(OVERLAY_Data *vedata) | ||||
| } | } | ||||
| DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA; | DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA; | ||||
| DRW_PASS_CREATE(psl->grid_ps, state); | DRW_PASS_CREATE(psl->grid_ps, state); | ||||
| DRWShadingGroup *grp; | DRWShadingGroup *grp; | ||||
| GPUShader *sh; | GPUShader *sh; | ||||
| struct GPUBatch *geom = DRW_cache_grid_get(); | struct GPUBatch *geom = DRW_cache_grid_get(); | ||||
| if (pd->is_image_editor) { | if (pd->space_type == SPACE_IMAGE) { | ||||
| float mat[4][4]; | float mat[4][4]; | ||||
| /* add quad background */ | /* add quad background */ | ||||
| sh = OVERLAY_shader_grid_image(); | sh = OVERLAY_shader_grid_image(); | ||||
| grp = DRW_shgroup_create(sh, psl->grid_ps); | grp = DRW_shgroup_create(sh, psl->grid_ps); | ||||
| float color_back[4]; | float color_back[4]; | ||||
| interp_v4_v4v4(color_back, G_draw.block.colorBackground, G_draw.block.colorGrid, 0.5); | interp_v4_v4v4(color_back, G_draw.block.colorBackground, G_draw.block.colorGrid, 0.5); | ||||
| DRW_shgroup_uniform_vec4_copy(grp, "color", color_back); | DRW_shgroup_uniform_vec4_copy(grp, "color", color_back); | ||||
| Show All 33 Lines | void OVERLAY_grid_cache_init(OVERLAY_Data *vedata) | ||||
| DRW_shgroup_uniform_int(grp, "gridFlag", &shd->zpos_flag, 1); | DRW_shgroup_uniform_int(grp, "gridFlag", &shd->zpos_flag, 1); | ||||
| DRW_shgroup_uniform_vec3(grp, "planeAxes", shd->zplane_axes, 1); | DRW_shgroup_uniform_vec3(grp, "planeAxes", shd->zplane_axes, 1); | ||||
| DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); | DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); | ||||
| DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth); | DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth); | ||||
| if (shd->zpos_flag) { | if (shd->zpos_flag) { | ||||
| DRW_shgroup_call(grp, geom, NULL); | DRW_shgroup_call(grp, geom, NULL); | ||||
| } | } | ||||
| if (pd->is_image_editor) { | if (pd->space_type == SPACE_IMAGE) { | ||||
| float theme_color[4]; | float theme_color[4]; | ||||
| UI_GetThemeColorShade4fv(TH_BACK, 60, theme_color); | UI_GetThemeColorShade4fv(TH_BACK, 60, theme_color); | ||||
| srgb_to_linearrgb_v4(theme_color, theme_color); | srgb_to_linearrgb_v4(theme_color, theme_color); | ||||
| float mat[4][4]; | float mat[4][4]; | ||||
| /* add wire border */ | /* add wire border */ | ||||
| sh = OVERLAY_shader_grid_image(); | sh = OVERLAY_shader_grid_image(); | ||||
| grp = DRW_shgroup_create(sh, psl->grid_ps); | grp = DRW_shgroup_create(sh, psl->grid_ps); | ||||
| Show All 20 Lines | |||||