[Bf-blender-cvs] [2b74af08eb3] temp-udim-images: Merge remote-tracking branch 'origin/blender2.8' into udim
Lukas Stockner
noreply at git.blender.org
Mon Jul 23 02:51:26 CEST 2018
Commit: 2b74af08eb32087c57720447627652311589ee8c
Author: Lukas Stockner
Date: Sun Jul 22 21:19:48 2018 +0200
Branches: temp-udim-images
https://developer.blender.org/rB2b74af08eb32087c57720447627652311589ee8c
Merge remote-tracking branch 'origin/blender2.8' into udim
===================================================================
===================================================================
diff --cc source/blender/blenloader/intern/versioning_280.c
index 21d35fe54f3,09a940436ef..487e0e8b9ec
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@@ -1600,27 -1599,27 +1600,49 @@@ void blo_do_versions_280(FileData *fd,
}
}
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "short", "type")) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ if (v3d->drawtype == OB_RENDER) {
+ v3d->drawtype = OB_SOLID;
+ }
+ v3d->shading.type = v3d->drawtype;
+ v3d->shading.prev_type = OB_SOLID;
+ }
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "SceneDisplay", "View3DShading", "shading")) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
+ BKE_screen_view3d_shading_init(&scene->display.shading);
+ }
+ }
++
+ if (!DNA_struct_elem_find(fd->filesdna, "Image", "short", "num_tiles")) {
+ for (Image *ima = bmain->image.first; ima; ima = ima->id.next) {
+ ImageTile *tile = MEM_callocN(sizeof(ImageTile), "Image Tiles");
+ tile->ok = 1;
+ BLI_addtail(&ima->tiles, tile);
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "SpaceImage", "int", "tile_grid_shape[2]")) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_IMAGE) {
+ SpaceImage *sima = (SpaceImage *)sl;
+ sima->tile_grid_shape[0] = 1;
+ sima->tile_grid_shape[1] = 1;
+ }
+ }
+ }
+ }
+ }
-
}
}
diff --cc source/blender/editors/screen/area.c
index 89a856052d3,1a63bc1cd53..ff12ed90621
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@@ -2741,12 -2741,12 +2741,12 @@@ void ED_region_grid_draw(ARegion *ar, f
float fac, blendfac;
int x1, y1, x2, y2;
- /* the image is located inside (0, 0), (1, 1) as set by view2d */
- UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x1, &y1);
- UI_view2d_view_to_region(&ar->v2d, 1.0f, 1.0f, &x2, &y2);
+ /* the image is located inside (x0, y0), (x0+1, y0+1) as set by view2d */
+ UI_view2d_view_to_region(&ar->v2d, x0, y0, &x1, &y1);
+ UI_view2d_view_to_region(&ar->v2d, x0+1.0f, y0+1.0f, &x2, &y2);
- Gwn_VertFormat *format = immVertexFormat();
- uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColorShade(TH_BACK, 20);
diff --cc source/blender/editors/space_image/image_draw.c
index 5528f9e0c3f,4cbe25462af..d69c4bcd88c
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@@ -605,13 -586,9 +605,13 @@@ void draw_image_sample_line(SpaceImage
immUniformArray4fv("colors", (float *)(float[][4]){{1.0f, 1.0f, 1.0f, 1.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}, 2);
immUniform1f("dash_width", 2.0f);
+ float co[2][2];
+ add_v2_v2v2(co[0], hist->co[0], hist->draw_offset);
+ add_v2_v2v2(co[1], hist->co[1], hist->draw_offset);
+
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
- immVertex2fv(shdr_dashed_pos, hist->co[0]);
- immVertex2fv(shdr_dashed_pos, hist->co[1]);
+ immVertex2fv(shdr_dashed_pos, co[0]);
+ immVertex2fv(shdr_dashed_pos, co[1]);
immEnd();
immUnbindProgram();
@@@ -656,75 -633,6 +656,75 @@@ static void draw_image_paint_helpers(co
}
}
+static void draw_udim_tile_grid(unsigned int pos_attr, unsigned int color_attr,
+ ARegion *ar, int x, int y,
+ float stepx, float stepy, const float color[3])
+{
+ float x1, y1;
+ UI_view2d_view_to_region_fl(&ar->v2d, x, y, &x1, &y1);
+ int gridpos[5][2] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}, {0, 0}};
+ for(int i = 0; i < 4; i++) {
+ immAttrib3fv(color_attr, color);
+ immVertex2f(pos_attr, x1 + gridpos[i][0]*stepx, y1 + gridpos[i][1]*stepy);
+ immAttrib3fv(color_attr, color);
+ immVertex2f(pos_attr, x1 + gridpos[i+1][0]*stepx, y1 + gridpos[i+1][1]*stepy);
+ }
+}
+
+static void draw_image_tiles(ARegion *ar, SpaceImage *sima, Image *ima)
+{
+ int num_tiles;
+ if (ima) {
+ num_tiles = BLI_listbase_count(&ima->tiles);
+ }
+ else {
+ num_tiles = sima->tile_grid_shape[0] * sima->tile_grid_shape[1];
+ }
+
+ if (num_tiles == 1) {
+ return;
+ }
+
+ float stepx = BLI_rcti_size_x(&ar->v2d.mask) / BLI_rctf_size_x(&ar->v2d.cur);
+ float stepy = BLI_rcti_size_y(&ar->v2d.mask) / BLI_rctf_size_y(&ar->v2d.cur);
+
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
++ GPUVertFormat *format = immVertexFormat();
++ unsigned int pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
++ unsigned color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+
+ immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
- immBegin(GWN_PRIM_LINES, 8*num_tiles);
++ immBegin(GPU_PRIM_LINES, 8*num_tiles);
+
+ float theme_color[3], selected_color[3];
+ UI_GetThemeColorShade3fv(TH_BACK, 60.0f, theme_color);
+ UI_GetThemeColor3fv(TH_FACE_SELECT, selected_color);
+
+ if (ima) {
+ LISTBASE_FOREACH(ImageTile*, tile, &ima->tiles) {
+ int x = tile->tile_number % 10;
+ int y = tile->tile_number / 10;
+ draw_udim_tile_grid(pos, color, ar, x, y, stepx, stepy, theme_color);
+ }
+ }
+ else {
+ for (int y = 0; y < sima->tile_grid_shape[1]; y++) {
+ for (int x = 0; x < sima->tile_grid_shape[0]; x++) {
+ draw_udim_tile_grid(pos, color, ar, x, y, stepx, stepy, theme_color);
+ }
+ }
+ }
+
+ if (num_tiles > 1) {
+ int cur_x = sima->curtile % 10, cur_y = sima->curtile / 10;
+ draw_udim_tile_grid(pos, color, ar, cur_x, cur_y, stepx, stepy, selected_color);
+ }
+
+ immEnd();
+ immUnbindProgram();
+
+ return;
+}
+
/* draw main image region */
void draw_image_main(const bContext *C, ARegion *ar)
diff --cc source/blender/gpu/shaders/gpu_shader_material.glsl
index 4e3709cc12a,464851bae21..704bbec8498
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@@ -1798,33 -1801,177 +1801,230 @@@ void node_tex_environment_empty(vec3 co
color = vec4(1.0, 0.0, 1.0, 1.0);
}
+ void node_tex_image_linear(vec3 co, sampler2D ima, out vec4 color, out float alpha)
+ {
+ color = texture(ima, co.xy);
+ alpha = color.a;
+ }
+
+ void node_tex_image_nearest(vec3 co, sampler2D ima, out vec4 color, out float alpha)
+ {
+ ivec2 pix = ivec2(co.xy * textureSize(ima, 0).xy);
+ color = texelFetch(ima, pix, 0);
+ alpha = color.a;
+ }
+
+ void node_tex_image_cubic(vec3 co, sampler2D ima, out vec4 color, out float alpha)
+ {
+ vec2 tex_size = vec2(textureSize(ima, 0).xy);
+
+ co.xy *= tex_size;
+ /* texel center */
+ vec2 tc = floor(co.xy - 0.5) + 0.5;
+ vec2 f = co.xy - tc;
+ vec2 f2 = f * f;
+ vec2 f3 = f2 * f;
+ /* Bspline coefs (optimized) */
+ vec2 w3 = f3 / 6.0;
+ vec2 w0 = -w3 + f2 * 0.5 - f * 0.5 + 1.0 / 6.0;
+ vec2 w1 = f3 * 0.5 - f2 * 1.0 + 2.0 / 3.0;
+ vec2 w2 = 1.0 - w0 - w1 - w3;
+
+ #if 1 /* Optimized version using 4 filtered tap. */
+ vec2 s0 = w0 + w1;
+ vec2 s1 = w2 + w3;
+
+ vec2 f0 = w1 / (w0 + w1);
+ vec2 f1 = w3 / (w2 + w3);
+
+ vec4 final_co;
+ final_co.xy = tc - 1.0 + f0;
+ final_co.zw = tc + 1.0 + f1;
+
+ final_co /= tex_size.xyxy;
+
+ color = texture(ima, final_co.xy) * s0.x * s0.y;
+ color += texture(ima, final_co.zy) * s1.x * s0.y;
+ color += texture(ima, final_co.xw) * s0.x * s1.y;
+ color += texture(ima, final_co.zw) * s1.x * s1.y;
+
+ #else /* Reference bruteforce 16 tap. */
+ color = texelFetch(ima, ivec2(tc + vec2(-1.0, -1.0)), 0) * w0.x * w0.y;
+ color += texelFetch(ima, ivec2(tc + vec2( 0.0, -1.0)), 0) * w1.x * w0.y;
+ color += texelFetch(ima, ivec2(tc + vec2( 1.0, -1.0)), 0) * w2.x * w0.y;
+ color += texelFetch(ima, ivec2(tc + vec2( 2.0, -1.0)), 0) * w3.x * w0.y;
+
+ color += texelFetch(ima, ivec2(tc + vec2(-1.0, 0.0)), 0) * w0.x * w1.y;
+ color += texelFetch(ima, ivec2(tc + vec2( 0.0, 0.0)), 0) * w1.x * w1.y;
+ color += texelFetch(ima, ivec2(tc + vec2( 1.0, 0.0)), 0) * w2.x * w1.y;
+ color += texelFetch(ima, ivec2(tc + vec2( 2.0, 0.0)), 0) * w3.x * w1.y;
+
+ color += texelFetch(ima, ivec2(tc + vec2(-1.0, 1.0)), 0) * w0.x * w2.y;
+ color += texelFetch(ima, ivec2(tc + vec2( 0.0, 1.0)), 0) * w1.x * w2.y;
+ color += texelFetch(ima, ivec2(tc + vec2( 1.0, 1.0)), 0) * w2.x * w2.y;
+ color += texelFetch(ima, ivec2(tc + vec2( 2.0, 1.0)), 0) * w3.x * w2.y;
+
+ color += texelFetch(ima, ivec2(tc + vec2(-1.0, 2.0)), 0) * w0.x * w3.y;
+ color += texelFetch(ima, ivec2(tc + vec2( 0.0, 2.0)), 0) * w1.x * w3.y;
+ color += texelFetch(ima, ivec2(tc + vec2( 1.0, 2.0)), 0) * w2.x * w3.y;
+ color += texelFetch(ima, ivec2(tc + vec2( 2.0, 2.0)), 0) * w3.x * w3.y;
+ #endif
+
+ alpha = color.a;
+ }
+
+ void node_tex_image_smart(vec3 co, sampler2D ima, out vec4 color, out float alpha)
+ {
+ /* use cubic for now */
+ node_tex_image_cubic(co, ima, color, alpha);
+ }
+
+void node_tex_image_tiled_map(vec3 co, out vec4 color, out vec3 map)
+{
+ float tx = floor(co.x);
+ float ty = floor(co.y);
+
+ if (tx < 0 || ty < 0 || tx >= 10)
+ map = vec3(0, 0, -1);
+ else
+ map = vec3(co.x - tx, co.y - ty, 10*ty + tx);
+
+ color = vec4(1.0, 0.0, 1.0, 1.0);
+}
+
- void node_tex_image_tile(vec3 map, float tile_id, sampler2D ima, vec4 in_color, out vec4 color, out float al
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list