[Bf-blender-cvs] [0e3ba7cf41] clay-engine: More lamp work
Commit: 0e3ba7cf4150a842a65819ff7d60a3abdaf75a55 Author: Clément Foucault Date: Thu Feb 2 22:19:23 2017 +0100 Branches: clay-engine https://developer.blender.org/rB0e3ba7cf4150a842a65819ff7d60a3abdaf75a55 More lamp work === M source/blender/draw/intern/draw_mode_pass.c === diff --git a/source/blender/draw/intern/draw_mode_pass.c b/source/blender/draw/intern/draw_mode_pass.c index 391639e57d..507872a4fe 100644 --- a/source/blender/draw/intern/draw_mode_pass.c +++ b/source/blender/draw/intern/draw_mode_pass.c @@ -96,17 +96,27 @@ static DRWShadingGroup *arrows_group_active; /* Lamps */ static DRWShadingGroup *lamp_center; +static DRWShadingGroup *lamp_center_group; static DRWShadingGroup *lamp_groundpoint; static DRWShadingGroup *lamp_groundline; -static DRWShadingGroup *lamp_circle_wire; +static DRWShadingGroup *lamp_circle; static DRWShadingGroup *lamp_circle_active; static DRWShadingGroup *lamp_circle_select; -static DRWShadingGroup *lamp_circle_shadow_wire; +static DRWShadingGroup *lamp_circle_transform; +static DRWShadingGroup *lamp_circle_group; +static DRWShadingGroup *lamp_circle_group_active; +static DRWShadingGroup *lamp_circle_shadow; static DRWShadingGroup *lamp_circle_shadow_active; static DRWShadingGroup *lamp_circle_shadow_select; -static DRWShadingGroup *lamp_sunrays_wire; +static DRWShadingGroup *lamp_circle_shadow_transform; +static DRWShadingGroup *lamp_circle_shadow_group; +static DRWShadingGroup *lamp_circle_shadow_group_active; +static DRWShadingGroup *lamp_sunrays; static DRWShadingGroup *lamp_sunrays_active; static DRWShadingGroup *lamp_sunrays_select; +static DRWShadingGroup *lamp_sunrays_transform; +static DRWShadingGroup *lamp_sunrays_group; +static DRWShadingGroup *lamp_sunrays_group_active; /* Helpers */ static DRWShadingGroup *relationship_lines; @@ -301,15 +311,25 @@ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPa * for now we create 3 times the same VBO with only lamp center coordinates * but ideally we would only create it once */ lamp_center = shgroup_dynpoints_uniform_color(*non_meshes, colorLampNoAlpha, ); - lamp_circle_wire = shgroup_lamp(*non_meshes, colorLampNoAlpha, ); + lamp_center_group = shgroup_dynpoints_uniform_color(*non_meshes, colorGroup, ); + lamp_circle = shgroup_lamp(*non_meshes, colorLampNoAlpha, ); lamp_circle_active = shgroup_lamp(*non_meshes, colorActive, ); lamp_circle_select = shgroup_lamp(*non_meshes, colorSelect, ); - lamp_circle_shadow_wire = shgroup_lamp(*non_meshes, colorLampNoAlpha, ); + lamp_circle_transform = shgroup_lamp(*non_meshes, colorTransform, ); + lamp_circle_group = shgroup_lamp(*non_meshes, colorGroup, ); + lamp_circle_group_active = shgroup_lamp(*non_meshes, colorGroupActive, ); + lamp_circle_shadow = shgroup_lamp(*non_meshes, colorLampNoAlpha, ); lamp_circle_shadow_active = shgroup_lamp(*non_meshes, colorActive, ); lamp_circle_shadow_select = shgroup_lamp(*non_meshes, colorSelect, ); - lamp_sunrays_wire = shgroup_lamp(*non_meshes, colorLampNoAlpha, ); + lamp_circle_shadow_transform = shgroup_lamp(*non_meshes, colorTransform, ); + lamp_circle_shadow_group = shgroup_lamp(*non_meshes, colorGroup, ); + lamp_circle_shadow_group_active = shgroup_lamp(*non_meshes, colorGroupActive, ); + lamp_sunrays = shgroup_lamp(*non_meshes, colorLampNoAlpha, ); lamp_sunrays_active = shgroup_lamp(*non_meshes, colorActive, ); lamp_sunrays_select = shgroup_lamp(*non_meshes, colorSelect, ); + lamp_sunrays_transform = shgroup_lamp(*non_meshes, colorTransform, ); + lamp_sunrays_group = shgroup_lamp(*non_meshes, colorGroup, ); + lamp_sunrays_group_active = shgroup_lamp(*non_meshes, colorGroupActive, ); lamp_groundline = shgroup_groundlines_uniform_color(*non_meshes, colorLamp); lamp_groundpoint = shgroup_groundpoints_uniform_color(*non_meshes, colorLamp); @@ -514,43 +534,69 @@ void DRW_shgroup_wire_outline(DRWPass *wire_outline, Object *ob, static void DRW_draw_lamp(Object *ob) { - struct Batch *geom = DRW_cache_single_vert_get(); + struct Batch *center = DRW_cache_single_vert_get(); struct Batch *lamp = DRW_cache_lamp_get(); struct Batch *sunrays = DRW_cache_lamp_sunrays_get(); Lamp *la = ob->data; + int theme_id = draw_object_wire_theme(ob); - /* Don't draw the center if it's selected */ - if ((ob->base_flag & BASE_SELECTED) == 0) { - DRW_shgroup_call_add(lamp_ce
[Bf-blender-cvs] [e148661d8d] clay-engine: Use vec2 for screen space stuff
Commit: e148661d8d8fa458b2c8198bb396b6c5f53510b3 Author: Clément Foucault Date: Thu Feb 2 21:44:14 2017 +0100 Branches: clay-engine https://developer.blender.org/rBe148661d8d8fa458b2c8198bb396b6c5f53510b3 Use vec2 for screen space stuff === M source/blender/draw/intern/draw_cache.c M source/blender/gpu/shaders/gpu_shader_3D_lamp_vert.glsl === diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index 2f571ec7f3..1255a083b8 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -412,13 +412,13 @@ Batch *DRW_cache_lamp_get(void) { #define NSEGMENTS 8 if (!SHC.drw_lamp) { - float v[3] = {0.0f, 0.0f, 0.0f}; + float v[2]; /* Position Only 3D format */ static VertexFormat format = { 0 }; static unsigned pos_id; if (format.attrib_ct == 0) { - pos_id = add_attrib(, "pos", GL_FLOAT, 3, KEEP_FLOAT); + pos_id = add_attrib(, "pos", GL_FLOAT, 2, KEEP_FLOAT); } VertexBuffer *vbo = VertexBuffer_create_with_format(); @@ -427,12 +427,10 @@ Batch *DRW_cache_lamp_get(void) for (int a = 0; a < NSEGMENTS; a++) { v[0] = sinf((2.0f * M_PI * a) / ((float)NSEGMENTS)); v[1] = cosf((2.0f * M_PI * a) / ((float)NSEGMENTS)); - v[2] = 0.0f; setAttrib(vbo, pos_id, a * 2, v); v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)NSEGMENTS)); v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)NSEGMENTS)); - v[2] = 0.0f; setAttrib(vbo, pos_id, a * 2 + 1, v); } @@ -445,13 +443,13 @@ Batch *DRW_cache_lamp_get(void) Batch *DRW_cache_lamp_sunrays_get(void) { if (!SHC.drw_lamp_sunrays) { - float v[3], v1[3], v2[3]; + float v[2], v1[2], v2[2]; /* Position Only 3D format */ static VertexFormat format = { 0 }; static unsigned pos_id; if (format.attrib_ct == 0) { - pos_id = add_attrib(, "pos", GL_FLOAT, 3, KEEP_FLOAT); + pos_id = add_attrib(, "pos", GL_FLOAT, 2, KEEP_FLOAT); } VertexBuffer *vbo = VertexBuffer_create_with_format(); @@ -460,10 +458,9 @@ Batch *DRW_cache_lamp_sunrays_get(void) for (int a = 0; a < 8; a++) { v[0] = sinf((2.0f * M_PI * a) / 8.0f); v[1] = cosf((2.0f * M_PI * a) / 8.0f); - v[2] = 0.0f; - mul_v3_v3fl(v1, v, 1.2f); - mul_v3_v3fl(v2, v, 2.5f); + mul_v2_v2fl(v1, v, 1.2f); + mul_v2_v2fl(v2, v, 2.5f); setAttrib(vbo, pos_id, a * 2, v1); setAttrib(vbo, pos_id, a * 2 + 1, v2); diff --git a/source/blender/gpu/shaders/gpu_shader_3D_lamp_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_lamp_vert.glsl index 8d091e9f43..dbc683ef42 100644 --- a/source/blender/gpu/shaders/gpu_shader_3D_lamp_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_3D_lamp_vert.glsl @@ -4,7 +4,7 @@ uniform vec3 screen_vecs[2]; uniform float size; uniform float pixel_size; -in vec3 pos; +in vec2 pos; in mat4 InstanceModelMatrix; #define lamp_pos InstanceModelMatrix[3].xyz ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6f1bdaab9d] clay-engine: Lamp sunrays and shadow circles
Commit: 6f1bdaab9dfbbe4d12558f8f22be8c7efabe57df Author: Clément Foucault Date: Thu Feb 2 21:39:58 2017 +0100 Branches: clay-engine https://developer.blender.org/rB6f1bdaab9dfbbe4d12558f8f22be8c7efabe57df Lamp sunrays and shadow circles === M source/blender/draw/intern/DRW_render.h M source/blender/draw/intern/draw_cache.c M source/blender/draw/intern/draw_cache.h M source/blender/draw/intern/draw_mode_pass.c === diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index ac57a05dd1..9945628653 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -40,6 +40,7 @@ #include "BLT_translation.h" #include "DNA_object_types.h" +#include "DNA_lamp_types.h" #include "DNA_material_types.h" #include "DNA_scene_types.h" diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index b41c232847..2f571ec7f3 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -49,6 +49,7 @@ static struct DRWShapeCache{ Batch *drw_empty_cone; Batch *drw_arrows; Batch *drw_lamp; + Batch *drw_lamp_sunrays; } SHC = {NULL}; void DRW_shape_cache_free(void) @@ -75,6 +76,8 @@ void DRW_shape_cache_free(void) Batch_discard_all(SHC.drw_arrows); if (SHC.drw_lamp) Batch_discard_all(SHC.drw_lamp); + if (SHC.drw_lamp_sunrays) + Batch_discard_all(SHC.drw_lamp_sunrays); } /* Quads */ @@ -439,6 +442,39 @@ Batch *DRW_cache_lamp_get(void) #undef NSEGMENTS } +Batch *DRW_cache_lamp_sunrays_get(void) +{ + if (!SHC.drw_lamp_sunrays) { + float v[3], v1[3], v2[3]; + + /* Position Only 3D format */ + static VertexFormat format = { 0 }; + static unsigned pos_id; + if (format.attrib_ct == 0) { + pos_id = add_attrib(, "pos", GL_FLOAT, 3, KEEP_FLOAT); + } + + VertexBuffer *vbo = VertexBuffer_create_with_format(); + VertexBuffer_allocate_data(vbo, 16); + + for (int a = 0; a < 8; a++) { + v[0] = sinf((2.0f * M_PI * a) / 8.0f); + v[1] = cosf((2.0f * M_PI * a) / 8.0f); + v[2] = 0.0f; + + mul_v3_v3fl(v1, v, 1.2f); + mul_v3_v3fl(v2, v, 2.5f); + + setAttrib(vbo, pos_id, a * 2, v1); + setAttrib(vbo, pos_id, a * 2 + 1, v2); + } + + SHC.drw_lamp_sunrays = Batch_create(GL_LINES, vbo, NULL); + } + return SHC.drw_lamp_sunrays; +} + + /* Object Center */ Batch *DRW_cache_single_vert_get(void) { diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h index 881fc2b529..c53f3d88af 100644 --- a/source/blender/draw/intern/draw_cache.h +++ b/source/blender/draw/intern/draw_cache.h @@ -46,6 +46,7 @@ struct Batch *DRW_cache_arrows_get(void); /* Lamps */ struct Batch *DRW_cache_lamp_get(void); +struct Batch *DRW_cache_lamp_sunrays_get(void); /* Meshes */ struct Batch *DRW_cache_wire_overlay_get(struct Object *ob); diff --git a/source/blender/draw/intern/draw_mode_pass.c b/source/blender/draw/intern/draw_mode_pass.c index 813fb2b38a..391639e57d 100644 --- a/source/blender/draw/intern/draw_mode_pass.c +++ b/source/blender/draw/intern/draw_mode_pass.c @@ -101,6 +101,12 @@ static DRWShadingGroup *lamp_groundline; static DRWShadingGroup *lamp_circle_wire; static DRWShadingGroup *lamp_circle_active; static DRWShadingGroup *lamp_circle_select; +static DRWShadingGroup *lamp_circle_shadow_wire; +static DRWShadingGroup *lamp_circle_shadow_active; +static DRWShadingGroup *lamp_circle_shadow_select; +static DRWShadingGroup *lamp_sunrays_wire; +static DRWShadingGroup *lamp_sunrays_active; +static DRWShadingGroup *lamp_sunrays_select; /* Helpers */ static DRWShadingGroup *relationship_lines; @@ -167,7 +173,7 @@ static DRWShadingGroup *shgroup_groundpoints_uniform_color(DRWPass *pass, float return grp; } -static DRWShadingGroup *shgroup_lampcircle(DRWPass *pass, float color[4], float *size) +static DRWShadingGroup *shgroup_lamp(DRWPass *pass, float color[4], float *size) { GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_LAMP_COMMON); @@ -189,7 +195,7 @@ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPa static float colorWire[4], colorWireEdit[4]; static float colorActive[4], colorSelect[4], colorTransform[4], colorGroup[4], colorGroupActive[4]; static float colorEmpty[4], colorLamp[4], colorCamera[4], colo
[Bf-blender-cvs] [c4c3951c4f] clay-engine: Initial implementation of instancing
Commit: c4c3951c4f294a4c543a81cb6b06a68fda8e970a Author: Clément Foucault Date: Tue Jan 31 02:12:24 2017 +0100 Branches: clay-engine https://developer.blender.org/rBc4c3951c4f294a4c543a81cb6b06a68fda8e970a Initial implementation of instancing === M source/blender/draw/intern/DRW_render.h M source/blender/draw/intern/draw_manager.c M source/blender/draw/intern/draw_mode_pass.c M source/blender/gpu/CMakeLists.txt M source/blender/gpu/GPU_shader.h M source/blender/gpu/gawain/batch.c M source/blender/gpu/gawain/batch.h M source/blender/gpu/intern/gpu_shader.c A source/blender/gpu/shaders/gpu_shader_3D_instance_vert.glsl === diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 6d26f7b8b7..8bd3cabf8d 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -160,6 +160,7 @@ typedef enum { /* Used by DRWShadingGroup.dyntype */ #define DRW_DYN_POINTS 1 #define DRW_DYN_LINES 2 +#define DRW_DYN_INSTANCE 3 DRWShadingGroup *DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass); void DRW_shgroup_free(struct DRWShadingGroup *shgroup); diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 45c8b911df..9fc020885d 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -90,6 +90,7 @@ struct DRWInterface { int modelview; int projection; int modelviewprojection; + int viewprojection; int normal; int eye; }; @@ -114,6 +115,8 @@ struct DRWShadingGroup { int state; /* State changes for this batch only */ short dyntype; /* Dynamic Batch type, 0 is normal */ Batch *dyngeom; /* Dynamic batch */ + GLuint instance_vbo; /* Dynamic batch VBO storing Model Matrices */ + int instance_count;/* Dynamic batch Number of instance to render */ }; /* Render State */ @@ -277,6 +280,7 @@ static DRWInterface *DRW_interface_create(GPUShader *shader) interface->modelview = GPU_shader_get_uniform(shader, "ModelViewMatrix"); interface->projection = GPU_shader_get_uniform(shader, "ProjectionMatrix"); + interface->viewprojection = GPU_shader_get_uniform(shader, "ViewProjectionMatrix"); interface->modelviewprojection = GPU_shader_get_uniform(shader, "ModelViewProjectionMatrix"); interface->normal = GPU_shader_get_uniform(shader, "NormalMatrix"); interface->eye = GPU_shader_get_uniform(shader, "eye"); @@ -440,16 +444,13 @@ void DRW_shgroup_uniform_mat4(DRWShadingGroup *shgroup, const char *name, const DRW_interface_uniform(shgroup, name, DRW_UNIFORM_MAT4, value, 16, 1, 0); } -static void shgroup_dynamic_batch_from_calls(DRWShadingGroup *shgroup) +/* Creates OGL primitives based on DRWCall.obmat position list */ +static void shgroup_dynamic_batch_primitives(DRWShadingGroup *shgroup) { int i = 0; int nbr = BLI_listbase_count(>calls); GLenum type; -#ifdef WITH_VIEWPORT_CACHE_TEST - if (shgroup->dyngeom) return; -#endif - if (nbr == 0) { if (shgroup->dyngeom) { Batch_discard(shgroup->dyngeom); @@ -491,6 +492,67 @@ static void shgroup_dynamic_batch_from_calls(DRWShadingGroup *shgroup) MEM_freeN(data); } +static void shgroup_dynamic_batch_instance(DRWShadingGroup *shgroup) +{ + int i = 0; + int nbr = BLI_listbase_count(>calls); + + shgroup->instance_count = nbr; + + if (nbr == 0) { + if (shgroup->instance_vbo) { + glDeleteBuffers(1, >instance_vbo); + shgroup->instance_vbo = 0; + } + return; + } + + /* Gather Data */ + float *data = MEM_mallocN(sizeof(float) * 4 * 4 * nbr , "Instance Model Matrix"); + + for (DRWCall *call = shgroup->calls.first; call; call = call->next, i++) { + copy_m4_m4([i*16], call->obmat); + } + + /* Upload Data */ + static VertexFormat format = { 0 }; + static unsigned mat_id; + if (format.attrib_ct == 0) { + mat_id = add_attrib(, "InstanceModelMatrix", GL_FLOAT, 4, KEEP_FLOAT); + } + + VertexBuffer *vbo = VertexBuffer_create_with_format(); + VertexBuffer_allocate_data(vbo, nbr); + + fillAttrib(vbo, mat_id, data); + + /* TODO poke mike to add this to gawain */ + if (shgroup->instance_vbo) { + glDeleteBuffers(1, >instance_vbo); +
[Bf-blender-cvs] [75d6a30cc2] clay-engine: Show Render Layer panel to clay engine.
Commit: 75d6a30cc2fc25c43f77259822853161d19418ac Author: Clément Foucault Date: Mon Jan 30 16:31:10 2017 +0100 Branches: clay-engine https://developer.blender.org/rB75d6a30cc2fc25c43f77259822853161d19418ac Show Render Layer panel to clay engine. === M release/scripts/startup/bl_ui/properties_render_layer.py === diff --git a/release/scripts/startup/bl_ui/properties_render_layer.py b/release/scripts/startup/bl_ui/properties_render_layer.py index 45c93dd933..2545eadc79 100644 --- a/release/scripts/startup/bl_ui/properties_render_layer.py +++ b/release/scripts/startup/bl_ui/properties_render_layer.py @@ -48,7 +48,7 @@ class RENDERLAYER_UL_renderlayers(UIList): class RENDERLAYER_PT_layers(RenderLayerButtonsPanel, Panel): bl_label = "Layer List" bl_options = {'HIDE_HEADER'} -COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} +COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'} def draw(self, context): layout = self.layout ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [581b0c9a4f] clay-engine: More Object mode work.
Commit: 581b0c9a4f80bb56e25622da3e526e7be24ea68a Author: Clément Foucault Date: Tue Jan 31 14:01:23 2017 +0100 Branches: clay-engine https://developer.blender.org/rB581b0c9a4f80bb56e25622da3e526e7be24ea68a More Object mode work. === M source/blender/blenkernel/BKE_layer.h M source/blender/draw/engines/clay/clay.c M source/blender/draw/intern/draw_manager.c M source/blender/draw/intern/draw_mode_pass.c M source/blender/draw/intern/draw_mode_pass.h === diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h index 0f328700bf..ff5b16f208 100644 --- a/source/blender/blenkernel/BKE_layer.h +++ b/source/blender/blenkernel/BKE_layer.h @@ -143,6 +143,15 @@ void BKE_visible_bases_Iterator_end(Iterator *iter); } \ } +#define FOREACH_BASE(sl, _object_base)\ +{ \ + for (base = sl->object_bases.first; base; base = base->next) { \ + _object_base = base; + +#define FOREACH_BASE_END \ +} \ +} + #define FOREACH_OBJECT_FLAG(scene, sl, flag, _ob) \ { \ IteratorBeginCb func_begin; \ diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c index a588412903..dabb500936 100644 --- a/source/blender/draw/engines/clay/clay.c +++ b/source/blender/draw/engines/clay/clay.c @@ -529,7 +529,7 @@ static void CLAY_create_cache(CLAY_PassList *passes, const struct bContext *C) { SceneLayer *sl = CTX_data_scene_layer(C); DRWShadingGroup *default_shgrp, *depthbatch; - Object *ob; + ObjectBase *base; /* Depth Pass */ { @@ -558,9 +558,10 @@ static void CLAY_create_cache(CLAY_PassList *passes, const struct bContext *C) } /* TODO Create hash table of batch based on material id*/ - FOREACH_OBJECT(sl, ob) + FOREACH_BASE(sl, base) { struct Batch *geom; + Object *ob = base->object; switch (ob->type) { case OB_MESH: @@ -583,14 +584,14 @@ static void CLAY_create_cache(CLAY_PassList *passes, const struct bContext *C) case OB_CAMERA: case OB_EMPTY: default: - DRW_shgroup_non_meshes(passes->non_meshes_pass, ob); + DRW_shgroup_non_meshes(passes->non_meshes_pass, base); break; } - DRW_shgroup_object_center(passes->ob_center_pass, ob); - DRW_shgroup_relationship_lines(passes->non_meshes_pass, ob); + DRW_shgroup_object_center(passes->ob_center_pass, base); + DRW_shgroup_relationship_lines(passes->non_meshes_pass, base); } - FOREACH_OBJECT_END + FOREACH_BASE_END } static void CLAY_view_draw(RenderEngine *UNUSED(engine), const struct bContext *context) diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 9fc020885d..3fff977bc9 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -544,7 +544,6 @@ static void shgroup_dynamic_batch_from_calls(DRWShadingGroup *shgroup) #ifdef WITH_VIEWPORT_CACHE_TEST if (shgroup->dyngeom) return; #endif - if (shgroup->dyntype == DRW_DYN_INSTANCE) { shgroup_dynamic_batch_instance(shgroup); } @@ -786,7 +785,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup) float obmat[4][4]; unit_m4(obmat); - if (shgroup->dyntype == DRW_DYN_INSTANCE) { + if (shgroup->dyntype == DRW_DYN_INSTANCE && shgroup->instance_count > 0) { DRWCall *call = shgroup->calls.first; draw_geometry(shgroup, interface, call->geometry, shgroup->instance_vbo, shgroup->instance_count, obmat); } diff --git a/source/blender/draw/intern/draw_mode_pass.c b/source/blender/draw/intern/draw_mode_pass.c index d8db13925f..c93c9a1610 100644 --- a/source/blender/draw/intern/draw_mode_pass.c +++ b/source/blender/draw/intern/draw_mode_pass.c @@ -29,10 +29,30 @@ #include "UI_resources.h" +#include "BKE_global.h" + #include "draw_mode_pass.h" /* ***
[Bf-blender-cvs] [481785f153] clay-engine: Merge branch 'render-layers' of git.blender.org:blender into clay-engine
Commit: 481785f1536a944b64febe7cfc1dbe5bb437eb40 Author: Clément Foucault Date: Tue Jan 31 14:03:00 2017 +0100 Branches: clay-engine https://developer.blender.org/rB481785f1536a944b64febe7cfc1dbe5bb437eb40 Merge branch 'render-layers' of git.blender.org:blender into clay-engine === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [0651227c4a] clay-engine: Fixing Memory Leak
Commit: 0651227c4ad00da7d64e7764ab523e1365ef6301 Author: Clément Foucault Date: Wed Feb 1 14:32:48 2017 +0100 Branches: clay-engine https://developer.blender.org/rB0651227c4ad00da7d64e7764ab523e1365ef6301 Fixing Memory Leak === M source/blender/draw/intern/draw_manager.c === diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 0c3c9a022c..dc40c669c8 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -348,7 +348,7 @@ void DRW_shgroup_free(struct DRWShadingGroup *shgroup) MEM_freeN(shgroup->interface); if (shgroup->dyngeom) - Batch_discard(shgroup->dyngeom); + Batch_discard_all(shgroup->dyngeom); } /* Later use VBO */ @@ -483,7 +483,7 @@ static void shgroup_dynamic_batch_primitives(DRWShadingGroup *shgroup) /* TODO make the batch dynamic instead of freeing it every times */ if (shgroup->dyngeom) - Batch_discard(shgroup->dyngeom); + Batch_discard_all(shgroup->dyngeom); shgroup->dyngeom = Batch_create(type, vbo, NULL); @@ -512,18 +512,6 @@ static void shgroup_dynamic_batch_instance(DRWShadingGroup *shgroup) copy_m4_m4((float (*)[4])[i*16], call->obmat); } - /* Upload Data */ - static VertexFormat format = { 0 }; - static unsigned mat_id; - if (format.attrib_ct == 0) { - mat_id = add_attrib(, "InstanceModelMatrix", GL_FLOAT, 4, KEEP_FLOAT); - } - - VertexBuffer *vbo = VertexBuffer_create_with_format(); - VertexBuffer_allocate_data(vbo, nbr); - - fillAttrib(vbo, mat_id, data); - /* TODO poke mike to add this to gawain */ if (shgroup->instance_vbo) { glDeleteBuffers(1, >instance_vbo); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6d4f75a123] render-layers: Merge remote-tracking branch 'origin/blender2.8' into render-layers
Commit: 6d4f75a123cdbc33d83b61e46b7bd2ede6cc0fe9 Author: Clément Foucault Date: Mon Feb 6 11:35:49 2017 +0100 Branches: render-layers https://developer.blender.org/rB6d4f75a123cdbc33d83b61e46b7bd2ede6cc0fe9 Merge remote-tracking branch 'origin/blender2.8' into render-layers === === diff --cc release/scripts/startup/bl_operators/freestyle.py index e899f7a1b0,fe3b00d54c..43cd3110be --- a/release/scripts/startup/bl_operators/freestyle.py +++ b/release/scripts/startup/bl_operators/freestyle.py @@@ -73,17 -75,53 +75,53 @@@ class SCENE_OT_freestyle_fill_range_by_ else: self.report({'ERROR'}, "Unexpected modifier type: " + m.type) return {'CANCELLED'} + # Find selected vertices in editmesh + ob = bpy.context.active_object + if ob.type == 'MESH' and ob.mode == 'EDIT' and ob.name != ref.name: + bpy.ops.object.mode_set(mode='OBJECT') + selected_verts = [v for v in bpy.context.active_object.data.vertices if v.select] + bpy.ops.object.mode_set(mode='EDIT') + # Compute the min/max distance from the reference to mesh vertices + min_dist = sys.float_info.max + max_dist = -min_dist + if m.type == 'DISTANCE_FROM_CAMERA': + ob_to_cam = matrix_to_camera * ob.matrix_world + for vert in selected_verts: + # dist in the camera space + dist = (ob_to_cam * vert.co).length + min_dist = min(dist, min_dist) + max_dist = max(dist, max_dist) + elif m.type == 'DISTANCE_FROM_OBJECT': + for vert in selected_verts: + # dist in the world space + dist = (ob.matrix_world * vert.co - target_location).length + min_dist = min(dist, min_dist) + max_dist = max(dist, max_dist) + # Fill the Range Min/Max entries with the computed distances + m.range_min = min_dist + m.range_max = max_dist + return {'FINISHED'} # Find selected mesh objects -selection = [ob for ob in scene.objects if ob.select and ob.type == 'MESH' and ob.name != ref.name] +selection = [ob for ob in scene.objects if ob.select_get() and ob.type == 'MESH' and ob.name != source.name] if selection: - # Compute the min/max distance between selected mesh objects and the source + # Compute the min/max distance from the reference to mesh vertices min_dist = sys.float_info.max max_dist = -min_dist - for ob in selection: - for vert in ob.data.vertices: - dist = (ob.matrix_world * vert.co - source.location).length - min_dist = min(dist, min_dist) - max_dist = max(dist, max_dist) + if m.type == 'DISTANCE_FROM_CAMERA': + for ob in selection: + ob_to_cam = matrix_to_camera * ob.matrix_world + for vert in ob.data.vertices: + # dist in the camera space + dist = (ob_to_cam * vert.co).length + min_dist = min(dist, min_dist) + max_dist = max(dist, max_dist) + elif m.type == 'DISTANCE_FROM_OBJECT': + for ob in selection: + for vert in ob.data.vertices: + # dist in the world space + dist = (ob.matrix_world * vert.co - target_location).length + min_dist = min(dist, min_dist) + max_dist = max(dist, max_dist) # Fill the Range Min/Max entries with the computed distances m.range_min = min_dist m.range_max = max_dist diff --cc source/blender/blenkernel/intern/library_query.c index 99aab6daed,9685f1f5af..ef629ce7ef --- a/source/blender/blenkernel/intern/library_query.c +++ b/source/blender/blenkernel/intern/library_query.c @@@ -334,15 -354,15 +355,15 @@@ void BKE_library_foreach_ID_link(Main * Scene *scene = (Scene *) id; ToolSettings *toolsett = scene->toolsettings; SceneRenderLayer *srl; - Base *base; + Base *legacy_base; - CALLBACK_INVOKE(scene->camera, IDWALK_NOP); - CALLBACK_INVOKE(scene->world, IDWALK_USER); - CALLBACK_INVOKE(scene->set, IDWALK_NOP); - CALLBACK_INVOKE(scene->clip, IDWALK_USER); + CALL
[Bf-blender-cvs] [8dbd961a3e] blender2.8: OpenGL immediate mode: interface_draw.c
Commit: 8dbd961a3ecb56f9ecef8d028914d981d65ef75b Author: Clément Foucault Date: Mon Feb 6 14:06:13 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB8dbd961a3ecb56f9ecef8d028914d981d65ef75b OpenGL immediate mode: interface_draw.c === M source/blender/editors/include/UI_interface.h M source/blender/editors/interface/interface_draw.c M source/blender/editors/screen/area.c M source/blender/editors/space_nla/nla_draw.c M source/blender/editors/space_sequencer/sequencer_draw.c === diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index d48cfbee41..5e27dc12a1 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -316,8 +316,8 @@ void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx, void UI_draw_roundbox_gl_mode_3ubAlpha(int mode, float minx, float miny, float maxx, float maxy, float rad, unsigned char col[3], unsigned char alpha); void UI_draw_roundbox_gl_mode_3fvAlpha(int mode, float minx, float miny, float maxx, float maxy, float rad, float col[3], float alpha); void UI_draw_roundbox_gl_mode(int mode, float minx, float miny, float maxx, float maxy, float rad, float col[4]); -void UI_draw_roundbox_shade_x(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown); -void UI_draw_roundbox_shade_y(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeLeft, float shadeRight); +void UI_draw_roundbox_shade_x(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown, float col[4]); +void UI_draw_roundbox_shade_y(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeleft, float shaderight, float col[4]); void UI_draw_text_underline(int pos_x, int pos_y, int len, int height); void UI_draw_safe_areas( diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index f17c61b8aa..bfd90142e9 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -174,227 +174,251 @@ void UI_draw_roundbox_gl_mode(int mode, float minx, float miny, float maxx, floa immUnbindProgram(); } -static void round_box_shade_col(const float col1[3], float const col2[3], const float fac) +static void round_box_shade_col(unsigned attrib, const float col1[3], float const col2[3], const float fac) { - float col[3] = { + float col[4] = { fac * col1[0] + (1.0f - fac) * col2[0], fac * col1[1] + (1.0f - fac) * col2[1], - fac * col1[2] + (1.0f - fac) * col2[2] + fac * col1[2] + (1.0f - fac) * col2[2], + 1.0f }; - glColor3fv(col); + immAttrib4fv(attrib, col); } /* linear horizontal shade within button or in outline */ /* view2d scrollers use it */ void UI_draw_roundbox_shade_x( int mode, float minx, float miny, float maxx, float maxy, -float rad, float shadetop, float shadedown) +float rad, float shadetop, float shadedown, float col[4]) { float vec[7][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293}, {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}}; const float div = maxy - miny; const float idiv = 1.0f / div; - float coltop[3], coldown[3], color[4]; + float coltop[3], coldown[3]; + int vert_count = 0; int a; - + + VertexFormat *format = immVertexFormat(); + unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); + unsigned color = add_attrib(format, "color", GL_FLOAT, 4, KEEP_FLOAT); + + immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); + /* mult */ for (a = 0; a < 7; a++) { mul_v2_fl(vec[a], rad); } - /* get current color, needs to be outside of glBegin/End */ - glGetFloatv(GL_CURRENT_COLOR, color); /* 'shade' defines strength of shading */ - coltop[0] = min_ff(1.0f, color[0] + shadetop); - coltop[1] = min_ff(1.0f, color[1] + shadetop); - coltop[2] = min_ff(1.0f, color[2] + shadetop); - coldown[0] = max_ff(0.0f, color[0] + shadedown); - coldown[1] = max_ff(0.0f, color[1] + shadedown); - coldown[2] = max_ff(0.0f, color[2] + shadedown); + coltop[0] = min_ff(1.0f, col[0] + shadetop); + coltop[1] = min_ff(1.0f, col[1] + shadetop); + coltop[2] = min_ff(1.0f, col[2] + shadetop); + coldown[0] = max_ff(0.0f, col[0] + shadedown); + coldown[1] = max_ff(0.0f, col[1] + shadedown); + coldown[2] = max_ff(0.0f, col[2] + shadedown
[Bf-blender-cvs] [83adc54438] blender2.8: Clay-Engine (merge clay-engine)
Commit: 83adc544382689217e19564fd5f2dd62160956cb Author: Clément Foucault Date: Tue Feb 7 11:20:15 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB83adc544382689217e19564fd5f2dd62160956cb Clay-Engine (merge clay-engine) Initial work by Clément Foucault with contributions from Dalai Felinto (mainly per-collection engine settings logic, and depsgraph iterator placeholder). This makes Blender require OpenGL 3.3. Which means Intel graphic card and OSX will break. Disable CLAY_ENGINE in CMake in those cases. This is a prototype render engine intended to help the design of real render engines. This is mainly an engine with enphasis in matcap and ambient occlusion. Implemented Features * Clay Render Engine, following the new API, to be used as reference for future engines * A more complete Matcap customization with more options * Per-Collection render engine settings * New Ground Truth AO - not enabled Missing Features * Finish object edit mode - Fix shaders to use new matrix - Fix artifacts when edge does off screen - Fix depth issue - Selection sillhouette - Mesh wires - Use mesh normals (for higher quality matcap) - Non-Mesh objects drawing - Widget drawing - Performance issues * Finish mesh edit mode - Derived-Mesh-less edit mode API (mesh_rende.c) * General edit mode - Per-collection edit mode settings * General engines - Per-collection engine settings (they are their, but they still need to be flushed by depsgraph, and used by the drawing code) === M CMakeLists.txt M build_files/cmake/macros.cmake M release/scripts/startup/bl_ui/properties_collection.py M release/scripts/startup/bl_ui/properties_render.py M release/scripts/startup/bl_ui/properties_render_layer.py M source/blender/CMakeLists.txt M source/blender/blenkernel/BKE_layer.h M source/blender/blenkernel/intern/layer.c M source/blender/blenkernel/intern/material.c M source/blender/blenkernel/intern/mesh_render.c M source/blender/blenkernel/intern/scene.c M source/blender/blenloader/intern/readfile.c M source/blender/blenloader/intern/versioning_280.c M source/blender/blenloader/intern/writefile.c M source/blender/draw/CMakeLists.txt A source/blender/draw/DRW_engine.h D source/blender/draw/DRW_engines.h A source/blender/draw/engines/clay/clay.c R071source/blender/draw/DRW_defines.h source/blender/draw/engines/clay/clay.h A source/blender/draw/engines/clay/shaders/clay_frag.glsl A source/blender/draw/engines/clay/shaders/clay_vert.glsl A source/blender/draw/engines/clay/shaders/ssao_alchemy.glsl A source/blender/draw/engines/clay/shaders/ssao_groundtruth.glsl A source/blender/draw/intern/DRW_render.h A source/blender/draw/intern/draw_cache.c A source/blender/draw/intern/draw_cache.h A source/blender/draw/intern/draw_manager.c A source/blender/draw/intern/draw_mode_pass.c A source/blender/draw/intern/draw_mode_pass.h M source/blender/editors/space_view3d/space_view3d.c M source/blender/editors/space_view3d/view3d_draw.c M source/blender/editors/space_view3d/view3d_intern.h M source/blender/gpu/CMakeLists.txt M source/blender/gpu/GPU_extensions.h M source/blender/gpu/GPU_framebuffer.h M source/blender/gpu/GPU_shader.h A source/blender/gpu/GPU_uniformbuffer.h M source/blender/gpu/GPU_viewport.h M source/blender/gpu/gawain/batch.c M source/blender/gpu/gawain/batch.h M source/blender/gpu/intern/gpu_extensions.c M source/blender/gpu/intern/gpu_framebuffer.c M source/blender/gpu/intern/gpu_shader.c M source/blender/gpu/intern/gpu_texture.c A source/blender/gpu/intern/gpu_uniformbuffer.c M source/blender/gpu/intern/gpu_viewport.c A source/blender/gpu/shaders/gpu_shader_3D_groundline_geom.glsl A source/blender/gpu/shaders/gpu_shader_3D_groundline_vert.glsl A source/blender/gpu/shaders/gpu_shader_3D_groundpoint_vert.glsl A source/blender/gpu/shaders/gpu_shader_3D_instance_vert.glsl A source/blender/gpu/shaders/gpu_shader_3D_lamp_vert.glsl M source/blender/makesdna/DNA_layer_types.h M source/blender/makesdna/DNA_material_types.h M source/blender/makesdna/DNA_object_types.h M source/blender/makesdna/DNA_scene_types.h M source/blender/makesrna/RNA_access.h M source/blender/makesrna/intern/CMakeLists.txt M source/blender/makesrna/intern/rna_material.c M source/blender/makesrna/intern/rna_render.c M source/blender/makesrna/intern/rna_scene.c M source/blender/render/CMakeLists.txt M source/blender/render/extern/include/RE_engine.h M source/blender/render/intern/source/external_engine.c M source/blenderplayer
[Bf-blender-cvs] [a54110751a] blender2.8: OpenGL immediate mode: interface_draw.c (cont)
Commit: a54110751a34c6f9641575258959dbaf6e43f2f3 Author: Clément Foucault Date: Mon Feb 6 16:54:26 2017 +0100 Branches: blender2.8 https://developer.blender.org/rBa54110751a34c6f9641575258959dbaf6e43f2f3 OpenGL immediate mode: interface_draw.c (cont) ui_draw_but_HISTOGRAM UI_draw_text_underline (untested) === M source/blender/editors/include/UI_interface.h M source/blender/editors/interface/interface_draw.c M source/blender/editors/interface/interface_widgets.c === diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index a4bd4b8010..286ac6054e 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -318,7 +318,7 @@ void UI_draw_roundbox_gl_mode_3fvAlpha(int mode, float minx, float miny, float m void UI_draw_roundbox_gl_mode(int mode, float minx, float miny, float maxx, float maxy, float rad, float col[4]); void UI_draw_roundbox_shade_x(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown, const float col[4]); void UI_draw_roundbox_shade_y(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeleft, float shaderight, const float col[4]); -void UI_draw_text_underline(int pos_x, int pos_y, int len, int height); +void UI_draw_text_underline(int pos_x, int pos_y, int len, int height, const float color[4]); void UI_draw_safe_areas( unsigned pos, float x1, float x2, float y1, float y2, diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index b3769f537e..60df380923 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -449,10 +449,18 @@ void UI_draw_roundbox(float minx, float miny, float maxx, float maxy, float rad, ui_draw_anti_roundbox(GL_TRIANGLE_FAN, minx, miny, maxx, maxy, rad, roundboxtype & UI_RB_ALPHA, color); } -void UI_draw_text_underline(int pos_x, int pos_y, int len, int height) +void UI_draw_text_underline(int pos_x, int pos_y, int len, int height, const float color[4]) { int ofs_y = 4 * U.pixelsize; - glRecti(pos_x, pos_y - ofs_y, pos_x + len, pos_y - ofs_y + (height * U.pixelsize)); + + VertexFormat *format = immVertexFormat(); + unsigned pos = add_attrib(format, "pos", GL_INT, 2, CONVERT_INT_TO_FLOAT); + + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + immUniformColor4fv(color); + + immRecti(pos, pos_x, pos_y - ofs_y, pos_x + len, pos_y - ofs_y + (height * U.pixelsize)); + immUnbindProgram(); } /* ** SPECIAL BUTTON DRAWING FUNCTIONS * */ @@ -556,45 +564,49 @@ static void draw_scope_end(const rctf *rect, GLint *scissor) static void histogram_draw_one( float r, float g, float b, float alpha, -float x, float y, float w, float h, const float *data, int res, const bool is_line) +float x, float y, float w, float h, const float *data, int res, const bool is_line, +unsigned int pos_attrib) { + float color[4] = {r, g, b, alpha}; + glEnable(GL_LINE_SMOOTH); glBlendFunc(GL_SRC_ALPHA, GL_ONE); - glColor4f(r, g, b, alpha); + + immUniformColor4fv(color); if (is_line) { /* curve outline */ glLineWidth(1.5); - glBegin(GL_LINE_STRIP); + immBegin(GL_LINE_STRIP, res); for (int i = 0; i < res; i++) { float x2 = x + i * (w / (float)res); - glVertex2f(x2, y + (data[i] * h)); + immVertex2f(pos_attrib, x2, y + (data[i] * h)); } - glEnd(); + immEnd(); } else { /* under the curve */ - glBegin(GL_TRIANGLE_STRIP); - glVertex2f(x, y); - glVertex2f(x, y + (data[0] * h)); + immBegin(GL_TRIANGLE_STRIP, res*2); + immVertex2f(pos_attrib, x, y); + immVertex2f(pos_attrib, x, y + (data[0] * h)); for (int i = 1; i < res; i++) { float x2 = x + i * (w / (float)res); - glVertex2f(x2, y + (data[i] * h)); - glVertex2f(x2, y); + immVertex2f(pos_attrib, x2, y + (data[i] * h)); + immVertex2f(pos_attrib, x2, y); } - glEnd(); + immEnd(); /* curve outline */ - glColor4f(0.f, 0.f, 0.f, 0.25f); + immUniformColor4f(0.f, 0.f, 0.f, 0.25f); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - g
[Bf-blender-cvs] [9b742ff61b] blender2.8: OpenGL immediate mode: interface_draw.c (cont)
Commit: 9b742ff61b7956d7158cdb9eebea2cc147f39582 Author: Clément Foucault Date: Tue Feb 7 00:24:44 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB9b742ff61b7956d7158cdb9eebea2cc147f39582 OpenGL immediate mode: interface_draw.c (cont) ui_draw_but_WAVEFORM ui_draw_but_VECTORSCOPE === M source/blender/editors/interface/interface_draw.c === diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 60df380923..d57015f888 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -57,7 +57,9 @@ #include "GPU_draw.h" #include "GPU_basic_shader.h" +#include "GPU_batch.h" #include "GPU_immediate.h" +#include "GPU_matrix.h" #include "UI_interface.h" @@ -688,6 +690,25 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol) #undef HISTOGRAM_TOT_GRID_LINES +static void waveform_draw_one(float *waveform, int nbr, const float col[3]) +{ + VertexFormat format = {0}; + unsigned int pos_id = add_attrib(, "pos", GL_FLOAT, 2, KEEP_FLOAT); + + VertexBuffer *vbo = VertexBuffer_create_with_format(); + VertexBuffer_allocate_data(vbo, nbr); + + fillAttrib(vbo, pos_id, waveform); + + /* TODO store the Batch inside the scope */ + Batch *batch = Batch_create(GL_POINTS, vbo, NULL); + Batch_set_builtin_program(batch, GPU_SHADER_2D_UNIFORM_COLOR); + Batch_Uniform4f(batch, "color", col[0], col[1], col[2], 1.f); + Batch_draw(batch); + + Batch_discard_all(batch); +} + void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti *recti) { Scopes *scopes = (Scopes *)but->poin; @@ -740,94 +761,84 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), (rect.xmax + 1) - (rect.xmin - 1), (rect.ymax + 1) - (rect.ymin - 1)); - glColor4f(1.f, 1.f, 1.f, 0.08f); - /* draw grid lines here */ + /* draw scale numbers first before binding any shader */ for (int i = 0; i < 6; i++) { char str[4]; BLI_snprintf(str, sizeof(str), "%-3d", i * 20); str[3] = '\0'; - fdrawline(rect.xmin + 22, yofs + (i / 5.f) * h, rect.xmax + 1, yofs + (i / 5.f) * h); BLF_draw_default(rect.xmin + 1, yofs - 5 + (i / 5.f) * h, 0, str, sizeof(str) - 1); - /* in the loop because blf_draw reset it */ - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + VertexFormat *format = immVertexFormat(); + unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); + + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + + immUniformColor4f(1.f, 1.f, 1.f, 0.08f); + /* draw grid lines here */ + for (int i = 0; i < 6; i++) { + imm_draw_line(pos, rect.xmin + 22, yofs + (i / 5.f) * h, rect.xmax + 1, yofs + (i / 5.f) * h); } /* 3 vertical separation */ if (scopes->wavefrm_mode != SCOPES_WAVEFRM_LUMA) { for (int i = 1; i < 3; i++) { - fdrawline(rect.xmin + i * w3, rect.ymin, rect.xmin + i * w3, rect.ymax); + imm_draw_line(pos, rect.xmin + i * w3, rect.ymin, rect.xmin + i * w3, rect.ymax); } } /* separate min max zone on the right */ - fdrawline(rect.xmin + w, rect.ymin, rect.xmin + w, rect.ymax); + imm_draw_line(pos, rect.xmin + w, rect.ymin, rect.xmin + w, rect.ymax); /* 16-235-240 level in case of ITU-R BT601/709 */ - glColor4f(1.f, 0.4f, 0.f, 0.2f); + immUniformColor4f(1.f, 0.4f, 0.f, 0.2f); if (ELEM(scopes->wavefrm_mode, SCOPES_WAVEFRM_YCC_601, SCOPES_WAVEFRM_YCC_709)) { - fdrawline(rect.xmin + 22, yofs + h * 16.0f / 255.0f, rect.xmax + 1, yofs + h * 16.0f / 255.0f); - fdrawline(rect.xmin + 22, yofs + h * 235.0f / 255.0f, rect.xmin + w3, yofs + h * 235.0f / 255.0f); - fdrawline(rect.xmin + 3 * w3, yofs + h * 235.0f / 255.0f, rect.xmax + 1, yofs + h * 235.0f / 255.0f); - fdrawline(rect.xmin + w3, yofs + h * 240.0f / 255.0f, rect.xmax + 1, yofs + h * 240.0f / 255.0f); + imm_draw_line(pos, rect.xmin + 22, yofs + h * 16.0f / 255.0f, rect.xmax + 1, yofs + h * 16.0f / 255.0f); + imm_draw_line(pos, rect.xmin + 22, yofs + h * 235.0f / 255.0f, rect.xmin + w3, yofs + h * 235.0f / 255.0f); +
[Bf-blender-cvs] [7e949b3124] temp-blender2.8-stable: OpenGL immediate mode: gluSphere replacement
Commit: 7e949b3124b4b0c8f32e2f14ae55e80e1d25d03a Author: Clément Foucault Date: Wed Feb 8 00:38:07 2017 +0100 Branches: temp-blender2.8-stable https://developer.blender.org/rB7e949b3124b4b0c8f32e2f14ae55e80e1d25d03a OpenGL immediate mode: gluSphere replacement Updated interface_draw.c to use the new sphere batch. === M source/blender/editors/interface/interface_draw.c M source/blender/gpu/GPU_batch.h M source/blender/gpu/intern/gpu_batch.c M source/blender/gpu/intern/gpu_init_exit.c === diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 1cd1921d12..47497947dc 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -1282,63 +1282,6 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti immUnbindProgram(); } -#define SPHERE_LAT_RES 24 -#define SPHERE_LON_RES 32 - -static float sphere_coords[SPHERE_LON_RES][SPHERE_LAT_RES][3] = {{{2.0f}}}; - -static void ui_draw_lat_lon_vert(unsigned int pos, unsigned int nor, float radius, int lat, int lon) -{ - const float x = sphere_coords[lon][lat][0]; - const float y = sphere_coords[lon][lat][1]; - const float z = sphere_coords[lon][lat][2]; - - immAttrib3f(nor, x, y, z); - immVertex3f(pos, x * radius, y * radius, z * radius); -} - -static void ui_draw_unitvec_sphere(unsigned int pos, unsigned int nor, float radius) -{ - const float lon_inc = 2 * M_PI / SPHERE_LON_RES; - const float lat_inc = M_PI / SPHERE_LAT_RES; - float lon, lat; - - /* TODO put that in a batch */ - - /* Init coords only once */ - if (sphere_coords[0][0][0] == 2.0f) { - lon = 0.0f; - for(int i = 0; i < SPHERE_LON_RES; i++, lon += lon_inc) { - lat = 0.0f; - for(int j = 0; j < SPHERE_LAT_RES; j++, lat += lat_inc) { - sphere_coords[i][j][0] = sinf(lat) * cosf(lon); - sphere_coords[i][j][1] = cosf(lat); - sphere_coords[i][j][2] = sinf(lat) * sinf(lon); - } - } - } - - immBegin(GL_TRIANGLES, (SPHERE_LAT_RES-1) * SPHERE_LON_RES * 6); - for(int i = 0; i < SPHERE_LON_RES; i++) { - for(int j = 0; j < SPHERE_LAT_RES; j++) { - if (j != SPHERE_LAT_RES - 1) { /* Pole */ - ui_draw_lat_lon_vert(pos, nor, radius, j, i); - ui_draw_lat_lon_vert(pos, nor, radius, j+1, i); - ui_draw_lat_lon_vert(pos, nor, radius, j+1, i+1); - } - - if (j != 0) { /* Pole */ - ui_draw_lat_lon_vert(pos, nor, radius, j, i); - ui_draw_lat_lon_vert(pos, nor, radius, j+1, i+1); - ui_draw_lat_lon_vert(pos, nor, radius, j, i+1); - } - } - } - immEnd(); -} -#undef SPHERE_LAT_RES -#undef SPHERE_LON_RES - void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect) { /* sphere color */ @@ -1357,40 +1300,36 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect) ui_but_v3_get(but, light); light[2] = -light[2]; - VertexFormat *format = immVertexFormat(); - unsigned int pos = add_attrib(format, "pos", GL_FLOAT, 3, KEEP_FLOAT); - unsigned int nor = add_attrib(format, "nor", GL_FLOAT, 3, KEEP_FLOAT); - immBindBuiltinProgram(GPU_SHADER_SIMPLE_LIGHTING); - immUniformColor3fv(diffuse); - immUniform3fv("light", light); - /* transform to button */ gpuMatrixBegin3D_legacy(); gpuPushMatrix(); if (BLI_rcti_size_x(rect) < BLI_rcti_size_y(rect)) - size = BLI_rcti_size_x(rect) / 200.f; + size = BLI_rcti_size_x(rect) / 2.f; else - size = BLI_rcti_size_y(rect) / 200.f; + size = BLI_rcti_size_y(rect) / 2.f; gpuTranslate3f(rect->xmin + 0.5f * BLI_rcti_size_x(rect), rect->ymin + 0.5f * BLI_rcti_size_y(rect), 0.0f); - gpuScale3f(size, size, MIN2(size, 1.0f)); + gpuScale3f(size, size, size); - ui_draw_unitvec_sphere(pos, nor, 100.0); - immUnbindProgram(); + Batch *sphere = Batch_get_sphere(2); + Batch_set_builtin_program(sphere, GPU_SHADER_SIMPLE_LIGHTING); + Batch_Uniform4f(sphere, "color", diffuse[0], diffuse[1], diffuse[2], 1.f); + Batch_Uniform3fv(sphere, "light", light); + Batch_draw(sphere);
[Bf-blender-cvs] [a39a459a1e] temp-blender2.8-stable: OpenGL immediate mode: interface_draw.c (cont)
Commit: a39a459a1ecbe3ab0cb772b9eae58ffc0a4d3e08 Author: Clément Foucault Date: Tue Feb 7 20:43:58 2017 +0100 Branches: temp-blender2.8-stable https://developer.blender.org/rBa39a459a1ecbe3ab0cb772b9eae58ffc0a4d3e08 OpenGL immediate mode: interface_draw.c (cont) ui_draw_but_UNITVEC Introduced a new shader to be used for simple lighting. === M source/blender/editors/interface/interface_draw.c M source/blender/gpu/CMakeLists.txt M source/blender/gpu/GPU_shader.h M source/blender/gpu/gawain/immediate.c M source/blender/gpu/gawain/immediate.h M source/blender/gpu/intern/gpu_shader.c M source/blender/gpu/shaders/gpu_shader_3D_vert.glsl A source/blender/gpu/shaders/gpu_shader_simple_lighting_frag.glsl === diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 7a12be93c7..32df2aaebb 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -1280,81 +1280,123 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti immUnbindProgram(); } +#define SPHERE_LAT_RES 24 +#define SPHERE_LON_RES 32 + +static float sphere_coords[SPHERE_LON_RES][SPHERE_LAT_RES][3] = {{{2.0f}}}; + +static void ui_draw_lat_lon_vert(unsigned int pos, unsigned int nor, float radius, int lat, int lon) +{ + const float x = sphere_coords[lon][lat][0]; + const float y = sphere_coords[lon][lat][1]; + const float z = sphere_coords[lon][lat][2]; + + immAttrib3f(nor, x, y, z); + immVertex3f(pos, x * radius, y * radius, z * radius); +} + +static void ui_draw_unitvec_sphere(unsigned int pos, unsigned int nor, float radius) +{ + const float lon_inc = 2 * M_PI / SPHERE_LON_RES; + const float lat_inc = M_PI / SPHERE_LAT_RES; + float lon, lat; + + /* TODO put that in a batch */ + + /* Init coords only once */ + if (sphere_coords[0][0][0] == 2.0f) { + lon = 0.0f; + for(int i = 0; i < SPHERE_LON_RES; i++, lon += lon_inc) { + lat = 0.0f; + for(int j = 0; j < SPHERE_LAT_RES; j++, lat += lat_inc) { + sphere_coords[i][j][0] = sinf(lat) * cosf(lon); + sphere_coords[i][j][1] = cosf(lat); + sphere_coords[i][j][2] = sinf(lat) * sinf(lon); + } + } + } + + immBegin(GL_TRIANGLES, (SPHERE_LAT_RES-1) * SPHERE_LON_RES * 6); + for(int i = 0; i < SPHERE_LON_RES; i++) { + for(int j = 0; j < SPHERE_LAT_RES; j++) { + if (j != SPHERE_LAT_RES - 1) { /* Pole */ + ui_draw_lat_lon_vert(pos, nor, radius, j, i); + ui_draw_lat_lon_vert(pos, nor, radius, j+1, i); + ui_draw_lat_lon_vert(pos, nor, radius, j+1, i+1); + } + + if (j != 0) { /* Pole */ + ui_draw_lat_lon_vert(pos, nor, radius, j, i); + ui_draw_lat_lon_vert(pos, nor, radius, j+1, i+1); + ui_draw_lat_lon_vert(pos, nor, radius, j, i+1); + } + } + } + immEnd(); +} +#undef SPHERE_LAT_RES +#undef SPHERE_LON_RES + void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect) { - static GLuint displist = 0; + /* sphere color */ float diffuse[3] = {1.0f, 1.0f, 1.0f}; + float light[3]; float size; /* backdrop */ UI_draw_roundbox_corner_set(UI_CNR_ALL); UI_draw_roundbox_gl_mode_3ubAlpha(GL_TRIANGLE_FAN, rect->xmin, rect->ymin, rect->xmax, rect->ymax, 5.0f, (unsigned char *)wcol->inner, 255); - /* sphere color */ glCullFace(GL_BACK); glEnable(GL_CULL_FACE); /* setup lights */ - GPULightData light = {0}; - light.type = GPU_LIGHT_SUN; - copy_v3_v3(light.diffuse, diffuse); - zero_v3(light.specular); - ui_but_v3_get(but, light.direction); + ui_but_v3_get(but, light); + light[2] = -light[2]; - GPU_basic_shader_light_set(0, ); - for (int a = 1; a < 8; a++) - GPU_basic_shader_light_set(a, NULL); - - /* setup shader */ - GPU_basic_shader_colors(diffuse, NULL, 0, 1.0f); - GPU_basic_shader_bind(GPU_SHADER_LIGHTING); + VertexFormat *format = immVertexFormat(); + unsigned int pos = add_attrib(format, "pos", GL_FLOAT, 3, KEEP_FLOAT); + unsigned int nor = add_attrib(format, "nor", GL_FLOAT, 3, KEEP_FLOAT); +
[Bf-blender-cvs] [c104a86e29] temp-blender2.8-stable: OpenGL immediate mode: interface_draw.c (cont)
Commit: c104a86e293351b2b7e815f0d9151047ce56b408 Author: Clément Foucault Date: Tue Feb 7 13:04:08 2017 +0100 Branches: temp-blender2.8-stable https://developer.blender.org/rBc104a86e293351b2b7e815f0d9151047ce56b408 OpenGL immediate mode: interface_draw.c (cont) ui_draw_but_COLORBAND Introduced a new checker shader to be used mostly on transparent areas. === M source/blender/editors/interface/interface_draw.c M source/blender/gpu/CMakeLists.txt M source/blender/gpu/GPU_shader.h M source/blender/gpu/intern/gpu_shader.c A source/blender/gpu/shaders/gpu_shader_checker_frag.glsl === diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index d57015f888..7a12be93c7 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -1047,44 +1047,44 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco glDisable(GL_BLEND); } -static void ui_draw_colorband_handle_tri_hlight(float x1, float y1, float halfwidth, float height) +static void ui_draw_colorband_handle_tri_hlight(unsigned int pos, float x1, float y1, float halfwidth, float height) { glEnable(GL_LINE_SMOOTH); - glBegin(GL_LINE_STRIP); - glVertex2f(x1 + halfwidth, y1); - glVertex2f(x1, y1 + height); - glVertex2f(x1 - halfwidth, y1); - glEnd(); + immBegin(GL_LINE_STRIP, 3); + immVertex2f(pos, x1 + halfwidth, y1); + immVertex2f(pos, x1, y1 + height); + immVertex2f(pos, x1 - halfwidth, y1); + immEnd(); glDisable(GL_LINE_SMOOTH); } -static void ui_draw_colorband_handle_tri(float x1, float y1, float halfwidth, float height, bool fill) +static void ui_draw_colorband_handle_tri(unsigned int pos, float x1, float y1, float halfwidth, float height, bool fill) { glEnable(fill ? GL_POLYGON_SMOOTH : GL_LINE_SMOOTH); - glBegin(fill ? GL_TRIANGLES : GL_LINE_LOOP); - glVertex2f(x1 + halfwidth, y1); - glVertex2f(x1, y1 + height); - glVertex2f(x1 - halfwidth, y1); - glEnd(); + immBegin(fill ? GL_TRIANGLES : GL_LINE_LOOP, 3); + immVertex2f(pos, x1 + halfwidth, y1); + immVertex2f(pos, x1, y1 + height); + immVertex2f(pos, x1 - halfwidth, y1); + immEnd(); glDisable(fill ? GL_POLYGON_SMOOTH : GL_LINE_SMOOTH); } -static void ui_draw_colorband_handle_box(float x1, float y1, float x2, float y2, bool fill) +static void ui_draw_colorband_handle_box(unsigned int pos, float x1, float y1, float x2, float y2, bool fill) { - glBegin(fill ? GL_QUADS : GL_LINE_LOOP); - glVertex2f(x1, y1); - glVertex2f(x1, y2); - glVertex2f(x2, y2); - glVertex2f(x2, y1); - glEnd(); + immBegin(fill ? GL_QUADS : GL_LINE_LOOP, 4); + immVertex2f(pos, x1, y1); + immVertex2f(pos, x1, y2); + immVertex2f(pos, x2, y2); + immVertex2f(pos, x2, y1); + immEnd(); } static void ui_draw_colorband_handle( -const rcti *rect, float x, +unsigned int pos, const rcti *rect, float x, const float rgb[3], struct ColorManagedDisplay *display, bool active) { @@ -1103,17 +1103,18 @@ static void ui_draw_colorband_handle( y1 = floorf(y1 + 0.5f); if (active || half_width < min_width) { - glBegin(GL_LINES); - glColor3ub(0, 0, 0); - glVertex2f(x, y1); - glVertex2f(x, y2); - glEnd(); + immUniformColor3ub(0, 0, 0); + immBegin(GL_LINES, 2); + immVertex2f(pos, x, y1); + immVertex2f(pos, x, y2); + immEnd(); + setlinestyle(active ? 2 : 1); - glBegin(GL_LINES); - glColor3ub(200, 200, 200); - glVertex2f(x, y1); - glVertex2f(x, y2); - glEnd(); + immUniformColor3ub(200, 200, 200); + immBegin(GL_LINES, 2); + immVertex2f(pos, x, y1); + immVertex2f(pos, x, y2); + immEnd(); setlinestyle(0); /* hide handles when zoomed out too far */ @@ -1125,45 +1126,46 @@ static void ui_draw_colorband_handle( /* shift handle down */ y1 -= half_width; - glColor3ub(0, 0, 0); - ui_draw_colorband_handle_box(x - half_width, y1 - 1, x + half_width, y1 + height, false); + immUniformColor3ub(0, 0, 0); + ui_draw_colorband_handle_box(pos, x - half_width, y1 - 1, x + half_width, y1 + height, false); /* draw all triangles blended */ glEnable(GL_BLEND); - ui_draw_colorband_handle_tri(x, y1 + height, half_width, half_width, true); + ui_draw_colorband_handle_tri(
[Bf-blender-cvs] [cc26deef55] temp-blender2.8-stable: OpenGL immediate mode: fix Waveform Font color
Commit: cc26deef55f5c1ac895f641d2cc03d561649f1a4 Author: Clément Foucault Date: Tue Feb 7 22:40:01 2017 +0100 Branches: temp-blender2.8-stable https://developer.blender.org/rBcc26deef55f5c1ac895f641d2cc03d561649f1a4 OpenGL immediate mode: fix Waveform Font color === M source/blender/blenfont/BLF_api.h M source/blender/blenfont/intern/blf.c M source/blender/editors/interface/interface_draw.c === diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index 649ec9c5a4..1b967f889c 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -70,6 +70,7 @@ void BLF_color4ubv(int fontid, const unsigned char rgba[4]); void BLF_color3ubv(int fontid, const unsigned char rgb[3]); void BLF_color3ubv_alpha(int fontid, const unsigned char rgb[3], unsigned char alpha); void BLF_color3ub(int fontid, unsigned char r, unsigned char g, unsigned char b); +void BLF_color4f(int fontid, float r, float g, float b, float a); void BLF_color4fv(int fontid, const float rgba[4]); void BLF_color3f(int fontid, float r, float g, float b); void BLF_color3fv_alpha(int fontid, const float rgb[3], float alpha); diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 04b6eb0ad3..bc914083c0 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -503,6 +503,12 @@ void BLF_color4fv(int fontid, const float rgba[4]) } } +void BLF_color4f(int fontid, float r, float g, float b, float a) +{ + float rgba[4] = { r, g, b, a }; + BLF_color4fv(fontid, rgba); +} + void BLF_color3fv_alpha(int fontid, const float rgb[3], float alpha) { float rgba[4]; diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 32df2aaebb..1cd1921d12 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -764,8 +764,10 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), /* draw scale numbers first before binding any shader */ for (int i = 0; i < 6; i++) { char str[4]; + const int font_id = BLF_default(); BLI_snprintf(str, sizeof(str), "%-3d", i * 20); str[3] = '\0'; + BLF_color4f(font_id, 1.f, 1.f, 1.f, 0.08f); BLF_draw_default(rect.xmin + 1, yofs - 5 + (i / 5.f) * h, 0, str, sizeof(str) - 1); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [92a2b444b0] clay-engine: Added Lamp screen space visual
Commit: 92a2b444b034e41fd4997cb55ae59e5a82b319d2 Author: Clément Foucault Date: Thu Feb 2 14:17:29 2017 +0100 Branches: clay-engine https://developer.blender.org/rB92a2b444b034e41fd4997cb55ae59e5a82b319d2 Added Lamp screen space visual === M source/blender/draw/intern/DRW_render.h M source/blender/draw/intern/draw_cache.c M source/blender/draw/intern/draw_cache.h M source/blender/draw/intern/draw_manager.c M source/blender/draw/intern/draw_mode_pass.c M source/blender/gpu/CMakeLists.txt M source/blender/gpu/GPU_shader.h M source/blender/gpu/intern/gpu_shader.c A source/blender/gpu/shaders/gpu_shader_3D_lamp_vert.glsl === diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 8bd3cabf8d..ac57a05dd1 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -196,6 +196,8 @@ typedef enum { void DRW_viewport_init(const bContext *C, void **buffers, void **textures, void **passes); void DRW_viewport_matrix_get(float mat[4][4], DRWViewportMatrixType type); float *DRW_viewport_size_get(void); +float *DRW_viewport_screenvecs_get(void); +float *DRW_viewport_pixelsize_get(void); bool DRW_viewport_is_persp_get(void); bool DRW_viewport_cache_is_dirty(void); diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index de171df511..421d8ca54c 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -48,6 +48,7 @@ static struct DRWShapeCache{ Batch *drw_empty_sphere; Batch *drw_empty_cone; Batch *drw_arrows; + Batch *drw_lamp; } SHC = {NULL}; /* Quads */ @@ -372,6 +373,36 @@ Batch *DRW_cache_arrows_get(void) return SHC.drw_arrows; } +/* Lamps */ +Batch *DRW_cache_lamp_get(void) +{ +#define NSEGMENTS 8 + if (!SHC.drw_lamp) { + float v[3] = {0.0f, 0.0f, 0.0f}; + + /* Position Only 3D format */ + static VertexFormat format = { 0 }; + static unsigned pos_id; + if (format.attrib_ct == 0) { + pos_id = add_attrib(, "pos", GL_FLOAT, 3, KEEP_FLOAT); + } + + VertexBuffer *vbo = VertexBuffer_create_with_format(); + VertexBuffer_allocate_data(vbo, NSEGMENTS); + + for (int a = 0; a < NSEGMENTS; a++) { + v[0] = sinf((2.0f * M_PI * a) / ((float)NSEGMENTS)); + v[1] = cosf((2.0f * M_PI * a) / ((float)NSEGMENTS)); + v[2] = 0.0f; + setAttrib(vbo, pos_id, a, v); + } + + SHC.drw_lamp = Batch_create(GL_LINE_LOOP, vbo, NULL); + } + return SHC.drw_lamp; +#undef NSEGMENTS +} + /* Object Center */ Batch *DRW_cache_single_vert_get(void) { diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h index abe3ee7e77..b5d57e58a4 100644 --- a/source/blender/draw/intern/draw_cache.h +++ b/source/blender/draw/intern/draw_cache.h @@ -42,6 +42,9 @@ struct Batch *DRW_cache_empty_sphere_get(void); struct Batch *DRW_cache_empty_cone_get(void); struct Batch *DRW_cache_arrows_get(void); +/* Lamps */ +struct Batch *DRW_cache_lamp_get(void); + /* Meshes */ struct Batch *DRW_cache_wire_overlay_get(struct Object *ob); struct Batch *DRW_cache_wire_outline_get(struct Object *ob); diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 3389c00c0d..67d5609911 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -129,6 +129,8 @@ static struct DRWGlobalState{ ListBase bound_texs; int tex_bind_id; float size[2]; + float screenvecs[2][3]; + float pixsize; /* Current rendering context set by DRW_viewport_init */ const struct bContext *context; } DST = {NULL}; @@ -1051,6 +1053,16 @@ float *DRW_viewport_size_get(void) return [0]; } +float *DRW_viewport_screenvecs_get(void) +{ + return [0][0]; +} + +float *DRW_viewport_pixelsize_get(void) +{ + return +} + void DRW_viewport_init(const bContext *C, void **buffers, void **textures, void **passes) { RegionView3D *rv3d = CTX_wm_region_view3d(C); @@ -1070,6 +1082,15 @@ void DRW_viewport_init(const bContext *C, void **buffers, void **textures, void DST.current_fbl = (FramebufferList *)*buffers; DST.current_psl = (PassList *)*passes; + /* Refresh DST.screenvecs */ + copy_v3_v3(DST.screenvecs[0], rv3d->viewinv[0]); + copy_v3_v3(DST.screenvecs[1], rv3d->viewinv[1]); + normalize_v3(DST.screenvecs[0]); + normalize_v3(DST.screenvecs[1]); + + /* Re
[Bf-blender-cvs] [0ccfa297f9] clay-engine: Start of Lamp drawing
Commit: 0ccfa297f95eecd3613e019c29c017119c02d3da Author: Clément Foucault Date: Thu Feb 2 00:41:54 2017 +0100 Branches: clay-engine https://developer.blender.org/rB0ccfa297f95eecd3613e019c29c017119c02d3da Start of Lamp drawing === M source/blender/draw/intern/draw_manager.c M source/blender/draw/intern/draw_mode_pass.c === diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index e9ff6343b0..3389c00c0d 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -616,6 +616,11 @@ void DRW_draw_background(void) static void shgroup_set_state(DRWShadingGroup *shgroup) { if (shgroup->state) { + /* Blend */ + if (shgroup->state & DRW_STATE_BLEND) { + glEnable(GL_BLEND); + } + /* Wire width */ if (shgroup->state & DRW_STATE_WIRE) { glLineWidth(1.0f); @@ -634,6 +639,11 @@ static void shgroup_set_state(DRWShadingGroup *shgroup) else if (shgroup->state & DRW_STATE_STIPPLE_4) { setlinestyle(4); } + + if (shgroup->state & DRW_STATE_POINT) { + GPU_enable_program_point_size(); + glPointSize(5.0f); + } } } diff --git a/source/blender/draw/intern/draw_mode_pass.c b/source/blender/draw/intern/draw_mode_pass.c index b6876d0a1c..bad791f1fc 100644 --- a/source/blender/draw/intern/draw_mode_pass.c +++ b/source/blender/draw/intern/draw_mode_pass.c @@ -94,6 +94,11 @@ static DRWShadingGroup *arrows_transform; static DRWShadingGroup *arrows_group; static DRWShadingGroup *arrows_group_active; +/* Lamps */ +static DRWShadingGroup *lamp_center; +static DRWShadingGroup *lamp_groundpoint; +static DRWShadingGroup *lamp_groundline; + /* Helpers */ static DRWShadingGroup *relationship_lines; @@ -124,13 +129,50 @@ static DRWShadingGroup *shgroup_dynlines_uniform_color(DRWPass *pass, float colo return grp; } +static DRWShadingGroup *shgroup_dynpoints_uniform_color(DRWPass *pass, float color[4], float *size) +{ + GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_SMOOTH); + + DRWShadingGroup *grp = DRW_shgroup_create(sh, pass); + DRW_shgroup_uniform_vec4(grp, "color", color, 1); + DRW_shgroup_uniform_float(grp, "size", size, 1); + DRW_shgroup_dyntype_set(grp, DRW_DYN_POINTS); + DRW_shgroup_state_set(grp, DRW_STATE_POINT); + + return grp; +} + +static DRWShadingGroup *shgroup_groundlines_uniform_color(DRWPass *pass, float color[4]) +{ + GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_GROUNDLINE); + + DRWShadingGroup *grp = DRW_shgroup_create(sh, pass); + DRW_shgroup_uniform_vec4(grp, "color", color, 1); + DRW_shgroup_dyntype_set(grp, DRW_DYN_POINTS); + + return grp; +} + +static DRWShadingGroup *shgroup_groundpoints_uniform_color(DRWPass *pass, float color[4]) +{ + GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_GROUNDPOINT); + + DRWShadingGroup *grp = DRW_shgroup_create(sh, pass); + DRW_shgroup_uniform_vec4(grp, "color", color, 1); + DRW_shgroup_dyntype_set(grp, DRW_DYN_POINTS); + DRW_shgroup_state_set(grp, DRW_STATE_POINT); + return grp; +} + /* This Function setup the passes needed for the mode rendering. * The passes are populated by the rendering engine using the DRW_shgroup_* functions. */ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPass **non_meshes, DRWPass **ob_center) { + /* Theses are defined for the whole application so make sure they rely on global settings */ static float colorWire[4], colorWireEdit[4]; static float colorActive[4], colorSelect[4], colorTransform[4], colorGroup[4], colorGroupActive[4]; static float colorEmpty[4], colorLamp[4], colorCamera[4], colorSpeaker[4]; + static float lampCenterSize, colorLampNoAlpha[4]; UI_GetThemeColor4fv(TH_WIRE, colorWire); UI_GetThemeColor4fv(TH_WIRE_EDIT, colorWireEdit); @@ -139,10 +181,13 @@ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPa UI_GetThemeColor4fv(TH_TRANSFORM, colorTransform); UI_GetThemeColor4fv(TH_GROUP_ACTIVE, colorGroupActive); UI_GetThemeColor4fv(TH_GROUP, colorGroup); - UI_GetThemeColor4fv(OB_LAMP, colorLamp); - UI_GetThemeColor4fv(OB_SPEAKER, colorSpeaker); - UI_GetThemeColor4fv(OB_CAMERA, colorCamera); - UI_GetThemeColor4fv(OB_EMPTY, colorEmpty); + UI_GetThemeColor4fv(TH_LAMP, colorLamp); + UI_GetThemeColo
[Bf-blender-cvs] [6144721778] clay-engine: Groundline/GroundPoint shader for lights
Commit: 614472177899419fee19f08ba02ec8811391d25f Author: Clément Foucault Date: Thu Feb 2 00:41:14 2017 +0100 Branches: clay-engine https://developer.blender.org/rB614472177899419fee19f08ba02ec8811391d25f Groundline/GroundPoint shader for lights === M source/blender/gpu/CMakeLists.txt M source/blender/gpu/GPU_shader.h M source/blender/gpu/intern/gpu_shader.c A source/blender/gpu/shaders/gpu_shader_3D_groundline_geom.glsl A source/blender/gpu/shaders/gpu_shader_3D_groundline_vert.glsl A source/blender/gpu/shaders/gpu_shader_3D_groundpoint_vert.glsl === diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 7aeb67a224..08aab95d55 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -153,6 +153,10 @@ data_to_c_simple(shaders/gpu_shader_3D_flat_color_vert.glsl SRC) data_to_c_simple(shaders/gpu_shader_3D_smooth_color_vert.glsl SRC) data_to_c_simple(shaders/gpu_shader_3D_smooth_color_frag.glsl SRC) +data_to_c_simple(shaders/gpu_shader_3D_groundpoint_vert.glsl SRC) +data_to_c_simple(shaders/gpu_shader_3D_groundline_vert.glsl SRC) +data_to_c_simple(shaders/gpu_shader_3D_groundline_geom.glsl SRC) + data_to_c_simple(shaders/gpu_shader_point_uniform_color_frag.glsl SRC) data_to_c_simple(shaders/gpu_shader_point_uniform_color_smooth_frag.glsl SRC) data_to_c_simple(shaders/gpu_shader_point_uniform_color_outline_smooth_frag.glsl SRC) diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h index 8cc9433c6a..ad39f585d3 100644 --- a/source/blender/gpu/GPU_shader.h +++ b/source/blender/gpu/GPU_shader.h @@ -131,6 +131,9 @@ typedef enum GPUBuiltinShader { GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_SMOOTH, GPU_SHADER_3D_POINT_VARYING_SIZE_UNIFORM_COLOR, GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR, + /* lamp drawing */ + GPU_SHADER_3D_GROUNDPOINT, + GPU_SHADER_3D_GROUNDLINE, GPU_NUM_BUILTIN_SHADERS /* (not an actual shader) */ } GPUBuiltinShader; diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index 6370e4f7f8..fb32477f40 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -70,6 +70,10 @@ extern char datatoc_gpu_shader_3D_flat_color_vert_glsl[]; extern char datatoc_gpu_shader_3D_smooth_color_vert_glsl[]; extern char datatoc_gpu_shader_3D_smooth_color_frag_glsl[]; +extern char datatoc_gpu_shader_3D_groundpoint_vert_glsl[]; +extern char datatoc_gpu_shader_3D_groundline_vert_glsl[]; +extern char datatoc_gpu_shader_3D_groundline_geom_glsl[]; + extern char datatoc_gpu_shader_point_uniform_color_frag_glsl[]; extern char datatoc_gpu_shader_point_uniform_color_smooth_frag_glsl[]; extern char datatoc_gpu_shader_point_uniform_color_outline_smooth_frag_glsl[]; @@ -678,6 +682,11 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader) datatoc_gpu_shader_3D_smooth_color_frag_glsl }, [GPU_SHADER_3D_DEPTH_ONLY] = { datatoc_gpu_shader_3D_vert_glsl, datatoc_gpu_shader_depth_only_frag_glsl }, + [GPU_SHADER_3D_GROUNDPOINT] = { datatoc_gpu_shader_3D_groundpoint_vert_glsl, datatoc_gpu_shader_point_uniform_color_frag_glsl }, + [GPU_SHADER_3D_GROUNDLINE] = { datatoc_gpu_shader_3D_groundline_vert_glsl, + datatoc_gpu_shader_uniform_color_frag_glsl, + datatoc_gpu_shader_3D_groundline_geom_glsl }, + [GPU_SHADER_2D_POINT_FIXED_SIZE_UNIFORM_COLOR] = { datatoc_gpu_shader_2D_vert_glsl, datatoc_gpu_shader_point_uniform_color_frag_glsl }, [GPU_SHADER_2D_POINT_VARYING_SIZE_VARYING_COLOR] = diff --git a/source/blender/gpu/shaders/gpu_shader_3D_groundline_geom.glsl b/source/blender/gpu/shaders/gpu_shader_3D_groundline_geom.glsl new file mode 100644 index 00..f16fa21b34 --- /dev/null +++ b/source/blender/gpu/shaders/gpu_shader_3D_groundline_geom.glsl @@ -0,0 +1,16 @@ + +/* Make to be used with dynamic batching so no Model Matrix needed */ +uniform mat4 ViewProjectionMatrix; + +layout(points) in; +layout(line_strip, max_vertices = 2) out; + +void main() +{ + vec3 vert = gl_in[0].gl_Position.xyz; + gl_Position = ViewProjectionMatrix * vec4(vert.xyz, 1.0); + EmitVertex(); + gl_Position = ViewProjectionMatrix * vec4(vert.xy, 0.0, 1.0); + EmitVertex(); + EndPrimitive(); +} diff --git a/source/blender/gpu/shaders/gpu_shader_3D_groundline_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_groundline_vert.glsl new file mode 100644 index 00..60793bf56b --- /dev/null +++ b/source/blender/gpu/shaders
[Bf-blender-cvs] [b1add8e5bd] clay-engine: Fix assert
Commit: b1add8e5bd55222080da8dc539b782970a49f3a7 Author: Clément Foucault Date: Thu Feb 2 16:23:21 2017 +0100 Branches: clay-engine https://developer.blender.org/rBb1add8e5bd55222080da8dc539b782970a49f3a7 Fix assert === M source/blender/draw/intern/draw_cache.c === diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index 421d8ca54c..d3e422abfd 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -135,16 +135,21 @@ Batch *DRW_cache_circle_get(void) } VertexBuffer *vbo = VertexBuffer_create_with_format(); - VertexBuffer_allocate_data(vbo, CIRCLE_RESOL); + VertexBuffer_allocate_data(vbo, CIRCLE_RESOL * 2); for (int a = 0; a < CIRCLE_RESOL; a++) { v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[1] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[2] = 0.0f; - setAttrib(vbo, pos_id, a, v); + setAttrib(vbo, pos_id, a * 2, v); + + v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)); + v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)); + v[2] = 0.0f; + setAttrib(vbo, pos_id, a * 2 + 1, v); } - SHC.drw_circle = Batch_create(GL_LINE_LOOP, vbo, NULL); + SHC.drw_circle = Batch_create(GL_LINES, vbo, NULL); } return SHC.drw_circle; #undef CIRCLE_RESOL @@ -388,16 +393,21 @@ Batch *DRW_cache_lamp_get(void) } VertexBuffer *vbo = VertexBuffer_create_with_format(); - VertexBuffer_allocate_data(vbo, NSEGMENTS); + VertexBuffer_allocate_data(vbo, NSEGMENTS * 2); for (int a = 0; a < NSEGMENTS; a++) { v[0] = sinf((2.0f * M_PI * a) / ((float)NSEGMENTS)); v[1] = cosf((2.0f * M_PI * a) / ((float)NSEGMENTS)); v[2] = 0.0f; - setAttrib(vbo, pos_id, a, v); + setAttrib(vbo, pos_id, a * 2, v); + + v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)NSEGMENTS)); + v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)NSEGMENTS)); + v[2] = 0.0f; + setAttrib(vbo, pos_id, a * 2 + 1, v); } - SHC.drw_lamp = Batch_create(GL_LINE_LOOP, vbo, NULL); + SHC.drw_lamp = Batch_create(GL_LINES, vbo, NULL); } return SHC.drw_lamp; #undef NSEGMENTS ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b12d2fb922] clay-engine: Fix warnings
Commit: b12d2fb922c539915b054ebd0d9bb091f6768ee8 Author: Clément Foucault Date: Thu Feb 2 17:03:21 2017 +0100 Branches: clay-engine https://developer.blender.org/rBb12d2fb922c539915b054ebd0d9bb091f6768ee8 Fix warnings === M source/blender/draw/engines/clay/clay.c === diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c index e5188760c0..7be13c079f 100644 --- a/source/blender/draw/engines/clay/clay.c +++ b/source/blender/draw/engines/clay/clay.c @@ -565,7 +565,7 @@ static void CLAY_create_cache(CLAY_PassList *passes, const struct bContext *C) } struct Batch *geom; - bool do_outlines; + //bool do_outlines; switch (ob->type) { case OB_MESH: @@ -577,7 +577,7 @@ static void CLAY_create_cache(CLAY_PassList *passes, const struct bContext *C) //DRW_shgroup_wire_overlay(passes->wire_overlay_pass, ob); - do_outlines = ((ob->base_flag & BASE_SELECTED) != 0); + //do_outlines = ((ob->base_flag & BASE_SELECTED) != 0); //DRW_shgroup_wire_outline(passes->wire_outline_pass, ob, false, false, do_outlines); /* When encountering a new material : ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8641fa1397] clay-engine: Fix unfreed memory
Commit: 8641fa13972e79d17ba35fd35ee7bcf1518007ff Author: Clément Foucault Date: Thu Feb 2 17:15:26 2017 +0100 Branches: clay-engine https://developer.blender.org/rB8641fa13972e79d17ba35fd35ee7bcf1518007ff Fix unfreed memory === M source/blender/draw/intern/draw_cache.c M source/blender/draw/intern/draw_cache.h M source/blender/draw/intern/draw_manager.c === diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index d3e422abfd..b41c232847 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -51,6 +51,32 @@ static struct DRWShapeCache{ Batch *drw_lamp; } SHC = {NULL}; +void DRW_shape_cache_free(void) +{ + if (SHC.drw_single_vertice) + Batch_discard_all(SHC.drw_single_vertice); + if (SHC.drw_fullscreen_quad) + Batch_discard_all(SHC.drw_fullscreen_quad); + if (SHC.drw_plain_axes) + Batch_discard_all(SHC.drw_plain_axes); + if (SHC.drw_single_arrow) + Batch_discard_all(SHC.drw_single_arrow); + if (SHC.drw_single_arrow_line) + Batch_discard_all(SHC.drw_single_arrow_line); + if (SHC.drw_cube) + Batch_discard_all(SHC.drw_cube); + if (SHC.drw_circle) + Batch_discard_all(SHC.drw_circle); + if (SHC.drw_empty_sphere) + Batch_discard_all(SHC.drw_empty_sphere); + if (SHC.drw_empty_cone) + Batch_discard_all(SHC.drw_empty_cone); + if (SHC.drw_arrows) + Batch_discard_all(SHC.drw_arrows); + if (SHC.drw_lamp) + Batch_discard_all(SHC.drw_lamp); +} + /* Quads */ Batch *DRW_cache_fullscreen_quad_get(void) { diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h index b5d57e58a4..881fc2b529 100644 --- a/source/blender/draw/intern/draw_cache.h +++ b/source/blender/draw/intern/draw_cache.h @@ -29,6 +29,8 @@ struct Batch; struct Object; +void DRW_shape_cache_free(void); + /* Common Shapes */ struct Batch *DRW_cache_fullscreen_quad_get(void); struct Batch *DRW_cache_single_vert_get(void); diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 7fd32d07d3..b2766fb716 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1134,5 +1134,7 @@ void DRW_engines_free(void) { clay_engine_free(); + DRW_shape_cache_free(); + BLI_remlink(_engines, _clay_type); } \ No newline at end of file ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [c1057ac196] clay-engine: Fix ogl warnings.
Commit: c1057ac19641c8a08bec9d8885b0f8e7d885cf75 Author: Clément Foucault Date: Thu Feb 2 16:28:16 2017 +0100 Branches: clay-engine https://developer.blender.org/rBc1057ac19641c8a08bec9d8885b0f8e7d885cf75 Fix ogl warnings. === M source/blender/gpu/intern/gpu_texture.c === diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c index 9115922706..2cc709db3b 100644 --- a/source/blender/gpu/intern/gpu_texture.c +++ b/source/blender/gpu/intern/gpu_texture.c @@ -597,7 +597,13 @@ void GPU_texture_bind(GPUTexture *tex, int number) else GPU_invalid_tex_bind(tex->target_base); - glEnable(tex->target_base); /* TODO: remove this line once we're using GLSL everywhere */ + /* TODO: remove this lines */ + GLenum target = tex->target_base; + if (tex->target_base == GL_TEXTURE_1D_ARRAY) + target = GL_TEXTURE_2D; + if (tex->target_base == GL_TEXTURE_2D_ARRAY) + target = GL_TEXTURE_3D; + glEnable(target); if (number != 0) glActiveTexture(GL_TEXTURE0); @@ -619,7 +625,14 @@ void GPU_texture_unbind(GPUTexture *tex) glActiveTexture(GL_TEXTURE0 + tex->number); glBindTexture(tex->target_base, 0); - glDisable(tex->target_base); /* TODO: remove this line */ + + /* TODO: remove this lines */ + GLenum target = tex->target_base; + if (tex->target_base == GL_TEXTURE_1D_ARRAY) + target = GL_TEXTURE_2D; + if (tex->target_base == GL_TEXTURE_2D_ARRAY) + target = GL_TEXTURE_3D; + glDisable(target); if (tex->number != 0) glActiveTexture(GL_TEXTURE0); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f695c9861f] clay-engine: Bypass wires.
Commit: f695c9861fe3597a21a825789e1cbaa9c26b79b1 Author: Clément Foucault Date: Thu Feb 2 16:54:15 2017 +0100 Branches: clay-engine https://developer.blender.org/rBf695c9861fe3597a21a825789e1cbaa9c26b79b1 Bypass wires. === M source/blender/draw/engines/clay/clay.c === diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c index e1b38926a0..e5188760c0 100644 --- a/source/blender/draw/engines/clay/clay.c +++ b/source/blender/draw/engines/clay/clay.c @@ -542,7 +542,7 @@ static void CLAY_create_cache(CLAY_PassList *passes, const struct bContext *C) MaterialRuntimeClay **runtime; DRW_render_settings_get(NULL, RE_engine_id_BLENDER_CLAY, (void ***)); - passes->clay_pass = DRW_pass_create("Clay Pass", DRW_STATE_WRITE_COLOR); + passes->clay_pass = DRW_pass_create("Clay Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS); default_shgrp = CLAY_shgroup_create(passes->clay_pass, &(*runtime)->material_id); DRW_shgroup_uniform_block(default_shgrp, "material_block", data.mat_ubo, 0); @@ -575,10 +575,10 @@ static void CLAY_create_cache(CLAY_PassList *passes, const struct bContext *C) DRW_shgroup_call_add(depthbatch, geom, ob->obmat); DRW_shgroup_call_add(default_shgrp, geom, ob->obmat); - DRW_shgroup_wire_overlay(passes->wire_overlay_pass, ob); + //DRW_shgroup_wire_overlay(passes->wire_overlay_pass, ob); do_outlines = ((ob->base_flag & BASE_SELECTED) != 0); - DRW_shgroup_wire_outline(passes->wire_outline_pass, ob, false, false, do_outlines); + //DRW_shgroup_wire_outline(passes->wire_outline_pass, ob, false, false, do_outlines); /* When encountering a new material : * - Create new Batch @@ -650,8 +650,8 @@ static void CLAY_view_draw(RenderEngine *UNUSED(engine), const struct bContext * /* Pass 4 : Overlays */ DRW_framebuffer_texture_attach(buffers->default_fb, textures->depth, 0); - DRW_draw_pass(passes->wire_overlay_pass); - DRW_draw_pass(passes->wire_outline_pass); + //DRW_draw_pass(passes->wire_overlay_pass); + //DRW_draw_pass(passes->wire_outline_pass); DRW_draw_pass(passes->non_meshes_pass); DRW_draw_pass(passes->ob_center_pass); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e572cf1239] clay-engine: Fix depth not cleared
Commit: e572cf1239fa6918b045f3ba4d4f1e0e86503a2f Author: Clément Foucault Date: Thu Feb 2 16:54:34 2017 +0100 Branches: clay-engine https://developer.blender.org/rBe572cf1239fa6918b045f3ba4d4f1e0e86503a2f Fix depth not cleared === M source/blender/draw/intern/draw_manager.c === diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 67d5609911..7fd32d07d3 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -577,6 +577,10 @@ DRWShadingGroup *DRW_pass_nth_shgroup_get(DRWPass *pass, int n) void DRW_draw_background(void) { + /* Just to make sure */ + glDepthMask(GL_TRUE); + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + if (UI_GetThemeValue(TH_SHOW_BACK_GRAD)) { /* Gradient background Color */ gpuMatrixBegin3D(); /* TODO: finish 2D API */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e58359c26f] blender2.8: OpenGL immediate mode: interface_draw.c (cont)
Commit: e58359c26f2b68b04b28cbcd69c53f19818aa5e1 Author: Clément Foucault Date: Mon Feb 6 15:19:45 2017 +0100 Branches: blender2.8 https://developer.blender.org/rBe58359c26f2b68b04b28cbcd69c53f19818aa5e1 OpenGL immediate mode: interface_draw.c (cont) Replaced GL_POLYGON in various places. Ported UI_draw_roundbox_unfilled === M source/blender/editors/animation/anim_channels_defines.c M source/blender/editors/include/UI_interface.h M source/blender/editors/interface/interface_draw.c M source/blender/editors/interface/interface_panel.c M source/blender/editors/screen/area.c M source/blender/editors/space_node/node_draw.c === diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 26674278a5..4163cbfe11 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -124,7 +124,7 @@ static void acf_generic_root_backdrop(bAnimContext *ac, bAnimListElem *ale, floa /* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */ UI_draw_roundbox_corner_set((expanded) ? UI_CNR_TOP_LEFT : (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT)); - UI_draw_roundbox_gl_mode_3fvAlpha(GL_POLYGON, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8, color, 1.0f); + UI_draw_roundbox_gl_mode_3fvAlpha(GL_TRIANGLE_FAN, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8, color, 1.0f); } @@ -442,7 +442,7 @@ static void acf_summary_backdrop(bAnimContext *ac, bAnimListElem *ale, float ymi * - special hack: make the top a bit higher, since we are first... */ UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT); - UI_draw_roundbox_gl_mode_3fvAlpha(GL_POLYGON, 0, yminc - 2, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8, color, 1.0f); + UI_draw_roundbox_gl_mode_3fvAlpha(GL_TRIANGLE_FAN, 0, yminc - 2, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8, color, 1.0f); } /* name for summary entries */ @@ -831,7 +831,7 @@ static void acf_group_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc /* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */ UI_draw_roundbox_corner_set(expanded ? UI_CNR_TOP_LEFT : (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT)); - UI_draw_roundbox_gl_mode_3fvAlpha(GL_POLYGON, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8, color, 1.0f); + UI_draw_roundbox_gl_mode_3fvAlpha(GL_TRIANGLE_FAN, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8, color, 1.0f); } /* name for group entries */ @@ -1087,7 +1087,7 @@ static void acf_nla_controls_backdrop(bAnimContext *ac, bAnimListElem *ale, floa /* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */ UI_draw_roundbox_corner_set(expanded ? UI_CNR_TOP_LEFT : (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT)); - UI_draw_roundbox_gl_mode_3fvAlpha(GL_POLYGON, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 5, color, 1.0f); + UI_draw_roundbox_gl_mode_3fvAlpha(GL_TRIANGLE_FAN, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 5, color, 1.0f); } /* name for nla controls expander entries */ @@ -3441,7 +3441,7 @@ static void acf_nlaaction_backdrop(bAnimContext *ac, bAnimListElem *ale, float y /* draw slightly shifted up vertically to look like it has more separation from other channels, * but we then need to slightly shorten it so that it doesn't look like it overlaps */ - UI_draw_roundbox_gl_mode(GL_POLYGON, offset, yminc + NLACHANNEL_SKIP, (float)v2d->cur.xmax, ymaxc + NLACHANNEL_SKIP - 1, 8, color); + UI_draw_roundbox_gl_mode(GL_TRIANGLE_FAN, offset, yminc + NLACHANNEL_SKIP, (float)v2d->cur.xmax, ymaxc + NLACHANNEL_SKIP - 1, 8, color); } /* name for nla action entries */ diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 5e27dc12a1..a4bd4b8010 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -311,13 +311,13 @@ typedef enum { void UI_draw_roundbox(float minx, float miny, float maxx, float maxy, float rad, const float color[4]); void UI_draw_roundbox_corner_set(int type); int UI_draw_roundbox_corner_get(void); -void UI_draw_roundbox_unfilled(float minx, float miny, float maxx, float maxy, float rad); +void UI_draw_roundbox_unfilled(float minx, float miny, float maxx, float maxy, float rad, const float color[4]); void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx, float maxy); void UI_draw_roundbox_gl_mode
[Bf-blender-cvs] [15eb105c0b] temp-blender2.8-stable: OpenGL immediate mode: interface_draw.c (cont)
Commit: 15eb105c0b9678a18cc96509c80b5a5796e40479 Author: Clément Foucault Date: Wed Feb 8 12:01:03 2017 +0100 Branches: temp-blender2.8-stable https://developer.blender.org/rB15eb105c0b9678a18cc96509c80b5a5796e40479 OpenGL immediate mode: interface_draw.c (cont) ui_draw_but_CURVE === M source/blender/editors/interface/interface_draw.c === diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index b1f4db3ff7..6a9da26770 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -1339,35 +1339,39 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect) immUnbindProgram(); } -static void ui_draw_but_curve_grid(const rcti *rect, float zoomx, float zoomy, float offsx, float offsy, float step) +static void ui_draw_but_curve_grid(unsigned int pos, const rcti *rect, float zoomx, float zoomy, float offsx, float offsy, float step) { - glBegin(GL_LINES); float dx = step * zoomx; float fx = rect->xmin + zoomx * (-offsx); if (fx > rect->xmin) fx -= dx * (floorf(fx - rect->xmin)); - while (fx < rect->xmax) { - glVertex2f(fx, rect->ymin); - glVertex2f(fx, rect->ymax); - fx += dx; - } float dy = step * zoomy; float fy = rect->ymin + zoomy * (-offsy); if (fy > rect->ymin) fy -= dy * (floorf(fy - rect->ymin)); + + float line_count = floorf((rect->xmax - fx) / dx) + 1.0f + + floorf((rect->ymax - fy) / dy) + 1.0f; + + immBegin(GL_LINES, (int)line_count * 2); + while (fx < rect->xmax) { + immVertex2f(pos, fx, rect->ymin); + immVertex2f(pos, fx, rect->ymax); + fx += dx; + } while (fy < rect->ymax) { - glVertex2f(rect->xmin, fy); - glVertex2f(rect->xmax, fy); + immVertex2f(pos, rect->xmin, fy); + immVertex2f(pos, rect->xmax, fy); fy += dy; } - glEnd(); + immEnd(); } static void gl_shaded_color(unsigned char *col, int shade) { - glColor3ub(col[0] - shade > 0 ? col[0] - shade : 0, - col[1] - shade > 0 ? col[1] - shade : 0, - col[2] - shade > 0 ? col[2] - shade : 0); + immUniformColor3ub(col[0] - shade > 0 ? col[0] - shade : 0, + col[1] - shade > 0 ? col[1] - shade : 0, + col[2] - shade > 0 ? col[2] - shade : 0); } void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti *rect) @@ -1403,10 +1407,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti float zoomy = (BLI_rcti_size_y(rect) - 2.0f) / BLI_rctf_size_y(>curr); float offsx = cumap->curr.xmin - (1.0f / zoomx); float offsy = cumap->curr.ymin - (1.0f / zoomy); - - glLineWidth(1.0f); - /* backdrop */ + /* Do this first to not mess imm context */ if (but->a1 == UI_GRAD_H) { /* magic trigger for curve backgrounds */ float col[3] = {0.0f, 0.0f, 0.0f}; /* dummy arg */ @@ -1419,43 +1421,52 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti }; ui_draw_gradient(, col, UI_GRAD_H, 1.0f); + } + + glLineWidth(1.0f); + + VertexFormat *format = immVertexFormat(); + unsigned int pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + /* backdrop */ + if (but->a1 == UI_GRAD_H) { /* grid, hsv uses different grid */ glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor4ub(0, 0, 0, 48); - ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 0.166f); + immUniformColor4ub(0, 0, 0, 48); + ui_draw_but_curve_grid(pos, rect, zoomx, zoomy, offsx, offsy, 0.166f); glDisable(GL_BLEND); } else { if (cumap->flag & CUMA_DO_CLIP) { gl_shaded_color((unsigned char *)wcol->inner, -20); - glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); - glColor3ubv((unsigned char *)wcol->inner); - glRectf(rect->xmin + zoomx * (cumap->clipr.xmin - offsx), - rect->ymin + zoomy * (cumap->clipr.ymin - offsy), -
[Bf-blender-cvs] [8a22429db2] clay-engine: Change settings order
Commit: 8a22429db20bc1e0317f9fcda6643a2e2e501663 Author: Clément Foucault Date: Fri Feb 3 12:47:45 2017 +0100 Branches: clay-engine https://developer.blender.org/rB8a22429db20bc1e0317f9fcda6643a2e2e501663 Change settings order === M release/scripts/startup/bl_ui/properties_collection.py === diff --git a/release/scripts/startup/bl_ui/properties_collection.py b/release/scripts/startup/bl_ui/properties_collection.py index 018a720737..e9651ba536 100644 --- a/release/scripts/startup/bl_ui/properties_collection.py +++ b/release/scripts/startup/bl_ui/properties_collection.py @@ -91,8 +91,8 @@ class COLLECTION_PT_clay_settings(CollectionButtonsPanel, Panel): settings = collection.get_engine_settings() col = layout.column() -col.template_icon_view(settings, "matcap_icon") col.prop(settings, "type") +col.template_icon_view(settings, "matcap_icon") col.prop(settings, "matcap_rotation") col.prop(settings, "matcap_hue") col.prop(settings, "matcap_saturation") ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [0ee52a5741] clay-engine: Get rid of runtime data struct.
Commit: 0ee52a5741a1fd831efff0d454bab3c6b00e0d1b Author: Clément Foucault Date: Fri Feb 3 13:00:15 2017 +0100 Branches: clay-engine https://developer.blender.org/rB0ee52a5741a1fd831efff0d454bab3c6b00e0d1b Get rid of runtime data struct. === M source/blender/blenkernel/intern/material.c M source/blender/blenkernel/intern/scene.c M source/blender/blenloader/intern/readfile.c M source/blender/draw/DRW_engine.h M source/blender/draw/engines/clay/clay.c M source/blender/draw/intern/DRW_render.h M source/blender/draw/intern/draw_manager.c M source/blender/makesdna/DNA_material_types.h M source/blender/makesdna/DNA_scene_types.h M source/blender/makesrna/intern/rna_scene.c === diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 89af048f73..435504859a 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -113,8 +113,6 @@ void BKE_material_free(Material *ma) BKE_previewimg_free(>preview); for (MaterialEngineSettings *mes = ma->engines_settings.first; mes; mes = mes->next) { - if (mes->runtime) - MEM_SAFE_FREE(mes->runtime); if (mes->data) MEM_SAFE_FREE(mes->data); } diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 807496d88e..cc136e8e74 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -570,8 +570,6 @@ void BKE_scene_free(Scene *sce) /* Runtime Engine Data */ for (RenderEngineSettings *res = sce->engines_settings.first; res; res = res->next) { - if (res->runtime) - MEM_freeN(res->runtime); if (res->data) MEM_freeN(res->data); } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index cb69d54fc4..9206f4b65e 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3994,7 +3994,6 @@ static void direct_link_material(FileData *fd, Material *ma) link_list(fd, >engines_settings); for (mes = ma->engines_settings.first; mes; mes = mes->next) { - mes->runtime = NULL; mes->data = newdataadr(fd, mes->data); } } @@ -6234,7 +6233,6 @@ static void direct_link_scene(FileData *fd, Scene *sce) link_list(fd, >engines_settings); for (res = sce->engines_settings.first; res; res = res->next) { - res->runtime = NULL; res->data = newdataadr(fd, res->data); } } diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h index 05222574ae..4f86e3fcd9 100644 --- a/source/blender/draw/DRW_engine.h +++ b/source/blender/draw/DRW_engine.h @@ -39,7 +39,7 @@ void DRW_engines_free(void); void DRW_pass_free(struct DRWPass *pass); /* Settings */ -void *DRW_material_settings_get(struct Material *ma, const char *engine_name, void ***runtime); -void *DRW_render_settings_get(struct Scene *scene, const char *engine_name, void ***runtime); +void *DRW_material_settings_get(struct Material *ma, const char *engine_name); +void *DRW_render_settings_get(struct Scene *scene, const char *engine_name); #endif /* __DRW_ENGINE_H__ */ \ No newline at end of file diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c index 7be13c079f..3bdd48d319 100644 --- a/source/blender/draw/engines/clay/clay.c +++ b/source/blender/draw/engines/clay/clay.c @@ -84,8 +84,10 @@ static struct CLAY_data { } data = {NULL}; /* CLAY_data.ubo_flag */ -#define CLAY_UBO_CLEAR (1 << 0) -#define CLAY_UBO_REFRESH (1 << 1) +enum { + CLAY_UBO_CLEAR= (1 << 0), + CLAY_UBO_REFRESH = (1 << 1), +}; /* keep it under MAX_BUFFERS */ typedef struct CLAY_FramebufferList{ @@ -105,9 +107,11 @@ typedef struct CLAY_TextureList{ } CLAY_TextureList; /* for clarity follow the same layout as CLAY_TextureList */ -#define SCENE_COLOR 0 -#define SCENE_DEPTH 1 -#define SCENE_DEPTH_LOW 2 +enum { + SCENE_COLOR, + SCENE_DEPTH, + SCENE_DEPTH_LOW, +}; /* keep it under MAX_PASSES */ typedef struct CLAY_PassList{ @@ -268,8 +272,10 @@ MaterialEngineSettings *CLAY_material_settings_create(void) return (MaterialEngineSettings *)settings; } -static void CLAY_engine_init(void) +static void CLAY_engine_init(const bContext *C) { + Main *bmain = CTX_data_main(C); + /* Create Texture Array */ if (!data.matcap_array) { Previe
[Bf-blender-cvs] [6cdb3845a3] clay-engine: Added collection settings getter/setter
Commit: 6cdb3845a351ee9437030bd50ca7a7124953e097 Author: Clément Foucault Date: Fri Feb 3 12:51:22 2017 +0100 Branches: clay-engine https://developer.blender.org/rB6cdb3845a351ee9437030bd50ca7a7124953e097 Added collection settings getter/setter === M source/blender/blenkernel/BKE_layer.h M source/blender/blenkernel/intern/layer.c === diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h index e796ef93fd..184f7b9afc 100644 --- a/source/blender/blenkernel/BKE_layer.h +++ b/source/blender/blenkernel/BKE_layer.h @@ -105,6 +105,10 @@ void BKE_layer_collection_engine_settings_free(struct ListBase *lb); void BKE_collection_engine_property_add_float(struct CollectionEngineSettings *ces, const char *name, float value); void BKE_collection_engine_property_add_int(struct CollectionEngineSettings *ces, const char *name, int value); struct CollectionEngineProperty *BKE_collection_engine_property_get(struct CollectionEngineSettings *ces, const char *name); +int BKE_collection_engine_property_value_get_int(struct CollectionEngineSettings *ces, const char *name); +int BKE_collection_engine_property_value_get_float(struct CollectionEngineSettings *ces, const char *name); +void BKE_collection_engine_property_value_set_int(struct CollectionEngineSettings *ces, const char *name, int value); +void BKE_collection_engine_property_value_set_float(struct CollectionEngineSettings *ces, const char *name, float value); /* iterators */ diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index 4b28eb99f0..7e4d78a454 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -739,6 +739,34 @@ CollectionEngineProperty *BKE_collection_engine_property_get(CollectionEngineSet return BLI_findstring(>properties, name, offsetof(CollectionEngineProperty, name)); } +int BKE_collection_engine_property_value_get_int(CollectionEngineSettings *ces, const char *name) +{ + CollectionEnginePropertyInt *prop; + prop = (CollectionEnginePropertyInt *)BLI_findstring(>properties, name, offsetof(CollectionEngineProperty, name)); + return prop->value; +} + +int BKE_collection_engine_property_value_get_float(CollectionEngineSettings *ces, const char *name) +{ + CollectionEnginePropertyFloat *prop; + prop = (CollectionEnginePropertyFloat *)BLI_findstring(>properties, name, offsetof(CollectionEngineProperty, name)); + return prop->value; +} + +void BKE_collection_engine_property_value_set_int(CollectionEngineSettings *ces, const char *name, int value) +{ + CollectionEnginePropertyInt *prop; + prop = (CollectionEnginePropertyInt *)BLI_findstring(>properties, name, offsetof(CollectionEngineProperty, name)); + prop->value = value; +} + +void BKE_collection_engine_property_value_set_float(CollectionEngineSettings *ces, const char *name, float value) +{ + CollectionEnginePropertyFloat *prop; + prop = (CollectionEnginePropertyFloat *)BLI_findstring(>properties, name, offsetof(CollectionEngineProperty, name)); + prop->value = value; +} + /* -- */ /* Iterators */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [520ced4ad5] blender2.8: Modifications to GPU_texture:
Commit: 520ced4ad504bfcbcf0e86ff07651736dc51b8f0 Author: Clément Foucault Date: Fri Feb 3 16:01:32 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB520ced4ad504bfcbcf0e86ff07651736dc51b8f0 Modifications to GPU_texture: -Remove NPOT check as it should be supported by default with OGL 3.3 -All custom texture creation follow the same path now -Now explicit texture format is required when creating a custom texture (Non RGBA8) -Support for arrays of textures Reviewers: dfelinto, merwin Differential Revision: https://developer.blender.org/D2452 === M source/blender/editors/space_view3d/drawvolume.c M source/blender/gpu/GPU_texture.h M source/blender/gpu/intern/gpu_codegen.c M source/blender/gpu/intern/gpu_compositing.c M source/blender/gpu/intern/gpu_draw.c M source/blender/gpu/intern/gpu_framebuffer.c M source/blender/gpu/intern/gpu_material.c M source/blender/gpu/intern/gpu_texture.c M source/blender/gpu/intern/gpu_viewport.c === diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c index 27ecbf83db..debdcb58d7 100644 --- a/source/blender/editors/space_view3d/drawvolume.c +++ b/source/blender/editors/space_view3d/drawvolume.c @@ -160,7 +160,7 @@ static GPUTexture *create_field_texture(SmokeDomainSettings *sds) default: return NULL; } - return GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2], 1, field); + return GPU_texture_create_3D_custom(sds->res[0], sds->res[1], sds->res[2], 1, GPU_R8, field, NULL); } typedef struct VolumeSlicer { diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h index 756fe79151..a8df80cd62 100644 --- a/source/blender/gpu/GPU_texture.h +++ b/source/blender/gpu/GPU_texture.h @@ -55,25 +55,112 @@ typedef struct GPUTexture GPUTexture; * - if created with from_blender, will not free the texture */ -typedef enum GPUHDRType { - GPU_HDR_NONE = 0, - GPU_HDR_HALF_FLOAT = 1, - GPU_HDR_FULL_FLOAT = (1 << 1), -} GPUHDRType; +/* Wrapper to supported OpenGL/Vulkan texture internal storage + * If you need a type just uncomment it. Be aware that some formats + * are not supported by renderbuffers. All of the following formats + * are part of the OpenGL 3.3 core + * specification. */ +typedef enum GPUTextureFormat { + /* Formats texture & renderbuffer */ + GPU_RGBA16F, + GPU_RGBA8, + GPU_RG32F, + GPU_RG16F, + GPU_R8, +#if 0 + GPU_RGBA32F, + GPU_RGBA32I, + GPU_RGBA32UI, + GPU_RGBA16, + GPU_RGBA16I, + GPU_RGBA16UI, + GPU_RGBA8I, + GPU_RGBA8UI, + GPU_RG32I, + GPU_RG32UI, + GPU_RG16, + GPU_RG16I, + GPU_RG16UI, + GPU_RG8, + GPU_RG8I, + GPU_RG8UI, + GPU_R32F, + GPU_R32I, + GPU_R32UI, + GPU_R16F, + GPU_R16I, + GPU_R16UI, + GPU_R16, + GPU_R8I, + GPU_R8UI, +#endif + + /* Special formats texture & renderbuffer */ +#if 0 + GPU_R11F_G11F_B10F, + GPU_RGB10_A2, + GPU_RGB10_A2UI, + GPU_DEPTH32F_STENCIL8, + GPU_DEPTH24_STENCIL8, +#endif + + /* Texture only format */ +#if 0 + GPU_RGBA16_SNORM, + GPU_RGBA8_SNORM, + GPU_RGB32F, + GPU_RGB32I, + GPU_RGB32UI, + GPU_RGB16_SNORM, + GPU_RGB16F, + GPU_RGB16I, + GPU_RGB16UI, + GPU_RGB16, + GPU_RGB8_SNORM, + GPU_RGB8, + GPU_RGB8I, + GPU_RGB8UI, + GPU_RG16_SNORM, + GPU_RG8_SNORM, + GPU_R16_SNORM, + GPU_R8_SNORM, +#endif + + /* Special formats texture only */ +#if 0 + GPU_SRGB8_A8, + GPU_SRGB8, + GPU_RGB9_E5, + GPU_COMPRESSED_RG_RGTC2, + GPU_COMPRESSED_SIGNED_RG_RGTC2, + GPU_COMPRESSED_RED_RGTC1, + GPU_COMPRESSED_SIGNED_RED_RGTC1, +#endif + + /* Depth Formats */ + GPU_DEPTH_COMPONENT32F, + GPU_DEPTH_COMPONENT24, + GPU_DEPTH_COMPONENT16, +} GPUTextureFormat; GPUTexture *GPU_texture_create_1D(int w, const float *pixels, char err_out[256]); -GPUTexture *GPU_texture_create_2D(int w, int h, const float *pixels, GPUHDRType hdr, char err_out[256]); -GPUTexture *GPU_texture_create_3D(int w, int h, int depth, int channels, const float *fpixels); +GPUTexture *GPU_texture_create_1D_custom( +int w, int channels, GPUTextureFormat data_type, const float *pixels, char err_out[256]); +GPUTexture *GPU_texture_create_2D(int w, int h, const float *pixels, char err_out[256]); +GPUTexture *GPU_texture_create_2D_custom( +int w, int h, int channels, GPUTextureFormat data_type, const float *pixels, char err_out[256]); +GPUTexture *GPU_texture_create_2D_multisample(int w,
[Bf-blender-cvs] [7203aa24f9] clay-engine: New CMake flag for Clay Engine
Commit: 7203aa24f99830ef022cf78874d59e4322b231a0 Author: Clément Foucault Date: Fri Feb 3 14:38:11 2017 +0100 Branches: clay-engine https://developer.blender.org/rB7203aa24f99830ef022cf78874d59e4322b231a0 New CMake flag for Clay Engine === M CMakeLists.txt M source/blender/draw/CMakeLists.txt M source/blender/draw/engines/clay/clay.c M source/blender/draw/intern/draw_manager.c M source/blender/makesrna/intern/CMakeLists.txt M source/blender/makesrna/intern/rna_material.c M source/blender/makesrna/intern/rna_scene.c === diff --git a/CMakeLists.txt b/CMakeLists.txt index de01be1d29..b1a9d6fcf3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -165,6 +165,7 @@ option_defaults_init( _init_FFTW3 _init_GAMEENGINE _init_OPENSUBDIV + _init_CLAY_ENGINE ) # customize... @@ -186,6 +187,7 @@ elseif(WIN32) elseif(APPLE) set(_init_JACK OFF) set(_init_OPENSUBDIV OFF) + set(_init_CLAY_ENGINEOFF) endif() @@ -242,6 +244,8 @@ endif() option(WITH_PLAYER"Build Player" OFF) option(WITH_OPENCOLORIO "Enable OpenColorIO color management" ${_init_OPENCOLORIO}) +option(WITH_CLAY_ENGINE"Enable New Clay engine (Breaks Mac and Intel compatibility)" _init_CLAY_ENGINE) + # Compositor option(WITH_COMPOSITOR "Enable the tile based nodal compositor" ON) diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 6cf358e8c1..d5b54e8a74 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -63,6 +63,10 @@ set(SRC ./DRW_engine.h ) +if(WITH_CLAY_ENGINE) + add_definitions(-DWITH_CLAY_ENGINE) +endif() + data_to_c_simple(engines/clay/shaders/clay_frag.glsl SRC) data_to_c_simple(engines/clay/shaders/clay_vert.glsl SRC) data_to_c_simple(engines/clay/shaders/ssao_alchemy.glsl SRC) diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c index 3bdd48d319..f443606f11 100644 --- a/source/blender/draw/engines/clay/clay.c +++ b/source/blender/draw/engines/clay/clay.c @@ -34,7 +34,7 @@ #include "UI_interface_icons.h" #include "clay.h" - +#ifdef WITH_CLAY_ENGINE /* Shaders */ extern char datatoc_clay_frag_glsl[]; @@ -719,3 +719,4 @@ RenderEngineType viewport_clay_type = { NULL, NULL, NULL, NULL, _view_draw, NULL, _collection_settings_create, {NULL, NULL, NULL} }; +#endif \ No newline at end of file diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index ed626d1080..729d9d19ce 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -617,7 +617,7 @@ void DRW_draw_background(void) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } } - +#ifdef WITH_CLAY_ENGINE /* Only alter the state (does not reset it like set_state() ) */ static void shgroup_set_state(DRWShadingGroup *shgroup) { @@ -928,15 +928,15 @@ void DRW_state_reset(void) state |= DRW_STATE_DEPTH_LESS; set_state(state); } - +#endif /* ** Settings **/ - void *DRW_material_settings_get(Material *ma, const char *engine_name) { MaterialEngineSettings *ms = NULL; ms = BLI_findstring(>engines_settings, engine_name, offsetof(MaterialEngineSettings, name)); +#ifdef WITH_CLAY_ENGINE /* If the settings does not exists yet, create it */ if (ms == NULL) { ms = MEM_callocN(sizeof(RenderEngineSettings), "RenderEngineSettings"); @@ -954,6 +954,9 @@ void *DRW_material_settings_get(Material *ma, const char *engine_name) BLI_addtail(>engines_settings, ms); } +#else + return NULL; +#endif return ms->data; } @@ -968,6 +971,7 @@ void *DRW_render_settings_get(Scene *scene, const char *engine_name) rs = BLI_findstring(>engines_settings, engine_name, offsetof(RenderEngineSettings, name)); +#ifdef WITH_CLAY_ENGINE /* If the settings does not exists yet, create it */ if (rs == NULL) { rs = MEM_callocN(sizeof(RenderEngineSettings), "RenderEngineSettings"); @@ -985,10 +989,12 @@ void *DRW_render_settings_get(Scene *scene, const char *engine_name) BLI_addtail(>engines_settings, rs); } +#else + return NULL; +#endif return rs->data; } - /* ** Framebuffers **/ void DRW_framebuffer_init(struct GPUFrameBuffer **fb, int width, int height, DRWFboTex
[Bf-blender-cvs] [9fb97e3f85] clay-engine: Fix hang infinite loop
Commit: 9fb97e3f85e973e8138af067bed73be7772a00d4 Author: Clément Foucault Date: Fri Feb 3 14:37:50 2017 +0100 Branches: clay-engine https://developer.blender.org/rB9fb97e3f85e973e8138af067bed73be7772a00d4 Fix hang infinite loop === M source/blender/render/intern/source/external_engine.c === diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c index eeb075c572..1744d88a14 100644 --- a/source/blender/render/intern/source/external_engine.c +++ b/source/blender/render/intern/source/external_engine.c @@ -92,7 +92,7 @@ void RE_engines_init(void) { RE_engines_register(NULL, _render_type); #ifdef WITH_GAMEENGINE - RE_engines_register(NULL, _render_type); + RE_engines_register(NULL, _game_type); #endif DRW_engines_init(); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [4a84884e99] clay-engine: Fix warnings
Commit: 4a84884e9936dcba4c22b815828e29ed43cfafb0 Author: Clément Foucault Date: Fri Feb 3 14:52:33 2017 +0100 Branches: clay-engine https://developer.blender.org/rB4a84884e9936dcba4c22b815828e29ed43cfafb0 Fix warnings === M source/blender/makesrna/intern/rna_material.c M source/blender/makesrna/intern/rna_scene.c === diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index fd934fe468..4d3e3ffca2 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -315,8 +315,8 @@ static void rna_MaterialTextureSlot_use_set(PointerRNA *ptr, int value) static StructRNA *rna_MaterialEngineSettings_refine(PointerRNA *ptr) { - MaterialEngineSettings *mes = (MaterialEngineSettings *)ptr->data; #ifdef WITH_CLAY_ENGINE + MaterialEngineSettings *mes = (MaterialEngineSettings *)ptr->data; if (STREQ(mes->name, RE_engine_id_BLENDER_CLAY)) { return _MaterialEngineSettingsClay; } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 39d93648a6..08ac178383 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1878,9 +1878,9 @@ static void rna_GameSettings_exit_key_set(PointerRNA *ptr, int value) static StructRNA *rna_RenderEngineSettings_refine(PointerRNA *ptr) { +#ifdef WITH_CLAY_ENGINE RenderEngineSettings *res = (RenderEngineSettings *)ptr->data; -#ifdef WITH_CLAY_ENGINE if (STREQ(res->name, RE_engine_id_BLENDER_CLAY)) { return _RenderEngineSettingsClay; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [71c8db2a0c] clay-engine: Build Clay engine by default
Commit: 71c8db2a0c7e47150f2386b46f661141d73ff4cd Author: Clément Foucault Date: Fri Feb 3 17:51:04 2017 +0100 Branches: clay-engine https://developer.blender.org/rB71c8db2a0c7e47150f2386b46f661141d73ff4cd Build Clay engine by default === M CMakeLists.txt === diff --git a/CMakeLists.txt b/CMakeLists.txt index b1a9d6fcf3..b034f88d79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -165,7 +165,6 @@ option_defaults_init( _init_FFTW3 _init_GAMEENGINE _init_OPENSUBDIV - _init_CLAY_ENGINE ) # customize... @@ -187,7 +186,6 @@ elseif(WIN32) elseif(APPLE) set(_init_JACK OFF) set(_init_OPENSUBDIV OFF) - set(_init_CLAY_ENGINEOFF) endif() @@ -244,7 +242,7 @@ endif() option(WITH_PLAYER"Build Player" OFF) option(WITH_OPENCOLORIO "Enable OpenColorIO color management" ${_init_OPENCOLORIO}) -option(WITH_CLAY_ENGINE"Enable New Clay engine (Breaks Mac and Intel compatibility)" _init_CLAY_ENGINE) +option(WITH_CLAY_ENGINE"Enable New Clay engine (Breaks Mac and Intel compatibility)" ON) # Compositor option(WITH_COMPOSITOR "Enable the tile based nodal compositor" ON) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [242715b843] clay-engine: Code cleanup
Commit: 242715b843367aa4bf86a964acd22819fbccf23c Author: Clément Foucault Date: Tue Jan 31 17:27:19 2017 +0100 Branches: clay-engine https://developer.blender.org/rB242715b843367aa4bf86a964acd22819fbccf23c Code cleanup === M source/blender/draw/intern/draw_manager.c M source/blender/draw/intern/draw_mode_pass.c === diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 3fff977bc9..bc927a4e96 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -336,8 +336,6 @@ DRWShadingGroup *DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass) shgroup->dyntype = 0; shgroup->dyngeom = NULL; - BLI_listbase_clear(>interface->uniforms); - BLI_addtail(>shgroups, shgroup); return shgroup; @@ -559,6 +557,8 @@ DRWPass *DRW_pass_create(const char *name, DRWState state) DRWPass *pass = MEM_callocN(sizeof(DRWPass), name); pass->state = state; + BLI_listbase_clear(>shgroups); + return pass; } diff --git a/source/blender/draw/intern/draw_mode_pass.c b/source/blender/draw/intern/draw_mode_pass.c index 41b119e35c..71a9582e70 100644 --- a/source/blender/draw/intern/draw_mode_pass.c +++ b/source/blender/draw/intern/draw_mode_pass.c @@ -68,6 +68,22 @@ static DRWShadingGroup *shgroup_instance_uniform_color(DRWPass *pass, float colo * The passes are populated by the rendering engine using the DRW_shgroup_* functions. */ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPass **non_meshes, DRWPass **ob_center) { + static float colorWire[4], colorWireEdit[4]; + static float colorActive[4], colorSelect[4], colorTransform[4], colorGroup[4], colorGroupActive[4]; + static float colorEmpty[4], colorLamp[4], colorCamera[4], colorSpeaker[4]; + + UI_GetThemeColor4fv(TH_WIRE, colorWire); + UI_GetThemeColor4fv(TH_WIRE_EDIT, colorWireEdit); + UI_GetThemeColor4fv(TH_ACTIVE, colorActive); + UI_GetThemeColor4fv(TH_SELECT, colorSelect); + UI_GetThemeColor4fv(TH_TRANSFORM, colorTransform); + UI_GetThemeColor4fv(TH_GROUP_ACTIVE, colorGroupActive); + UI_GetThemeColor4fv(TH_GROUP, colorGroup); + UI_GetThemeColor4fv(OB_LAMP, colorLamp); + UI_GetThemeColor4fv(OB_SPEAKER, colorSpeaker); + UI_GetThemeColor4fv(OB_CAMERA, colorCamera); + UI_GetThemeColor4fv(OB_EMPTY, colorEmpty); + if (wire_overlay) { /* This pass can draw mesh edges top of Shaded Meshes without any Z fighting */ DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND; @@ -83,22 +99,6 @@ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPa } if (non_meshes) { - static float colorWire[4], colorWireEdit[4]; - static float colorActive[4], colorSelect[4], colorTransform[4], colorGroup[4], colorGroupActive[4]; - static float colorEmpty[4], colorLamp[4], colorCamera[4], colorSpeaker[4]; - - UI_GetThemeColor4fv(TH_WIRE, colorWire); - UI_GetThemeColor4fv(TH_WIRE_EDIT, colorWireEdit); - UI_GetThemeColor4fv(TH_ACTIVE, colorActive); - UI_GetThemeColor4fv(TH_SELECT, colorSelect); - UI_GetThemeColor4fv(TH_TRANSFORM, colorTransform); - UI_GetThemeColor4fv(TH_GROUP_ACTIVE, colorGroupActive); - UI_GetThemeColor4fv(TH_GROUP, colorGroup); - UI_GetThemeColor4fv(OB_LAMP, colorLamp); - UI_GetThemeColor4fv(OB_SPEAKER, colorSpeaker); - UI_GetThemeColor4fv(OB_CAMERA, colorCamera); - UI_GetThemeColor4fv(OB_EMPTY, colorEmpty); - /* Non Meshes Pass (Camera, empties, lamps ...) */ DRWShadingGroup *grp; @@ -145,7 +145,7 @@ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPa if (ob_center) { /* Object Center pass grouped by State */ DRWShadingGroup *grp; - static float colorActive[4], colorSelect[4], colorDeselect[4], outlineColor[4]; + static float colorDeselect[4], outlineColor[4]; static float outlineWidth, size; DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND | DRW_STATE_POINT; @@ -153,8 +153,8 @@ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPa outlineWidth = 1.0f * U.pixelsize; size = U.obcenter_dia * U.pixelsize + outlineWidth; - UI_GetThemeColorShadeAlpha4fv(TH_ACTIVE, 0, -80, colorActive); - UI_GetThemeColorShadeAlpha4fv(TH_SELECT
[Bf-blender-cvs] [81db4d2b43] clay-engine: Added wire outlines
Commit: 81db4d2b430edaa9b0d18d28b9a95b32fe2062f8 Author: Clément Foucault Date: Tue Jan 31 17:27:05 2017 +0100 Branches: clay-engine https://developer.blender.org/rB81db4d2b430edaa9b0d18d28b9a95b32fe2062f8 Added wire outlines === M source/blender/draw/engines/clay/clay.c === diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c index 844cd5b4ec..e187affaed 100644 --- a/source/blender/draw/engines/clay/clay.c +++ b/source/blender/draw/engines/clay/clay.c @@ -565,6 +565,8 @@ static void CLAY_create_cache(CLAY_PassList *passes, const struct bContext *C) } struct Batch *geom; + bool do_outlines, do_wires; + switch (ob->type) { case OB_MESH: geom = DRW_cache_surface_get(ob); @@ -573,6 +575,10 @@ static void CLAY_create_cache(CLAY_PassList *passes, const struct bContext *C) DRW_shgroup_call_add(depthbatch, geom, ob->obmat); DRW_shgroup_call_add(default_shgrp, geom, ob->obmat); + do_outlines = ((ob->base_flag & BASE_SELECTED) != 0); + + DRW_shgroup_wire_outline(passes->wire_outline_pass, ob, false, do_wires, do_outlines); + /* When encountering a new material : * - Create new Batch * - Initialize Batch @@ -586,7 +592,7 @@ static void CLAY_create_cache(CLAY_PassList *passes, const struct bContext *C) case OB_CAMERA: case OB_EMPTY: default: - DRW_shgroup_non_meshes(passes->non_meshes_pass, ob); + DRW_shgroup_non_meshes(passes->non_meshes_pass, ob); break; } @@ -643,6 +649,7 @@ static void CLAY_view_draw(RenderEngine *UNUSED(engine), const struct bContext * /* Pass 4 : Overlays */ DRW_framebuffer_texture_attach(buffers->default_fb, textures->depth, 0); + DRW_draw_pass(passes->wire_outline_pass); DRW_draw_pass(passes->non_meshes_pass); DRW_draw_pass(passes->ob_center_pass); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [85194046e6] clay-engine: Giving Overlay Edges a try
Commit: 85194046e6342b4fb5ddff6fd30155c9ae2e8e34 Author: Clément Foucault Date: Wed Feb 1 00:28:16 2017 +0100 Branches: clay-engine https://developer.blender.org/rB85194046e6342b4fb5ddff6fd30155c9ae2e8e34 Giving Overlay Edges a try === M source/blender/draw/engines/clay/clay.c M source/blender/draw/intern/draw_cache.c M source/blender/draw/intern/draw_cache.h M source/blender/draw/intern/draw_mode_pass.c === diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c index e187affaed..2be3418171 100644 --- a/source/blender/draw/engines/clay/clay.c +++ b/source/blender/draw/engines/clay/clay.c @@ -565,7 +565,7 @@ static void CLAY_create_cache(CLAY_PassList *passes, const struct bContext *C) } struct Batch *geom; - bool do_outlines, do_wires; + bool do_outlines; switch (ob->type) { case OB_MESH: @@ -575,9 +575,10 @@ static void CLAY_create_cache(CLAY_PassList *passes, const struct bContext *C) DRW_shgroup_call_add(depthbatch, geom, ob->obmat); DRW_shgroup_call_add(default_shgrp, geom, ob->obmat); - do_outlines = ((ob->base_flag & BASE_SELECTED) != 0); + DRW_shgroup_wire_overlay(passes->wire_overlay_pass, ob); - DRW_shgroup_wire_outline(passes->wire_outline_pass, ob, false, do_wires, do_outlines); + do_outlines = ((ob->base_flag & BASE_SELECTED) != 0); + DRW_shgroup_wire_outline(passes->wire_outline_pass, ob, false, false, do_outlines); /* When encountering a new material : * - Create new Batch @@ -649,6 +650,7 @@ static void CLAY_view_draw(RenderEngine *UNUSED(engine), const struct bContext * /* Pass 4 : Overlays */ DRW_framebuffer_texture_attach(buffers->default_fb, textures->depth, 0); + DRW_draw_pass(passes->wire_overlay_pass); DRW_draw_pass(passes->wire_outline_pass); DRW_draw_pass(passes->non_meshes_pass); DRW_draw_pass(passes->ob_center_pass); diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index a5a465a145..5889410db6 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -169,6 +169,21 @@ Batch *DRW_cache_single_vert_get(void) } /* Meshes */ +Batch *DRW_cache_wire_overlay_get(Object *ob) +{ + Batch *overlay_wire = NULL; + + BLI_assert(ob->type == OB_MESH); + + Mesh *me = ob->data; +#if 1 /* new version not working */ + overlay_wire = BKE_mesh_batch_cache_get_overlay_edges(me); +#else + overlay_wire = BKE_mesh_batch_cache_get_all_edges(me); +#endif + return overlay_wire; +} + Batch *DRW_cache_wire_outline_get(Object *ob) { Batch *fancy_wire = NULL; diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h index 13b33931b7..54abccdd47 100644 --- a/source/blender/draw/intern/draw_cache.h +++ b/source/blender/draw/intern/draw_cache.h @@ -35,6 +35,7 @@ struct Batch *DRW_cache_circle_ball_get(void); struct Batch *DRW_cache_single_vert_get(void); struct Batch *DRW_cache_plain_axes_get(void); /* Meshes */ +struct Batch *DRW_cache_wire_overlay_get(struct Object *ob); struct Batch *DRW_cache_wire_outline_get(struct Object *ob); struct Batch *DRW_cache_surface_get(struct Object *ob); diff --git a/source/blender/draw/intern/draw_mode_pass.c b/source/blender/draw/intern/draw_mode_pass.c index 71a9582e70..0d5ea5ea6c 100644 --- a/source/blender/draw/intern/draw_mode_pass.c +++ b/source/blender/draw/intern/draw_mode_pass.c @@ -86,7 +86,7 @@ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPa if (wire_overlay) { /* This pass can draw mesh edges top of Shaded Meshes without any Z fighting */ - DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND; + DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_BLEND; *wire_overlay = DRW_pass_create("Wire Overlays Pass", state); } @@ -236,13 +236,24 @@ static int draw_object_wire_theme(Object *ob) void DRW_shgroup_wire_overlay(DRWPass *wire_overlay, Object *ob) { - struct Batch *geom = DRW_cache_wire_outline_get(ob); +#if 1 + struct Batch *geom = DRW_cache_wire_overlay_get(ob); GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_EDGES_OVERLAY);
[Bf-blender-cvs] [641828bf85] clay-engine: Code Cleanup
Commit: 641828bf856c0110f05117d66935dbea5383b18d Author: Clément Foucault Date: Tue Jan 31 16:15:06 2017 +0100 Branches: clay-engine https://developer.blender.org/rB641828bf856c0110f05117d66935dbea5383b18d Code Cleanup === M source/blender/draw/intern/draw_mode_pass.c === diff --git a/source/blender/draw/intern/draw_mode_pass.c b/source/blender/draw/intern/draw_mode_pass.c index 2156a860c5..41b119e35c 100644 --- a/source/blender/draw/intern/draw_mode_pass.c +++ b/source/blender/draw/intern/draw_mode_pass.c @@ -38,12 +38,12 @@ /* Store list of shading group for easy access*/ /* Empties */ -static DRWShadingGroup *empty_wire; -static DRWShadingGroup *empty_active; -static DRWShadingGroup *empty_select; -static DRWShadingGroup *empty_transform; -static DRWShadingGroup *empty_group; -static DRWShadingGroup *empty_group_active; +static DRWShadingGroup *plain_axes_wire; +static DRWShadingGroup *plain_axes_active; +static DRWShadingGroup *plain_axes_select; +static DRWShadingGroup *plain_axes_transform; +static DRWShadingGroup *plain_axes_group; +static DRWShadingGroup *plain_axes_group_active; /* Helpers */ static DRWShadingGroup *relationship_lines; @@ -53,6 +53,17 @@ static DRWShadingGroup *center_active; static DRWShadingGroup *center_selected; static DRWShadingGroup *center_deselected; +static DRWShadingGroup *shgroup_instance_uniform_color(DRWPass *pass, float color[4]) +{ + GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR_INSTANCE); + + DRWShadingGroup *grp = DRW_shgroup_create(sh_inst, pass); + DRW_shgroup_uniform_vec4(grp, "color", color, 1); + DRW_shgroup_dyntype_set(grp, DRW_DYN_INSTANCE); + + return grp; +} + /* This Function setup the passes needed for the mode rendering. * The passes are populated by the rendering engine using the DRW_shgroup_* functions. */ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPass **non_meshes, DRWPass **ob_center) @@ -96,7 +107,6 @@ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPa *non_meshes = DRW_pass_create("Non Meshes Pass", state); GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR); - GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR_INSTANCE); /* Solid Wires */ grp = DRW_shgroup_create(sh, *non_meshes); @@ -105,37 +115,12 @@ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPa grp = DRW_shgroup_create(sh, *non_meshes); /* Empties */ - { - grp = DRW_shgroup_create(sh_inst, *non_meshes); - DRW_shgroup_uniform_vec4(grp, "color", colorEmpty, 1); - DRW_shgroup_dyntype_set(grp, DRW_DYN_INSTANCE); - empty_wire = grp; - - grp = DRW_shgroup_create(sh_inst, *non_meshes); - DRW_shgroup_uniform_vec4(grp, "color", colorActive, 1); - DRW_shgroup_dyntype_set(grp, DRW_DYN_INSTANCE); - empty_active = grp; - - grp = DRW_shgroup_create(sh_inst, *non_meshes); - DRW_shgroup_uniform_vec4(grp, "color", colorSelect, 1); - DRW_shgroup_dyntype_set(grp, DRW_DYN_INSTANCE); - empty_select = grp; - - grp = DRW_shgroup_create(sh_inst, *non_meshes); - DRW_shgroup_uniform_vec4(grp, "color", colorTransform, 1); - DRW_shgroup_dyntype_set(grp, DRW_DYN_INSTANCE); - empty_transform = grp; - - grp = DRW_shgroup_create(sh_inst, *non_meshes); - DRW_shgroup_uniform_vec4(grp, "color", colorGroup, 1); - DRW_shgroup_dyntype_set(grp, DRW_DYN_INSTANCE); - empty_group = grp; - - grp = DRW_shgroup_create(sh_inst, *non_meshes); - DRW_shgroup_uniform_vec4(grp, "color", colorGroupActive, 1); - DRW_shgroup_dyntype_set(grp, DRW_DYN_INSTANCE); - empty_group_active = grp; - } + plain_axes_wire = shgroup_instance_uniform_color(*non_meshes, colorEmpty); + plain_axes_active = shgroup_instance_uniform_color(*non_meshes, colorActive); + plain_axes_select = shgroup_instance_uniform_color(*non_meshes, colorSelect); + plain_axes_transform = shgroup_instance_uniform_color(*non_meshes, colorTransform); + plain_axes_group = shgroup_instance_
[Bf-blender-cvs] [efa46d7db0] clay-engine: Initial support of Uniform Buffer objects
Commit: efa46d7db0e395d6b1380432e5de5bf2a628c81d Author: Clément Foucault Date: Mon Jan 23 09:54:54 2017 +0100 Branches: clay-engine https://developer.blender.org/rBefa46d7db0e395d6b1380432e5de5bf2a628c81d Initial support of Uniform Buffer objects === M source/blender/draw/engines/clay/clay.c M source/blender/draw/engines/clay/shaders/clay_frag.glsl M source/blender/draw/engines/clay/shaders/ssao_alchemy.glsl M source/blender/draw/engines/clay/shaders/ssao_groundtruth.glsl M source/blender/draw/intern/DRW_render.h M source/blender/draw/intern/draw_manager.c M source/blender/gpu/CMakeLists.txt M source/blender/gpu/GPU_extensions.h M source/blender/gpu/GPU_shader.h A source/blender/gpu/GPU_uniformbuffer.h M source/blender/gpu/intern/gpu_extensions.c M source/blender/gpu/intern/gpu_shader.c A source/blender/gpu/intern/gpu_uniformbuffer.c === diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c index 48fbb435e3..14ef27fa55 100644 --- a/source/blender/draw/engines/clay/clay.c +++ b/source/blender/draw/engines/clay/clay.c @@ -43,11 +43,31 @@ extern char datatoc_ssao_groundtruth_glsl[]; /* Storage */ +/* UBOs data needs to be 16 byte aligned (size of vec4) */ +/* Reminder : float, int, bool are 4 bytes */ +typedef struct CLAY_UBO_Material { + float ssao_params_var[4]; + /* - 16 -*/ + float matcap_hsv[3]; + float matcap_id; /* even float encoding have enough precision */ + /* - 16 -*/ + float matcap_rot[2]; + float pad[2]; /* ensure 16 bytes alignement */ +} CLAY_UBO_Material; /* 48 bytes */ + +typedef struct CLAY_UBO_Storage { + CLAY_UBO_Material materials[512]; /* 512 = 9 bit material id */ +} CLAY_UBO_Storage; + static struct CLAY_data { /* Depth Pre Pass */ struct GPUShader *depth_sh; /* Shading Pass */ - struct GPUShader *clay_sh[8]; + struct GPUShader *clay_sh; + + /* Materials Parameter UBO */ + struct GPUUniformBuffer *mat_ubo; + CLAY_UBO_Storage mat_storage; /* Matcap textures */ struct GPUTexture *matcap_array; @@ -61,18 +81,6 @@ static struct CLAY_data { struct GPUTexture *sampling_tx; } data = {NULL}; -/* Shaders */ -#define WITH_ALL 0 -#define WITH_HSV_ROT 1 -#define WITH_AO_ROT 2 -#define WITH_AO_HSV 3 -#define WITH_AO 4 -#define WITH_ROT 5 -#define WITH_HSV 6 -#define WITH_NONE 7 - -/* for clarity follow the same layout as CLAY_TextureList */ - /* keep it under MAX_BUFFERS */ typedef struct CLAY_FramebufferList{ /* default */ @@ -268,25 +276,18 @@ static void CLAY_engine_init(void) data.depth_sh = DRW_shader_create_3D_depth_only(); } + if (!data.mat_ubo) { + data.mat_ubo = DRW_uniformbuffer_create(sizeof(CLAY_UBO_Storage), NULL); + } + /* Shading pass */ - if (!data.clay_sh[0]) { + if (!data.clay_sh) { DynStr *ds = BLI_dynstr_new(); - const char *with_all = - "#define USE_AO;\n" - "#define USE_HSV;\n" - "#define USE_ROTATION;\n"; - const char *with_hsv_rot = - "#define USE_HSV;\n" - "#define USE_ROTATION;\n"; - const char *with_ao_rot = - "#define USE_AO;\n" - "#define USE_ROTATION;\n"; - const char *with_ao_hsv = - "#define USE_AO;\n" - "#define USE_HSV;\n"; - const char *with_ao ="#define USE_AO;\n"; - const char *with_rot ="#define USE_ROTATION;\n"; - const char *with_hsv ="#define USE_HSV;\n"; + const char *max_mat = + "#define MAX_MATERIAL 512\n" + "#define USE_ROTATION\n" + "#define USE_AO\n" + "#define USE_HSV\n"; char *matcap_with_ao; BLI_dynstr_append(ds, datatoc_clay_frag_glsl); @@ -298,80 +299,49 @@ static void CLAY_engine_init(void) matcap_with_ao = BLI_dynstr_get_cstring(ds); - data.clay_sh[WITH_ALL] = DRW_shader_create(datatoc_clay_vert_glsl, NULL, matcap_with_ao, with_all); - data.clay_sh[WITH_HSV_ROT] = DRW_shader_create(datatoc_clay_vert_glsl, NULL, matcap_with_ao, with_hsv_rot); - data.clay_sh[WITH_AO_ROT] = DRW_shader_create(datatoc_clay_vert_glsl, NULL, matcap_with_ao, with_ao_rot); - data.clay_sh[WITH_AO_HSV] = DRW_shader_create(dat
[Bf-blender-cvs] [bbbb8405b6] clay-engine: Removed Batch storage Also lots of renaming Small visual tweaks Material Settings Struct is now shared by Scene and material
Commit: 8405b6547cdff9f248da86b2205c7963c3dd Author: Clément Foucault Date: Fri Jan 20 01:11:42 2017 +0100 Branches: clay-engine https://developer.blender.org/rB8405b6547cdff9f248da86b2205c7963c3dd Removed Batch storage Also lots of renaming Small visual tweaks Material Settings Struct is now shared by Scene and material === M release/scripts/startup/bl_ui/properties_render.py M source/blender/blenkernel/intern/scene.c M source/blender/blenloader/intern/readfile.c M source/blender/blenloader/intern/versioning_280.c M source/blender/draw/engines/clay/clay.c M source/blender/draw/engines/clay/clay.h M source/blender/draw/engines/clay/shaders/clay_frag.glsl M source/blender/draw/engines/clay/shaders/ssao_groundtruth.glsl M source/blender/draw/intern/DRW_render.h M source/blender/draw/intern/draw_manager.c M source/blender/draw/intern/draw_mode_pass.c M source/blender/draw/intern/draw_mode_pass.h M source/blender/makesdna/DNA_material_types.h M source/blender/makesdna/DNA_scene_types.h M source/blender/makesrna/intern/rna_material.c M source/blender/makesrna/intern/rna_scene.c === diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py index 8ddc99af70..0d473d79ed 100644 --- a/release/scripts/startup/bl_ui/properties_render.py +++ b/release/scripts/startup/bl_ui/properties_render.py @@ -591,15 +591,16 @@ class RENDER_PT_clay(RenderButtonsPanel, Panel): def draw(self, context): layout = self.layout; settings = context.scene.clay_settings -layout.template_icon_view(settings, "matcap_icon") -layout.prop(settings, "matcap_rotation") -layout.prop(settings, "matcap_hue") -layout.prop(settings, "matcap_saturation") -layout.prop(settings, "matcap_value") -layout.prop(settings, "ssao_factor_cavity") -layout.prop(settings, "ssao_factor_edge") -layout.prop(settings, "ssao_distance") -layout.prop(settings, "ssao_attenuation") +matsettings = context.scene.clay_settings.mat_settings +layout.template_icon_view(matsettings, "matcap_icon") +layout.prop(matsettings, "matcap_rotation") +layout.prop(matsettings, "matcap_hue") +layout.prop(matsettings, "matcap_saturation") +layout.prop(matsettings, "matcap_value") +layout.prop(matsettings, "ssao_factor_cavity") +layout.prop(matsettings, "ssao_factor_edge") +layout.prop(matsettings, "ssao_distance") +layout.prop(matsettings, "ssao_attenuation") layout.prop(settings, "ssao_samples") diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 2d9b4fcd2b..efaea4f9c3 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -558,6 +558,10 @@ void BKE_scene_free(Scene *sce) BKE_collection_master_free(sce); MEM_freeN(sce->collection); sce->collection = NULL; + + /* Runtime Engine Data */ + if (sce->claydata.defsettings.runtime) + MEM_freeN(sce->claydata.defsettings.runtime); } void BKE_scene_init(Scene *sce) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 0f79a42111..e98e72295c 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6197,6 +6197,8 @@ static void direct_link_scene(FileData *fd, Scene *sce) sl->basact = newdataadr(fd, sl->basact); direct_link_layer_collections(fd, >layer_collections); } + + sce->claydata.defsettings.runtime = NULL; } /* READ WM * */ diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 8ae921ab69..64340ebcdb 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -30,6 +30,7 @@ #include "DNA_object_types.h" #include "DNA_layer_types.h" +#include "DNA_material_types.h" #include "DNA_scene_types.h" #include "DNA_genfile.h" @@ -165,14 +166,14 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main) for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { EngineDataClay *settings = >claydata; -
[Bf-blender-cvs] [00c3c6824d] clay-engine: Integrated MBC functions. Added Object centers and empties.
Commit: 00c3c6824d6304ffbb3d858fa936edc2c1c4c2fa Author: Clément Foucault Date: Thu Jan 26 15:56:40 2017 +0100 Branches: clay-engine https://developer.blender.org/rB00c3c6824d6304ffbb3d858fa936edc2c1c4c2fa Integrated MBC functions. Added Object centers and empties. === M source/blender/draw/CMakeLists.txt M source/blender/draw/DRW_engine.h M source/blender/draw/engines/clay/clay.c M source/blender/draw/engines/clay/shaders/clay_frag.glsl M source/blender/draw/engines/clay/shaders/ssao_groundtruth.glsl M source/blender/draw/intern/DRW_render.h A source/blender/draw/intern/draw_cache.c A source/blender/draw/intern/draw_cache.h M source/blender/draw/intern/draw_manager.c M source/blender/draw/intern/draw_mode_pass.c M source/blender/draw/intern/draw_mode_pass.h M source/blender/editors/space_view3d/view3d_draw.c M source/blender/editors/space_view3d/view3d_intern.h M source/blender/gpu/intern/gpu_viewport.c === diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 1aababc350..4cc69c0ea0 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -52,10 +52,12 @@ set(INC_SYS set(SRC intern/draw_manager.c intern/draw_mode_pass.c + intern/draw_cache.c engines/clay/clay.c intern/DRW_render.h intern/draw_mode_pass.h + intern/draw_cache.h engines/clay/clay.h ./DRW_engine.h diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h index 43e0657e4d..ad05cf625f 100644 --- a/source/blender/draw/DRW_engine.h +++ b/source/blender/draw/DRW_engine.h @@ -31,6 +31,7 @@ struct DRWPass; void DRW_engines_init(void); void DRW_engines_free(void); +/* This is here because GPUViewport needs it */ void DRW_pass_free(struct DRWPass *pass); #endif /* __DRW_ENGINE_H__ */ \ No newline at end of file diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c index 459a413454..a6b6fc95d5 100644 --- a/source/blender/draw/engines/clay/clay.c +++ b/source/blender/draw/engines/clay/clay.c @@ -113,8 +113,10 @@ typedef struct CLAY_TextureList{ typedef struct CLAY_PassList{ struct DRWPass *depth_pass; struct DRWPass *clay_pass; - struct DRWPass *mode_ob_wire_pass; - struct DRWPass *mode_ob_center_pass; + struct DRWPass *wire_overlay_pass; + struct DRWPass *wire_outline_pass; + struct DRWPass *non_meshes_pass; + struct DRWPass *ob_center_pass; } CLAY_PassList; //#define GTAO @@ -312,6 +314,57 @@ static void CLAY_engine_init(void) } } +static void CLAY_ssao_setup(void) +{ + float invproj[4][4]; + float dfdyfacs[2]; + bool is_persp = DRW_viewport_is_persp_get(); + /* view vectors for the corners of the view frustum. Can be used to recreate the world space position easily */ + float viewvecs[3][4] = { + {-1.0f, -1.0f, -1.0f, 1.0f}, + {1.0f, -1.0f, -1.0f, 1.0f}, + {-1.0f, 1.0f, -1.0f, 1.0f} + }; + int i; + float *size = DRW_viewport_size_get(); + EngineDataClay *settings = DRW_render_settings(); + + DRW_get_dfdy_factors(dfdyfacs); + + data.ssao_params[0] = settings->ssao_samples; + data.ssao_params[1] = size[0] / 64.0; + data.ssao_params[2] = size[1] / 64.0; + data.ssao_params[3] = dfdyfacs[1]; /* dfdy sign for offscreen */ + + /* invert the view matrix */ + DRW_viewport_matrix_get(data.winmat, DRW_MAT_WIN); + invert_m4_m4(invproj, data.winmat); + + /* convert the view vectors to view space */ + for (i = 0; i < 3; i++) { + mul_m4_v4(invproj, viewvecs[i]); + /* normalized trick see http://www.derschmale.com/2014/01/26/reconstructing-positions-from-the-depth-buffer */ + mul_v3_fl(viewvecs[i], 1.0f / viewvecs[i][3]); + if (is_persp) + mul_v3_fl(viewvecs[i], 1.0f / viewvecs[i][2]); + viewvecs[i][3] = 1.0; + + copy_v4_v4(data.viewvecs[i], viewvecs[i]); + } + + /* we need to store the differences */ + data.viewvecs[1][0] -= data.viewvecs[0][0]; + data.viewvecs[1][1] = data.viewvecs[2][1] - data.viewvecs[0][1]; + + /* calculate a depth offset as well */ + if (!is_persp) { + float vec_far[] = {-1.0f, -1.0f, 1.0f, 1.0f}; + mul_m4_v4(invproj, vec_far); + mul_v3_fl(vec_far, 1.0f / vec_far[3]); + data.viewvecs[1][2] = vec_far[2] - data.viewvecs[0][2]; + } +} + static DRWShadingGroup *CLAY_shgroup_create(DRWPass *pass, int *material_id) { const int depthloc = 0, matcaploc = 1, jitterloc = 2, sampleloc = 3; @@
[Bf-blender-cvs] [72ff78a951] clay-engine: Merge branch 'render-layers' of git.blender.org:blender into clay-engine
Commit: 72ff78a9515255c1b687ad3fd63d169ef5c27355 Author: Clément Foucault Date: Wed Jan 25 12:28:52 2017 +0100 Branches: clay-engine https://developer.blender.org/rB72ff78a9515255c1b687ad3fd63d169ef5c27355 Merge branch 'render-layers' of git.blender.org:blender into clay-engine # Conflicts: # source/blender/editors/space_view3d/drawobject.c === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [92e5dfbeed] clay-engine: Fix compilation error on windows
Commit: 92e5dfbeed170deedae60df7fb66cb3bdd66a6f7 Author: Clément Foucault Date: Thu Jan 26 18:33:24 2017 +0100 Branches: clay-engine https://developer.blender.org/rB92e5dfbeed170deedae60df7fb66cb3bdd66a6f7 Fix compilation error on windows === M source/blender/draw/engines/clay/clay.c M source/blender/gpu/GPU_viewport.h === diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c index a6b6fc95d5..ffdad41bef 100644 --- a/source/blender/draw/engines/clay/clay.c +++ b/source/blender/draw/engines/clay/clay.c @@ -111,12 +111,14 @@ typedef struct CLAY_TextureList{ /* keep it under MAX_PASSES */ typedef struct CLAY_PassList{ + /* default */ + struct DRWPass *non_meshes_pass; + struct DRWPass *ob_center_pass; + /* engine specific */ struct DRWPass *depth_pass; struct DRWPass *clay_pass; struct DRWPass *wire_overlay_pass; struct DRWPass *wire_outline_pass; - struct DRWPass *non_meshes_pass; - struct DRWPass *ob_center_pass; } CLAY_PassList; //#define GTAO diff --git a/source/blender/gpu/GPU_viewport.h b/source/blender/gpu/GPU_viewport.h index fca77ea0b6..e44657a464 100644 --- a/source/blender/gpu/GPU_viewport.h +++ b/source/blender/gpu/GPU_viewport.h @@ -69,10 +69,8 @@ typedef struct DefaultTextureList { } DefaultTextureList; typedef struct DefaultPassList { - /* Put Default passes here -* - Edit Wire -* - Active objects outlines -* ... */ + struct DRWPass *non_meshes_pass; + struct DRWPass *ob_center_pass; } DefaultPassList; GPUViewport *GPU_viewport_create(void); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [fcd5880d12] clay-engine: Fix include compilation error on MSVC 2015.
Commit: fcd5880d12f659644e6b21371f5d94e3ffdbc70e Author: Clément Foucault Date: Thu Jan 26 18:51:22 2017 +0100 Branches: clay-engine https://developer.blender.org/rBfcd5880d12f659644e6b21371f5d94e3ffdbc70e Fix include compilation error on MSVC 2015. === M source/blender/draw/CMakeLists.txt === diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 4cc69c0ea0..6cf358e8c1 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -46,7 +46,7 @@ set(INC ) set(INC_SYS - + ${GLEW_INCLUDE_PATH} ) set(SRC ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [4c416aea3b] clay-engine: Merge branch 'render-layers' of git.blender.org:blender into clay-engine
Commit: 4c416aea3bd2d4b5e05c33b90f7b79e04f4da318 Author: Clément Foucault Date: Thu Jan 26 19:49:09 2017 +0100 Branches: clay-engine https://developer.blender.org/rB4c416aea3bd2d4b5e05c33b90f7b79e04f4da318 Merge branch 'render-layers' of git.blender.org:blender into clay-engine # Conflicts: # source/blender/makesdna/DNA_scene_types.h === === diff --cc source/blender/makesdna/DNA_scene_types.h index 08366af628,cb267002a5..3759aa3d48 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@@ -1751,10 -1711,8 +1751,12 @@@ typedef struct Scene ListBase render_layers; struct SceneCollection *collection; + int active_layer; + int pad4; + + /* Engine Settings */ + struct EngineDataClay claydata; + short pad10[4]; } Scene; /* RENDERDATA * */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [08675b94ef] clay-engine: Fixed Engine name length
Commit: 08675b94ef15b4ecb94ce0cefcbd4bba9cad60fa Author: Clément Foucault Date: Mon Jan 30 13:03:30 2017 +0100 Branches: clay-engine https://developer.blender.org/rB08675b94ef15b4ecb94ce0cefcbd4bba9cad60fa Fixed Engine name length === M source/blender/draw/intern/draw_manager.c M source/blender/makesdna/DNA_material_types.h M source/blender/makesdna/DNA_scene_types.h === diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 3f5cc156f5..26525954c2 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -859,7 +859,7 @@ void *DRW_material_settings_get(Material *ma, const char *engine_name, void **ru if (ms == NULL) { ms = MEM_callocN(sizeof(RenderEngineSettings), "RenderEngineSettings"); - BLI_strncpy(ms->name, engine_name, 64); + BLI_strncpy(ms->name, engine_name, 32); /* TODO make render_settings_create a polymorphic function */ if (STREQ(engine_name, RE_engine_id_BLENDER_CLAY)) { @@ -894,7 +894,7 @@ void *DRW_render_settings_get(Scene *scene, const char *engine_name, void **runt if (rs == NULL) { rs = MEM_callocN(sizeof(RenderEngineSettings), "RenderEngineSettings"); - BLI_strncpy(rs->name, engine_name, 64); + BLI_strncpy(rs->name, engine_name, 32); /* TODO make render_settings_create a polymorphic function */ if (STREQ(engine_name, RE_engine_id_BLENDER_CLAY)) { diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h index 3717561dd0..824925634d 100644 --- a/source/blender/makesdna/DNA_material_types.h +++ b/source/blender/makesdna/DNA_material_types.h @@ -93,7 +93,7 @@ typedef struct TexPaintSlot { /* Material Engine Settings */ typedef struct MaterialEngineSettings { struct MaterialEngineSettings *next, *prev; - char name[64]; /* engine name - MAX_NAME */ + char name[32]; /* engine name - MAX_NAME */ void *runtime; /* To be free on file read */ void *data; } MaterialEngineSettings; diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index c042716fdc..1ae914eeea 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -550,7 +550,7 @@ typedef enum BakePassFilter { typedef struct RenderEngineSettings { struct RenderEngineSettings *next, *prev; - char name[64]; /* engine name - MAX_NAME */ + char name[32]; /* engine name */ void *runtime; /* Here to be free on file read */ void *data; } RenderEngineSettings; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ba4a30c71b] clay-engine: Fix read/writefile.c
Commit: ba4a30c71baffde4af8e94257f2758a1f35aa23b Author: Clément Foucault Date: Mon Jan 30 12:19:51 2017 +0100 Branches: clay-engine https://developer.blender.org/rBba4a30c71baffde4af8e94257f2758a1f35aa23b Fix read/writefile.c === M source/blender/blenloader/intern/readfile.c M source/blender/blenloader/intern/writefile.c === diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index a8dc9d0ed8..783eb8fd5f 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3968,6 +3968,7 @@ static void lib_link_material(FileData *fd, Main *main) static void direct_link_material(FileData *fd, Material *ma) { int a; + MaterialEngineSettings *mes; ma->adt = newdataadr(fd, ma->adt); direct_link_animdata(fd, ma->adt); @@ -3988,6 +3989,12 @@ static void direct_link_material(FileData *fd, Material *ma) ma->preview = direct_link_preview_image(fd, ma->preview); BLI_listbase_clear(>gpumaterial); + + link_list(fd, >engines_settings); + for (mes = ma->engines_settings.first; mes; mes = mes->next) { + mes->runtime = NULL; + mes->data = newdataadr(fd, mes->data); + } } /* READ PARTICLE SETTINGS * */ @@ -6210,12 +6217,12 @@ static void direct_link_scene(FileData *fd, Scene *sce) sl->basact = newdataadr(fd, sl->basact); direct_link_layer_collections(fd, >layer_collections); } -#if 0 + link_list(fd, >engines_settings); for (res = sce->engines_settings.first; res; res = res->next) { res->runtime = NULL; + res->data = newdataadr(fd, res->data); } -#endif } /* READ WM * */ diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 4032dbe9d2..151fd06ed6 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2468,6 +2468,21 @@ static void write_textures(WriteData *wd, ListBase *idbase) mywrite_flush(wd); } +static void write_material_engines_settings(WriteData *wd, ListBase *lb) +{ + for (MaterialEngineSettings *res = lb->first; res; res = res->next) { + writestruct(wd, DATA, MaterialEngineSettings, 1, res); + + if (STREQ(res->name, RE_engine_id_BLENDER_CLAY)) { + writestruct(wd, DATA, MaterialEngineSettingsClay, 1, res->data); + } + else { + /* No engine matched */ + /* error: don't know how to write this file */ + } + } +} + static void write_materials(WriteData *wd, ListBase *idbase) { Material *ma; @@ -2504,6 +2519,8 @@ static void write_materials(WriteData *wd, ListBase *idbase) } write_previews(wd, ma->preview); + + write_material_engines_settings(wd, >engines_settings); } ma = ma->id.next; } @@ -2650,6 +2667,21 @@ static void write_layer_collections(WriteData *wd, ListBase *lb) } } +static void write_render_engines_settings(WriteData *wd, ListBase *lb) +{ + for (RenderEngineSettings *res = lb->first; res; res = res->next) { + writestruct(wd, DATA, RenderEngineSettings, 1, res); + + if (STREQ(res->name, RE_engine_id_BLENDER_CLAY)) { + writestruct(wd, DATA, RenderEngineSettingsClay, 1, res->data); + } + else { + /* No engine matched */ + /* error: don't know how to write this file */ + } + } +} + static void write_scenes(WriteData *wd, ListBase *scebase) { Scene *sce; @@ -2666,7 +2698,6 @@ static void write_scenes(WriteData *wd, ListBase *scebase) FreestyleModuleConfig *fmc; FreestyleLineSet *fls; SceneLayer *sl; - RenderEngineSettings *res; sce = scebase->first; while (sce) { @@ -2879,11 +2910,9 @@ static void write_scenes(WriteData *wd, ListBase *scebase) writelist(wd, DATA, ObjectBase, >object_bases); write_layer_collections(wd, >layer_collections); } -#if 0 - for (res = sce->engines_settings.first; res; res = res->next) { - /* How to write if struct type is not known? */ - } -#endif + + write_render_engines_settings(wd, >engines_settings); + sce = s
[Bf-blender-cvs] [12bac207c7] clay-engine: Added scene.active_engine_settings
Commit: 12bac207c7d31206dfca15088bc16587d639dddc Author: Clément Foucault Date: Mon Jan 30 14:41:58 2017 +0100 Branches: clay-engine https://developer.blender.org/rB12bac207c7d31206dfca15088bc16587d639dddc Added scene.active_engine_settings === M release/scripts/startup/bl_ui/properties_render.py M source/blender/draw/intern/draw_manager.c M source/blender/makesrna/intern/rna_scene.c === diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py index b1c68559d8..5f2c9939dc 100644 --- a/release/scripts/startup/bl_ui/properties_render.py +++ b/release/scripts/startup/bl_ui/properties_render.py @@ -590,17 +590,17 @@ class RENDER_PT_clay(RenderButtonsPanel, Panel): def draw(self, context): layout = self.layout; -# settings = context.scene.engine_settings -# layout.template_icon_view(settings, "matcap_icon") -# layout.prop(settings, "matcap_rotation") -# layout.prop(settings, "matcap_hue") -# layout.prop(settings, "matcap_saturation") -# layout.prop(settings, "matcap_value") -# layout.prop(settings, "ssao_factor_cavity") -# layout.prop(settings, "ssao_factor_edge") -# layout.prop(settings, "ssao_distance") -# layout.prop(settings, "ssao_attenuation") -# layout.prop(settings, "ssao_samples") +settings = context.scene.active_engine_settings +layout.template_icon_view(settings, "matcap_icon") +layout.prop(settings, "matcap_rotation") +layout.prop(settings, "matcap_hue") +layout.prop(settings, "matcap_saturation") +layout.prop(settings, "matcap_value") +layout.prop(settings, "ssao_factor_cavity") +layout.prop(settings, "ssao_factor_edge") +layout.prop(settings, "ssao_distance") +layout.prop(settings, "ssao_attenuation") +layout.prop(settings, "ssao_samples") if __name__ == "__main__": # only for live edit. diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 26525954c2..683c0bd178 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -905,6 +905,8 @@ void *DRW_render_settings_get(Scene *scene, const char *engine_name, void **runt BLI_assert(false); } + printf("DRW_render_settings_get %s\n", rs->name); + BLI_addtail(>engines_settings, rs); } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 2ac8d317b9..604a758980 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1885,6 +1885,19 @@ static StructRNA *rna_RenderEngineSettings_refine(PointerRNA *ptr) return _RenderEngineSettings; } +static PointerRNA rna_RenderEngineSettings_active_get(PointerRNA *ptr) +{ + Scene *scene = (Scene *)ptr->data; + RenderEngineSettings *res; + + /* Ensure settings exists */ + DRW_render_settings_get(scene, scene->r.engine, NULL); + + res = BLI_findstring(>engines_settings, scene->r.engine, offsetof(RenderEngineSettings, name)); + + return rna_pointer_inherit_refine(ptr, _RenderEngineSettings, res); +} + static void rna_RenderEngineSettings_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { Scene *sce = (Scene *)ptr->id.data; @@ -8166,6 +8179,11 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_struct_type(prop, "RenderEngineSettings"); RNA_def_property_ui_text(prop, "Render Engine Settings", "Engine specific render settings"); + prop = RNA_def_property(srna, "active_engine_settings", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "RenderEngineSettings"); + RNA_def_property_pointer_funcs(prop, "rna_RenderEngineSettings_active_get", NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "Active Render Engine Settings", "Active Engine specific render settings for this scene"); + /* Safe Areas */ prop = RNA_def_property(srna, "safe_areas", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "safe_areas"); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f2e217938e] clay-engine: Fixed unfreed memory
Commit: f2e217938ed1c67c2b09b4e77f33f9303b0f0a1f Author: Clément Foucault Date: Mon Jan 30 15:35:12 2017 +0100 Branches: clay-engine https://developer.blender.org/rBf2e217938ed1c67c2b09b4e77f33f9303b0f0a1f Fixed unfreed memory === M source/blender/blenkernel/intern/material.c M source/blender/blenkernel/intern/scene.c === diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 3fb7ee89ae..89af048f73 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -112,7 +112,13 @@ void BKE_material_free(Material *ma) BKE_icon_id_delete((ID *)ma); BKE_previewimg_free(>preview); - /* TODO Free Engine Settings */ + for (MaterialEngineSettings *mes = ma->engines_settings.first; mes; mes = mes->next) { + if (mes->runtime) + MEM_SAFE_FREE(mes->runtime); + if (mes->data) + MEM_SAFE_FREE(mes->data); + } + BLI_freelistN(>engines_settings); } void BKE_material_init(Material *ma) diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index b4aa47bf9d..807496d88e 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -569,6 +569,12 @@ void BKE_scene_free(Scene *sce) sce->collection = NULL; /* Runtime Engine Data */ + for (RenderEngineSettings *res = sce->engines_settings.first; res; res = res->next) { + if (res->runtime) + MEM_freeN(res->runtime); + if (res->data) + MEM_freeN(res->data); + } BLI_freelistN(>engines_settings); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [106f415ddd] clay-engine: Fix crash on read file
Commit: 106f415ddde2b2b94a7d9bd1f8f9783e3a86358c Author: Clément Foucault Date: Mon Jan 30 15:17:03 2017 +0100 Branches: clay-engine https://developer.blender.org/rB106f415ddde2b2b94a7d9bd1f8f9783e3a86358c Fix crash on read file === M source/blender/blenloader/intern/readfile.c === diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 783eb8fd5f..51c28fed11 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4615,6 +4615,7 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh) mesh->bb = NULL; mesh->edit_btmesh = NULL; + mesh->batch_cache = NULL; /* happens with old files */ if (mesh->mselect == NULL) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b86e5a9fbf] clay-engine: Fixed Pointer problem. Now materials are working.
Commit: b86e5a9fbfc7b2b2bb1d80f800ac17f5c4fc1f8a Author: Clément Foucault Date: Mon Jan 30 15:09:35 2017 +0100 Branches: clay-engine https://developer.blender.org/rBb86e5a9fbfc7b2b2bb1d80f800ac17f5c4fc1f8a Fixed Pointer problem. Now materials are working. === M source/blender/draw/DRW_engine.h M source/blender/draw/engines/clay/clay.c M source/blender/draw/intern/DRW_render.h M source/blender/draw/intern/draw_manager.c M source/blender/makesrna/intern/rna_scene.c === diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h index 93b5e69d4d..05222574ae 100644 --- a/source/blender/draw/DRW_engine.h +++ b/source/blender/draw/DRW_engine.h @@ -39,7 +39,7 @@ void DRW_engines_free(void); void DRW_pass_free(struct DRWPass *pass); /* Settings */ -void *DRW_material_settings_get(struct Material *ma, const char *engine_name, void **runtime); -void *DRW_render_settings_get(struct Scene *scene, const char *engine_name, void **runtime); +void *DRW_material_settings_get(struct Material *ma, const char *engine_name, void ***runtime); +void *DRW_render_settings_get(struct Scene *scene, const char *engine_name, void ***runtime); #endif /* __DRW_ENGINE_H__ */ \ No newline at end of file diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c index d084a3383b..a588412903 100644 --- a/source/blender/draw/engines/clay/clay.c +++ b/source/blender/draw/engines/clay/clay.c @@ -487,19 +487,19 @@ static void update_ubo_storage(MaterialRuntimeClay *runtime, unsigned int curren static void CLAY_update_material_ubo(const struct bContext *C) { Main *bmain = CTX_data_main(C); - MaterialRuntimeClay *runtime; + MaterialRuntimeClay **runtime; /* Update Default materials */ for (Scene *sce = bmain->scene.first; sce; sce = sce->id.next) { /* Using render settings as material settings */ - MaterialEngineSettingsClay *res = DRW_render_settings_get(sce, RE_engine_id_BLENDER_CLAY, (void **)); - CLAY_update_material_runtime(res, ); + MaterialEngineSettingsClay *res = DRW_render_settings_get(sce, RE_engine_id_BLENDER_CLAY, (void ***)); + CLAY_update_material_runtime(res, runtime); } /* Update Scene Materials */ for (Material *mat = bmain->mat.first; mat; mat = mat->id.next) { - MaterialEngineSettingsClay *mesc = DRW_material_settings_get(mat, RE_engine_id_BLENDER_CLAY, (void **)); - CLAY_update_material_runtime(mesc, ); + MaterialEngineSettingsClay *mesc = DRW_material_settings_get(mat, RE_engine_id_BLENDER_CLAY, (void ***)); + CLAY_update_material_runtime(mesc, runtime); } if (data.ubo_flag & CLAY_UBO_REFRESH) { @@ -507,15 +507,15 @@ static void CLAY_update_material_ubo(const struct bContext *C) /* Default materials */ for (Scene *sce = bmain->scene.first; sce; sce = sce->id.next) { - DRW_render_settings_get(sce, RE_engine_id_BLENDER_CLAY, (void **)); - update_ubo_storage(runtime, current_id); + DRW_render_settings_get(sce, RE_engine_id_BLENDER_CLAY, (void ***)); + update_ubo_storage(*runtime, current_id); current_id++; } /* TODO only add materials linked to geometry */ for (Material *mat = bmain->mat.first; mat; mat = mat->id.next) { - DRW_material_settings_get(mat, RE_engine_id_BLENDER_CLAY, (void **)); - update_ubo_storage(runtime, current_id); + DRW_material_settings_get(mat, RE_engine_id_BLENDER_CLAY, (void ***)); + update_ubo_storage(*runtime, current_id); current_id++; } @@ -540,12 +540,12 @@ static void CLAY_create_cache(CLAY_PassList *passes, const struct bContext *C) /* Clay Pass */ { - MaterialRuntimeClay *runtime; - DRW_render_settings_get(NULL, RE_engine_id_BLENDER_CLAY, (void **)); + MaterialRuntimeClay **runtime; + DRW_render_settings_get(NULL, RE_engine_id_BLENDER_CLAY, (void ***)); passes->clay_pass = DRW_pass_create("Clay Pass", DRW_STATE_WRITE_COLOR); - default_shgrp = CLAY_shgroup_create(passes->clay_pass, >material_id); + default_shgrp = CLAY_shgroup_create(passes->clay_pass, &(*runtime)->material_id); DRW_shgroup_uniform_block(default_shgrp, "material_block", data.mat_ubo, 0); } diff --git a/source/blender/draw/intern/DRW_r
[Bf-blender-cvs] [744f26b612] clay-engine: Change in DNA/RNA. Still missing freeing and read/write.
Commit: 744f26b6129fc3723f9934d358060a3cb931474c Author: Clément Foucault Date: Sun Jan 29 00:55:46 2017 +0100 Branches: clay-engine https://developer.blender.org/rB744f26b6129fc3723f9934d358060a3cb931474c Change in DNA/RNA. Still missing freeing and read/write. === M release/scripts/startup/bl_ui/properties_material.py M release/scripts/startup/bl_ui/properties_render.py M source/blender/blenkernel/intern/material.c M source/blender/blenkernel/intern/scene.c M source/blender/blenloader/intern/readfile.c M source/blender/blenloader/intern/versioning_280.c M source/blender/blenloader/intern/writefile.c M source/blender/draw/DRW_engine.h M source/blender/draw/engines/clay/clay.c M source/blender/draw/engines/clay/clay.h M source/blender/draw/intern/DRW_render.h M source/blender/draw/intern/draw_cache.c M source/blender/draw/intern/draw_cache.h M source/blender/draw/intern/draw_manager.c M source/blender/makesdna/DNA_material_types.h M source/blender/makesdna/DNA_scene_types.h M source/blender/makesrna/RNA_access.h M source/blender/makesrna/intern/CMakeLists.txt M source/blender/makesrna/intern/rna_material.c M source/blender/makesrna/intern/rna_scene.c === diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py index 04662095a0..e8ba7cc803 100644 --- a/release/scripts/startup/bl_ui/properties_material.py +++ b/release/scripts/startup/bl_ui/properties_material.py @@ -1060,16 +1060,16 @@ class MATERIAL_PT_clay_settings(MaterialButtonsPanel, Panel): def draw(self, context): layout = self.layout; settings = context.material.clay_settings -layout.template_icon_view(settings, "matcap_icon") -layout.prop(settings, "type") -layout.prop(settings, "matcap_rotation") -layout.prop(settings, "matcap_hue") -layout.prop(settings, "matcap_saturation") -layout.prop(settings, "matcap_value") -layout.prop(settings, "ssao_factor_cavity") -layout.prop(settings, "ssao_factor_edge") -layout.prop(settings, "ssao_distance") -layout.prop(settings, "ssao_attenuation") +# layout.template_icon_view(settings, "matcap_icon") +# layout.prop(settings, "type") +# layout.prop(settings, "matcap_rotation") +# layout.prop(settings, "matcap_hue") +# layout.prop(settings, "matcap_saturation") +# layout.prop(settings, "matcap_value") +# layout.prop(settings, "ssao_factor_cavity") +# layout.prop(settings, "ssao_factor_edge") +# layout.prop(settings, "ssao_distance") +# layout.prop(settings, "ssao_attenuation") if __name__ == "__main__": # only for live edit. diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py index 0d473d79ed..593072992f 100644 --- a/release/scripts/startup/bl_ui/properties_render.py +++ b/release/scripts/startup/bl_ui/properties_render.py @@ -590,17 +590,16 @@ class RENDER_PT_clay(RenderButtonsPanel, Panel): def draw(self, context): layout = self.layout; -settings = context.scene.clay_settings -matsettings = context.scene.clay_settings.mat_settings -layout.template_icon_view(matsettings, "matcap_icon") -layout.prop(matsettings, "matcap_rotation") -layout.prop(matsettings, "matcap_hue") -layout.prop(matsettings, "matcap_saturation") -layout.prop(matsettings, "matcap_value") -layout.prop(matsettings, "ssao_factor_cavity") -layout.prop(matsettings, "ssao_factor_edge") -layout.prop(matsettings, "ssao_distance") -layout.prop(matsettings, "ssao_attenuation") +settings = context.scene.render_engine +layout.template_icon_view(settings, "matcap_icon") +layout.prop(settings, "matcap_rotation") +layout.prop(settings, "matcap_hue") +layout.prop(settings, "matcap_saturation") +layout.prop(settings, "matcap_value") +layout.prop(settings, "ssao_factor_cavity") +layout.prop(settings, "ssao_factor_edge") +layout.prop(settings, "ssao_distance") +layout.prop(settings, "ssao_attenuation") layout.prop(settings, "ssao_samples") diff --git a/source/blender/blenkernel/intern/material.c b/source/blend
[Bf-blender-cvs] [5bf60530e5] clay-engine: Added switch to test viewport cache
Commit: 5bf60530e5f1843b613439ea05790412d7f74d41 Author: Clément Foucault Date: Fri Jan 27 12:44:41 2017 +0100 Branches: clay-engine https://developer.blender.org/rB5bf60530e5f1843b613439ea05790412d7f74d41 Added switch to test viewport cache === M source/blender/draw/DRW_engine.h M source/blender/draw/engines/clay/clay.c M source/blender/draw/intern/DRW_render.h M source/blender/draw/intern/draw_manager.c M source/blender/editors/space_view3d/view3d_draw.c M source/blender/gpu/intern/gpu_viewport.c === diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h index ad05cf625f..d58e2406fa 100644 --- a/source/blender/draw/DRW_engine.h +++ b/source/blender/draw/DRW_engine.h @@ -26,6 +26,8 @@ #ifndef __DRW_ENGINE_H__ #define __DRW_ENGINE_H__ +//#define WITH_VIEWPORT_CACHE_TEST + struct DRWPass; void DRW_engines_init(void); diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c index f741cb54b9..cf5720b911 100644 --- a/source/blender/draw/engines/clay/clay.c +++ b/source/blender/draw/engines/clay/clay.c @@ -577,11 +577,18 @@ static void CLAY_view_draw(RenderEngine *UNUSED(engine), const struct bContext * /* TODO : tag to refresh by the deps graph */ /* ideally only refresh when objects are added/removed */ /* or render properties / materials change */ - //static bool once = false; +#ifdef WITH_VIEWPORT_CACHE_TEST + static bool once = false; + printf("AA\n"); +#endif if (DRW_viewport_cache_is_dirty() - //&& !once +#ifdef WITH_VIEWPORT_CACHE_TEST + && !once +#endif ) { - //once = true; +#ifdef WITH_VIEWPORT_CACHE_TEST + once = true; +#endif CLAY_create_cache(passes, context); } diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 8daf97875b..75f5a124a1 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -50,6 +50,8 @@ #include "RE_engine.h" +//#define WITH_VIEWPORT_CACHE_TEST + struct GPUFrameBuffer; struct GPUShader; struct GPUTexture; diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index a2ddf07079..0bb651897b 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -446,6 +446,10 @@ static void shgroup_dynamic_batch_from_calls(DRWShadingGroup *shgroup) int nbr = BLI_listbase_count(>calls); GLenum type; +#ifdef WITH_VIEWPORT_CACHE_TEST + if (shgroup->dyngeom) return; +#endif + if (nbr == 0) { if (shgroup->dyngeom) { Batch_discard(shgroup->dyngeom); @@ -457,7 +461,6 @@ static void shgroup_dynamic_batch_from_calls(DRWShadingGroup *shgroup) /* Gather Data */ float *data = MEM_mallocN(sizeof(float) * 3 * nbr , "Object Center Batch data"); - /* TODO do something more generic usable for other things than obj center */ for (DRWCall *call = shgroup->calls.first; call; call = call->next, i++) { copy_v3_v3([i*3], call->obmat[3]); } @@ -506,6 +509,7 @@ void DRW_pass_free(DRWPass *pass) BLI_freelistN(>shgroups); } +/* TODO this is slow we should not have to use this (better store shgroup pointer somewhere) */ DRWShadingGroup *DRW_pass_nth_shgroup_get(DRWPass *pass, int n) { int i = 0; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index c8f0a4e325..f428b2cec4 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2109,7 +2109,7 @@ static void view3d_render_pass(const bContext *C, ARegion *ar) } } -static void view3d_draw_view_new(const bContext *C, ARegion *ar, DrawData *draw_data) +static void view3d_draw_view_new(const bContext *C, ARegion *ar, DrawData *UNUSED(draw_data)) { view3d_draw_setup_view(C, ar); diff --git a/source/blender/gpu/intern/gpu_viewport.c b/source/blender/gpu/intern/gpu_viewport.c index 015d71ac56..b1964857ab 100644 --- a/source/blender/gpu/intern/gpu_viewport.c +++ b/source/blender/gpu/intern/gpu_viewport.c @@ -87,8 +87,10 @@ void GPU_viewport_bind(GPUViewport *viewport, const rcti *rect) /* add one pixel because of scissor test */ int rect_w = BLI_rcti_size_x(rect) + 1, rect_h = BLI_rcti_size_y(rect) + 1; +#ifndef WITH_VIEWPORT_CACHE_TEST /* TODO for testing only, we need proper cache invalidation */ GPU_viewport_passes_free(viewport); +#endif if (viewport->fbl->default_fb) {
[Bf-blender-cvs] [e15c16f11c] clay-engine: Changes to DNA/RNA. Follow same layout as sensors.
Commit: e15c16f11c08a13ef8288ee500d2d317634c Author: Clément Foucault Date: Mon Jan 30 02:24:18 2017 +0100 Branches: clay-engine https://developer.blender.org/rBe15c16f11c08a13ef8288ee500d2d317634c Changes to DNA/RNA. Follow same layout as sensors. === M release/scripts/startup/bl_ui/properties_render.py M source/blender/draw/DRW_engine.h M source/blender/draw/engines/clay/clay.c M source/blender/draw/intern/DRW_render.h M source/blender/draw/intern/draw_manager.c M source/blender/makesdna/DNA_material_types.h M source/blender/makesdna/DNA_scene_types.h M source/blender/makesrna/RNA_access.h M source/blender/makesrna/intern/rna_material.c M source/blender/makesrna/intern/rna_scene.c === diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py index 593072992f..b1c68559d8 100644 --- a/release/scripts/startup/bl_ui/properties_render.py +++ b/release/scripts/startup/bl_ui/properties_render.py @@ -590,17 +590,17 @@ class RENDER_PT_clay(RenderButtonsPanel, Panel): def draw(self, context): layout = self.layout; -settings = context.scene.render_engine -layout.template_icon_view(settings, "matcap_icon") -layout.prop(settings, "matcap_rotation") -layout.prop(settings, "matcap_hue") -layout.prop(settings, "matcap_saturation") -layout.prop(settings, "matcap_value") -layout.prop(settings, "ssao_factor_cavity") -layout.prop(settings, "ssao_factor_edge") -layout.prop(settings, "ssao_distance") -layout.prop(settings, "ssao_attenuation") -layout.prop(settings, "ssao_samples") +# settings = context.scene.engine_settings +# layout.template_icon_view(settings, "matcap_icon") +# layout.prop(settings, "matcap_rotation") +# layout.prop(settings, "matcap_hue") +# layout.prop(settings, "matcap_saturation") +# layout.prop(settings, "matcap_value") +# layout.prop(settings, "ssao_factor_cavity") +# layout.prop(settings, "ssao_factor_edge") +# layout.prop(settings, "ssao_distance") +# layout.prop(settings, "ssao_attenuation") +# layout.prop(settings, "ssao_samples") if __name__ == "__main__": # only for live edit. diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h index 4f86e3fcd9..93b5e69d4d 100644 --- a/source/blender/draw/DRW_engine.h +++ b/source/blender/draw/DRW_engine.h @@ -39,7 +39,7 @@ void DRW_engines_free(void); void DRW_pass_free(struct DRWPass *pass); /* Settings */ -void *DRW_material_settings_get(struct Material *ma, const char *engine_name); -void *DRW_render_settings_get(struct Scene *scene, const char *engine_name); +void *DRW_material_settings_get(struct Material *ma, const char *engine_name, void **runtime); +void *DRW_render_settings_get(struct Scene *scene, const char *engine_name, void **runtime); #endif /* __DRW_ENGINE_H__ */ \ No newline at end of file diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c index 6e155776bb..d084a3383b 100644 --- a/source/blender/draw/engines/clay/clay.c +++ b/source/blender/draw/engines/clay/clay.c @@ -237,7 +237,7 @@ static struct GPUTexture *create_jitter_texture(void) static void clay_material_settings_init(MaterialEngineSettingsClay *ma) { - ma->matcap_icon = 0; + ma->matcap_icon = ICON_MATCAP_01; ma->matcap_rot = 0.0f; ma->matcap_hue = 0.5f; ma->matcap_sat = 0.5f; @@ -252,8 +252,6 @@ RenderEngineSettings *CLAY_render_settings_create(void) { RenderEngineSettingsClay *settings = MEM_callocN(sizeof(RenderEngineSettingsClay), "RenderEngineSettingsClay"); - BLI_strncpy(settings->res.name, RE_engine_id_BLENDER_CLAY, 64); - clay_material_settings_init((MaterialEngineSettingsClay *)settings); settings->ssao_samples = 32; @@ -265,8 +263,6 @@ MaterialEngineSettings *CLAY_material_settings_create(void) { MaterialEngineSettingsClay *settings = MEM_callocN(sizeof(MaterialEngineSettingsClay), "MaterialEngineSettingsClay"); - BLI_strncpy(settings->mes.name, RE_engine_id_BLENDER_CLAY, 64); - clay_material_settings_init(settings); return (MaterialEngineSettings *)settings; @@ -366,7 +362,7 @@ static void CLAY_ssao_setup(void) }; int i; float *size = DRW_viewport_size_get(); - RenderEngineSettingsClay *settings = DRW_render_settings_get(NULL, RE_engine_id_BLENDER_
[Bf-blender-cvs] [95e9790704] render-layers: Fix compile error
Commit: 95e9790704c61cb26171f4c7c84673eacd5ac3bd Author: Clément Foucault Date: Wed Jan 25 12:21:43 2017 +0100 Branches: render-layers https://developer.blender.org/rB95e9790704c61cb26171f4c7c84673eacd5ac3bd Fix compile error === M source/blender/editors/mesh/mesh_navmesh.c === diff --git a/source/blender/editors/mesh/mesh_navmesh.c b/source/blender/editors/mesh/mesh_navmesh.c index 3910ef40fd..cc6a5d578a 100644 --- a/source/blender/editors/mesh/mesh_navmesh.c +++ b/source/blender/editors/mesh/mesh_navmesh.c @@ -460,6 +460,7 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh, static int navmesh_create_exec(bContext *C, wmOperator *op) { + Scene *scene = CTX_data_scene(C); SceneLayer *sl = CTX_data_scene_layer(C); LinkNode *obs = NULL; Base *navmeshBase = NULL; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [efa401b086] clay-engine: Introduce Dynamic Batches + Relationship lines + Clear some matrix warnings
Commit: efa401b086fe558ab100309a727c6d04e7387f10 Author: Clément Foucault Date: Fri Jan 27 11:18:16 2017 +0100 Branches: clay-engine https://developer.blender.org/rBefa401b086fe558ab100309a727c6d04e7387f10 Introduce Dynamic Batches + Relationship lines + Clear some matrix warnings === M source/blender/draw/engines/clay/clay.c M source/blender/draw/intern/DRW_render.h M source/blender/draw/intern/draw_manager.c M source/blender/draw/intern/draw_mode_pass.c M source/blender/draw/intern/draw_mode_pass.h M source/blender/editors/space_view3d/view3d_draw.c === diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c index ffdad41bef..f741cb54b9 100644 --- a/source/blender/draw/engines/clay/clay.c +++ b/source/blender/draw/engines/clay/clay.c @@ -534,8 +534,8 @@ static void CLAY_create_cache(CLAY_PassList *passes, const struct bContext *C) geom = DRW_cache_surface_get(ob); /* Add everything for now */ - DRW_shgroup_call_add(depthbatch, geom, >obmat); - DRW_shgroup_call_add(default_shgrp, geom, >obmat); + DRW_shgroup_call_add(depthbatch, geom, ob->obmat); + DRW_shgroup_call_add(default_shgrp, geom, ob->obmat); /* When encountering a new material : * - Create new Batch @@ -554,14 +554,10 @@ static void CLAY_create_cache(CLAY_PassList *passes, const struct bContext *C) break; } - /* Add all object center for now */ DRW_shgroup_object_center(passes->ob_center_pass, ob); + DRW_shgroup_relationship_lines(passes->non_meshes_pass, ob); } FOREACH_OBJECT_END - - /* Optimization */ - // DRWShadingGroup *shgrp = DRW_pass_nth_shgroup_get(passes->ob_center_pass, 0); - // DRW_shgroup_batch_calls_object_center(shgrp); } static void CLAY_view_draw(RenderEngine *UNUSED(engine), const struct bContext *context) diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 419e5248bd..8daf97875b 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -149,29 +149,35 @@ typedef enum { DRW_STATE_WIRE= (1 << 6), DRW_STATE_WIRE_LARGE = (1 << 7), DRW_STATE_POINT = (1 << 8), - DRW_STATE_BLEND = (1 << 9) + DRW_STATE_STIPPLE_2 = (1 << 9), + DRW_STATE_STIPPLE_3 = (1 << 10), + DRW_STATE_STIPPLE_4 = (1 << 11), + DRW_STATE_BLEND = (1 << 12), } DRWState; +/* Used by DRWShadingGroup.dyntype */ +#define DRW_DYN_POINTS 1 +#define DRW_DYN_LINES 2 + DRWShadingGroup *DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass); -void DRW_shgroup_free(struct DRWShadingGroup *batch); -void DRW_shgroup_call_add(DRWShadingGroup *batch, struct Batch *geom, const float **obmat); -void DRW_shgroup_state_set(DRWShadingGroup *batch, DRWState state); +void DRW_shgroup_free(struct DRWShadingGroup *shgroup); +void DRW_shgroup_call_add(DRWShadingGroup *shgroup, struct Batch *geom, float (*obmat)[4]); +void DRW_shgroup_state_set(DRWShadingGroup *shgroup, DRWState state); +void DRW_shgroup_dyntype_set(DRWShadingGroup *shgroup, int type); -void DRW_shgroup_uniform_texture(DRWShadingGroup *batch, const char *name, const struct GPUTexture *tex, int loc); +void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, const struct GPUTexture *tex, int loc); void DRW_shgroup_uniform_block(DRWShadingGroup *shgroup, const char *name, const struct GPUUniformBuffer *ubo, int loc); -void DRW_shgroup_uniform_buffer(DRWShadingGroup *batch, const char *name, const int value, int loc); -void DRW_shgroup_uniform_bool(DRWShadingGroup *batch, const char *name, const bool *value, int arraysize); -void DRW_shgroup_uniform_float(DRWShadingGroup *batch, const char *name, const float *value, int arraysize); -void DRW_shgroup_uniform_vec2(DRWShadingGroup *batch, const char *name, const float *value, int arraysize); -void DRW_shgroup_uniform_vec3(DRWShadingGroup *batch, const char *name, const float *value, int arraysize); -void DRW_shgroup_uniform_vec4(DRWShadingGroup *batch, const char *name, const float *value, int arraysize); -void DRW_shgroup_uniform_int(DRWShadingGroup *batch, const char *name, const int *value, int arraysize); -void DRW_shgroup_uniform_ivec2(DRWShadingGroup *batch, const char *name, const int *value, int arraysize); -void DRW_shgroup_uniform_ivec3(DRWShadingGroup *batch, const char *name, const int *
[Bf-blender-cvs] [eff5924c75] blender2.8: OpenGl immediate mode: screen_draw.c
Commit: eff5924c75947bffba47a2c734f475f9dfe4bbb7 Author: Clément Foucault Date: Wed Feb 22 14:05:56 2017 +0100 Branches: blender2.8 https://developer.blender.org/rBeff5924c75947bffba47a2c734f475f9dfe4bbb7 OpenGl immediate mode: screen_draw.c === M source/blender/editors/screen/screen_draw.c === diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c index f73bed1633..56565b2a5f 100644 --- a/source/blender/editors/screen/screen_draw.c +++ b/source/blender/editors/screen/screen_draw.c @@ -34,15 +34,16 @@ /** - * Draw vertical shape visualizing future joining (left as well right direction of future joining). + * Draw horizontal shape visualizing future joining (left as well right direction of future joining). */ -static void draw_horizontal_join_shape(ScrArea *sa, char dir) +static void draw_horizontal_join_shape(ScrArea *sa, char dir, unsigned int pos) { vec2f points[10]; short i; float w, h; float width = sa->v3->vec.x - sa->v1->vec.x; float height = sa->v3->vec.y - sa->v1->vec.y; + return; if (height < width) { h = height / 8; @@ -93,24 +94,24 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir) } } - glBegin(GL_POLYGON); + immBegin(GL_TRIANGLE_FAN, 5); for (i = 0; i < 5; i++) - glVertex2f(points[i].x, points[i].y); - glEnd(); - glBegin(GL_POLYGON); + immVertex2f(pos, points[i].x, points[i].y); + immEnd(); + immBegin(GL_TRIANGLE_FAN, 5); for (i = 4; i < 8; i++) - glVertex2f(points[i].x, points[i].y); - glVertex2f(points[0].x, points[0].y); - glEnd(); + immVertex2f(pos, points[i].x, points[i].y); + immVertex2f(pos, points[0].x, points[0].y); + immEnd(); - glRectf(points[2].x, points[2].y, points[8].x, points[8].y); - glRectf(points[6].x, points[6].y, points[9].x, points[9].y); + immRectf(pos, points[2].x, points[2].y, points[8].x, points[8].y); + immRectf(pos, points[6].x, points[6].y, points[9].x, points[9].y); } /** * Draw vertical shape visualizing future joining (up/down direction). */ -static void draw_vertical_join_shape(ScrArea *sa, char dir) +static void draw_vertical_join_shape(ScrArea *sa, char dir, unsigned int pos) { vec2f points[10]; short i; @@ -167,91 +168,91 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir) } } - glBegin(GL_POLYGON); + immBegin(GL_TRIANGLE_FAN, 5); for (i = 0; i < 5; i++) - glVertex2f(points[i].x, points[i].y); - glEnd(); - glBegin(GL_POLYGON); + immVertex2f(pos, points[i].x, points[i].y); + immEnd(); + immBegin(GL_TRIANGLE_FAN, 5); for (i = 4; i < 8; i++) - glVertex2f(points[i].x, points[i].y); - glVertex2f(points[0].x, points[0].y); - glEnd(); + immVertex2f(pos, points[i].x, points[i].y); + immVertex2f(pos, points[0].x, points[0].y); + immEnd(); - glRectf(points[2].x, points[2].y, points[8].x, points[8].y); - glRectf(points[6].x, points[6].y, points[9].x, points[9].y); + immRectf(pos, points[2].x, points[2].y, points[8].x, points[8].y); + immRectf(pos, points[6].x, points[6].y, points[9].x, points[9].y); } /** * Draw join shape due to direction of joining. */ -static void draw_join_shape(ScrArea *sa, char dir) +static void draw_join_shape(ScrArea *sa, char dir, unsigned int pos) { if (dir == 'u' || dir == 'd') - draw_vertical_join_shape(sa, dir); + draw_vertical_join_shape(sa, dir, pos); else - draw_horizontal_join_shape(sa, dir); + draw_horizontal_join_shape(sa, dir, pos); } /** * Draw screen area darker with arrow (visualization of future joining). */ -static void scrarea_draw_shape_dark(ScrArea *sa, char dir) +static void scrarea_draw_shape_dark(ScrArea *sa, char dir, unsigned int pos) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor4ub(0, 0, 0, 50); - draw_join_shape(sa, dir); + immUniformColor4ub(0, 0, 0, 50); + draw_join_shape(sa, dir, pos); } /** * Draw screen area ligher with arrow shape ("eraser" of previous dark shape). */ -static void scrarea_draw_shape_light(ScrArea *sa, char UNUSED(dir)) +static void scrarea_draw_shape_light(ScrArea *sa, char UNUSED(dir), unsigned int pos) { glBlendFunc(GL_DST_COLOR, GL_SRC_ALPHA); /* value 181 was hardly computed: 181~105 */ - glColor4ub(255, 255, 255, 50); + immUniformColor4ub(255, 255, 255, 50); /* draw_join_shape(s
[Bf-blender-cvs] [3952349a81] blender2.8: OpenGl immediate mode: fix false positive (again)
Commit: 3952349a812b898ce1409de294a94cca0ca0c3d7 Author: Clément Foucault Date: Wed Feb 22 14:27:04 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB3952349a812b898ce1409de294a94cca0ca0c3d7 OpenGl immediate mode: fix false positive (again) === M source/blender/editors/space_view3d/drawarmature.c === diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index fbdf1de808..172df71bfc 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -133,7 +133,7 @@ static void set_pchan_colorset(Object *ob, bPoseChannel *pchan) } } -/* This function is for brightening/darkening a given color (like UI_ThemeColorShade()) */ +/* This function is for brightening/darkening a given color (like UI_GetThemeColorShade3ubv()) */ static void cp_shade_color3ub(unsigned char cp[3], const int offset) { int r, g, b; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d4f0e10cc4] blender2.8: OpenGl immediate mode: Fix false positive
Commit: d4f0e10cc47f89cbfcd14b4c70dfba25b019e7dc Author: Clément Foucault Date: Wed Feb 22 14:23:20 2017 +0100 Branches: blender2.8 https://developer.blender.org/rBd4f0e10cc47f89cbfcd14b4c70dfba25b019e7dc OpenGl immediate mode: Fix false positive === M source/blender/editors/space_view3d/drawarmature.c === diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index c14a4f980a..fbdf1de808 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -80,7 +80,7 @@ static ThemeWireColor *bcolor = NULL; static float fcolor[4] = {0.0f}; static bool flat_color; -/* values of colCode for set_pchan_glcolor */ +/* values of colCode for set_pchan_color */ enum { PCHAN_COLOR_NORMAL = 0,/* normal drawing */ PCHAN_COLOR_SOLID, /* specific case where "solid" color is needed */ @@ -151,7 +151,7 @@ static void cp_shade_color3ub(unsigned char cp[3], const int offset) } /* This function sets the gl-color for coloring a certain bone (based on bcolor) */ -static bool set_pchan_glColor(short colCode, int boneflag, short constflag) +static bool set_pchan_color(short colCode, int boneflag, short constflag) { switch (colCode) { case PCHAN_COLOR_NORMAL: @@ -314,7 +314,7 @@ static bool set_pchan_glColor(short colCode, int boneflag, short constflag) return false; } -static void set_ebone_glColor(const unsigned int boneflag) +static void set_ebone_color(const unsigned int boneflag) { if ((boneflag & BONE_DRAW_ACTIVE) && (boneflag & BONE_SELECTED)) { UI_GetThemeColor4fv(TH_EDGE_SELECT, fcolor); @@ -684,7 +684,7 @@ static void draw_bone_points(const short dt, int armflag, unsigned int boneflag, } else { if (armflag & ARM_POSEMODE) - set_pchan_glColor(PCHAN_COLOR_SOLID, boneflag, 0); + set_pchan_color(PCHAN_COLOR_SOLID, boneflag, 0); else { UI_GetThemeColor4fv(TH_BONE_SOLID, fcolor); } @@ -712,7 +712,7 @@ static void draw_bone_points(const short dt, int armflag, unsigned int boneflag, } else { if (armflag & ARM_POSEMODE) - set_pchan_glColor(PCHAN_COLOR_SOLID, boneflag, 0); + set_pchan_color(PCHAN_COLOR_SOLID, boneflag, 0); else { UI_GetThemeColor4fv(TH_BONE_SOLID, fcolor); } @@ -920,7 +920,7 @@ static void draw_sphere_bone_wire(float smat[4][4], float imat[4][4], } } else if (armflag & ARM_POSEMODE) - set_pchan_glColor(PCHAN_COLOR_NORMAL, boneflag, constflag); + set_pchan_color(PCHAN_COLOR_NORMAL, boneflag, constflag); immUniformColor4fv(fcolor); @@ -1045,7 +1045,7 @@ static void draw_sphere_bone(const short dt, int armflag, int boneflag, short co UI_GetThemeColorShade4fv(TH_BONE_SOLID, -30, fcolor); } else if (armflag & ARM_POSEMODE) - set_pchan_glColor(PCHAN_COLOR_SPHEREBONE_END, boneflag, constflag); + set_pchan_color(PCHAN_COLOR_SPHEREBONE_END, boneflag, constflag); else if (dt == OB_SOLID) UI_GetThemeColorShade4fv(TH_BONE_SOLID, -30, fcolor); @@ -1086,7 +1086,7 @@ static void draw_sphere_bone(const short dt, int armflag, int boneflag, short co else UI_GetThemeColor4fv(TH_BONE_SOLID, fcolor); } else if (armflag & ARM_POSEMODE) - set_pchan_glColor(PCHAN_COLOR_SPHEREBONE_BASE, boneflag, constflag); + set_pchan_color(PCHAN_COLOR_SPHEREBONE_BASE, boneflag, constflag); else if (dt == OB_SOLID) UI_GetThemeColor4fv(TH_BONE_SOLID, fcolor); @@ -1174,7 +1174,7 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned glPointSize(8.0f); if (armflag & ARM_POSEMODE) - set_pchan_glColor(PCHAN_COLOR_NORMAL, boneflag, constflag); + set_pchan_color(PCHAN_COLOR_NORMAL, boneflag, constflag); else if (armflag & ARM_EDITMODE) { UI_GetThemeColor4fv(TH_WIRE_EDIT, fcolor); } @@ -1222,7 +1222,7 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned GPU_select_load_id(id & 0x); /* object tag, for bordersel optim */ if (armflag & ARM_POSEMODE) -
[Bf-blender-cvs] [48752d8802] blender2.8: OpenGL: Fix Object Axes color
Commit: 48752d880225c373b1be177b008eec6b9b61d510 Author: Clément Foucault Date: Wed Feb 22 14:24:09 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB48752d880225c373b1be177b008eec6b9b61d510 OpenGL: Fix Object Axes color === M source/blender/editors/space_view3d/drawobject.c === diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index fb190293d7..1b8acde421 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -8753,7 +8753,13 @@ afterdraw: if (dtx && (G.f & G_RENDER_OGL) == 0) { if (dtx & OB_AXIS) { - drawaxes(rv3d->viewmatob, 1.0f, OB_ARROWS, NULL); + if ((dflag & DRAW_CONSTCOLOR) == 0) { + /* prevent random colors being used */ + drawaxes(rv3d->viewmatob, 1.0f, OB_ARROWS, ob_wire_col); + } + else { + drawaxes(rv3d->viewmatob, 1.0f, OB_ARROWS, NULL); + } } if (dtx & OB_DRAWBOUNDOX) { draw_bounding_volume(ob, ob->boundtype); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [48aeb0b640] blender2.8: Clay Engine: Renaming shader.
Commit: 48aeb0b64008a947c5165d45d4a78f142f70e84c Author: Clément Foucault Date: Wed Feb 22 12:50:03 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB48aeb0b64008a947c5165d45d4a78f142f70e84c Clay Engine: Renaming shader. === M source/blender/draw/intern/draw_mode_pass.c M source/blender/gpu/CMakeLists.txt M source/blender/gpu/GPU_shader.h M source/blender/gpu/intern/gpu_shader.c R100 source/blender/gpu/shaders/gpu_shader_instance_screenspace_axis_name_vert.glsl source/blender/gpu/shaders/gpu_shader_instance_screen_aligned_axis_name_vert.glsl === diff --git a/source/blender/draw/intern/draw_mode_pass.c b/source/blender/draw/intern/draw_mode_pass.c index 08fba9479c..6c041294d3 100644 --- a/source/blender/draw/intern/draw_mode_pass.c +++ b/source/blender/draw/intern/draw_mode_pass.c @@ -143,7 +143,7 @@ static DRWShadingGroup *shgroup_instance_screenspace(DRWPass *pass, struct Batch static DRWShadingGroup *shgroup_instance_axis_names(DRWPass *pass, struct Batch *geom) { - GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_SCREENSPACE_AXIS); + GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED_AXIS); DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom); DRW_shgroup_attrib_float(grp, "color", 3); diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 2249f19881..98c7331e8d 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -160,7 +160,7 @@ data_to_c_simple(shaders/gpu_shader_instance_vert.glsl SRC) data_to_c_simple(shaders/gpu_shader_instance_variying_size_variying_color_vert.glsl SRC) data_to_c_simple(shaders/gpu_shader_instance_objectspace_variying_color_vert.glsl SRC) data_to_c_simple(shaders/gpu_shader_instance_screenspace_variying_color_vert.glsl SRC) -data_to_c_simple(shaders/gpu_shader_instance_screenspace_axis_name_vert.glsl SRC) +data_to_c_simple(shaders/gpu_shader_instance_screen_aligned_axis_name_vert.glsl SRC) data_to_c_simple(shaders/gpu_shader_3D_groundline_geom.glsl SRC) data_to_c_simple(shaders/gpu_shader_3D_groundpoint_vert.glsl SRC) diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h index f77fd3b6dc..9fe7c7a1c1 100644 --- a/source/blender/gpu/GPU_shader.h +++ b/source/blender/gpu/GPU_shader.h @@ -143,7 +143,7 @@ typedef enum GPUBuiltinShader { GPU_SHADER_3D_OBJECTSPACE_VARIYING_COLOR, GPU_SHADER_3D_OBJECTSPACE_SIMPLE_LIGHTING_VARIYING_COLOR, /* axis name */ - GPU_SHADER_3D_SCREENSPACE_AXIS, + GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED_AXIS, /* instance */ GPU_SHADER_INSTANCE_UNIFORM_COLOR, GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE, diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index a9d85838ac..e5c1dfb5bc 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -77,7 +77,7 @@ extern char datatoc_gpu_shader_instance_vert_glsl[]; extern char datatoc_gpu_shader_instance_variying_size_variying_color_vert_glsl[]; extern char datatoc_gpu_shader_instance_objectspace_variying_color_vert_glsl[]; extern char datatoc_gpu_shader_instance_screenspace_variying_color_vert_glsl[]; -extern char datatoc_gpu_shader_instance_screenspace_axis_name_vert_glsl[]; +extern char datatoc_gpu_shader_instance_screen_aligned_axis_name_vert_glsl[]; extern char datatoc_gpu_shader_3D_groundpoint_vert_glsl[]; extern char datatoc_gpu_shader_3D_groundline_geom_glsl[]; @@ -709,7 +709,7 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader) datatoc_gpu_shader_flat_color_frag_glsl}, [GPU_SHADER_3D_SCREENSPACE_VARIYING_COLOR] = { datatoc_gpu_shader_instance_screenspace_variying_color_vert_glsl, datatoc_gpu_shader_flat_color_frag_glsl}, - [GPU_SHADER_3D_SCREENSPACE_AXIS] = { datatoc_gpu_shader_instance_screenspace_axis_name_vert_glsl, + [GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED_AXIS] = { datatoc_gpu_shader_instance_screen_aligned_axis_name_vert_glsl, datatoc_gpu_shader_flat_color_frag_glsl}, [GPU_SHADER_2D_POINT_FIXED_SIZE_UNIFORM_COLOR] = diff --git a/source/blender/gpu/shaders/gpu_shader_instance_screenspace_axis_name_vert.glsl b/source/blender/gpu/shaders/gpu_shader_instance_screen_aligned_axis_name_vert.glsl similarity index 100% rename from source/blender/gpu/shaders/gpu_shader_instance_screenspace_axis_name_vert.glsl rename to source/blender/gpu/shaders/gpu_shader_instance_screen_aligned_axis_name
[Bf-blender-cvs] [6dbc6dfc14] blender2.8: Clay Engine: Prepare for Armature drawing.
Commit: 6dbc6dfc14e749f929be93a5025b255d41c30941 Author: Clément Foucault Date: Wed Feb 22 12:46:27 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB6dbc6dfc14e749f929be93a5025b255d41c30941 Clay Engine: Prepare for Armature drawing. - Added runtime display matrices to EditBone and bPoseChannel - Added Object space instance vertex shader and modified the simple lighting shader accordingly === M source/blender/editors/include/ED_armature.h M source/blender/gpu/CMakeLists.txt M source/blender/gpu/GPU_shader.h M source/blender/gpu/intern/gpu_shader.c A source/blender/gpu/shaders/gpu_shader_instance_objectspace_variying_color_vert.glsl M source/blender/gpu/shaders/gpu_shader_simple_lighting_frag.glsl M source/blender/makesdna/DNA_action_types.h === diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 3bde01a1bd..867e85487e 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -83,6 +83,12 @@ typedef struct EditBone { short segments; + /* Used for display */ + float disp_mat[4][4]; /* in Armature space, rest pos matrix */ + float disp_tail_mat[4][4]; /* in Armature space, rest pos matrix */ + /* 32 == MAX_BBONE_SUBDIV */ + float disp_bbone_mat[32][4][4]; /* in Armature space, rest pos matrix */ + /* Used to store temporary data */ union { struct EditBone *ebone; diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index a59971610e..2249f19881 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -158,6 +158,7 @@ data_to_c_simple(shaders/gpu_shader_3D_passthrough_vert.glsl SRC) data_to_c_simple(shaders/gpu_shader_instance_vert.glsl SRC) data_to_c_simple(shaders/gpu_shader_instance_variying_size_variying_color_vert.glsl SRC) +data_to_c_simple(shaders/gpu_shader_instance_objectspace_variying_color_vert.glsl SRC) data_to_c_simple(shaders/gpu_shader_instance_screenspace_variying_color_vert.glsl SRC) data_to_c_simple(shaders/gpu_shader_instance_screenspace_axis_name_vert.glsl SRC) diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h index 2ea2cc..f77fd3b6dc 100644 --- a/source/blender/gpu/GPU_shader.h +++ b/source/blender/gpu/GPU_shader.h @@ -139,6 +139,9 @@ typedef enum GPUBuiltinShader { GPU_SHADER_3D_GROUNDPOINT, GPU_SHADER_3D_GROUNDLINE, GPU_SHADER_3D_SCREENSPACE_VARIYING_COLOR, + /* bone drawing */ + GPU_SHADER_3D_OBJECTSPACE_VARIYING_COLOR, + GPU_SHADER_3D_OBJECTSPACE_SIMPLE_LIGHTING_VARIYING_COLOR, /* axis name */ GPU_SHADER_3D_SCREENSPACE_AXIS, /* instance */ diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index 8cae197408..a9d85838ac 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -75,6 +75,7 @@ extern char datatoc_gpu_shader_3D_passthrough_vert_glsl[]; extern char datatoc_gpu_shader_instance_vert_glsl[]; extern char datatoc_gpu_shader_instance_variying_size_variying_color_vert_glsl[]; +extern char datatoc_gpu_shader_instance_objectspace_variying_color_vert_glsl[]; extern char datatoc_gpu_shader_instance_screenspace_variying_color_vert_glsl[]; extern char datatoc_gpu_shader_instance_screenspace_axis_name_vert_glsl[]; @@ -701,6 +702,11 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader) datatoc_gpu_shader_uniform_color_frag_glsl, datatoc_gpu_shader_3D_groundline_geom_glsl }, + [GPU_SHADER_3D_OBJECTSPACE_SIMPLE_LIGHTING_VARIYING_COLOR] = + { datatoc_gpu_shader_instance_objectspace_variying_color_vert_glsl, + datatoc_gpu_shader_simple_lighting_frag_glsl}, + [GPU_SHADER_3D_OBJECTSPACE_VARIYING_COLOR] = { datatoc_gpu_shader_instance_objectspace_variying_color_vert_glsl, + datatoc_gpu_shader_flat_color_frag_glsl}, [GPU_SHADER_3D_SCREENSPACE_VARIYING_COLOR] = { datatoc_gpu_shader_instance_screenspace_variying_color_vert_glsl, datatoc_gpu_shader_flat_color_frag_glsl}, [GPU_SHADER_3D_SCREENSPACE_AXIS] = { datatoc_gpu_shader_instance_screenspace_axis_name_vert_glsl, @@ -745,7 +751,8 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader) if (builtin_shaders[shader] == NULL) { /* just a few special cases */ const char *defines = (shader
[Bf-blender-cvs] [e05d3d5d9b] blender2.8: Clay Engine: Fix Memory Leak.
Commit: e05d3d5d9b0fff6efce57f015129892c29ab067e Author: Clément Foucault Date: Wed Feb 22 12:19:10 2017 +0100 Branches: blender2.8 https://developer.blender.org/rBe05d3d5d9b0fff6efce57f015129892c29ab067e Clay Engine: Fix Memory Leak. === M source/blender/draw/intern/draw_manager.c === diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 015d364fc6..f671cbc85e 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -457,7 +457,11 @@ void DRW_shgroup_free(struct DRWShadingGroup *shgroup) BLI_freelistN(>calls); BLI_freelistN(>interface->uniforms); BLI_freelistN(>interface->attribs); - /* TODO free instance vbo */ + + if (shgroup->interface->instance_vbo) { + glDeleteBuffers(1, >interface->instance_vbo); + } + MEM_freeN(shgroup->interface); if (shgroup->batch_geom) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [cd0d335183] blender2.8: Clay Engine: Started Armature drawing
Commit: cd0d335183c8aa2c947a68ed6d5ded02a3cf2d2a Author: Clément Foucault Date: Wed Feb 22 13:00:15 2017 +0100 Branches: blender2.8 https://developer.blender.org/rBcd0d335183c8aa2c947a68ed6d5ded02a3cf2d2a Clay Engine: Started Armature drawing This should give the overall direction to whom wants to finish it. - Renamed EDIT mode engine to EDIT_MESH mode engine - Introduce EDIT_ARMATURE mode engine - Started to port legacy drawarmature.c to draw_armature.c === M source/blender/blenkernel/intern/layer.c M source/blender/draw/CMakeLists.txt M source/blender/draw/DRW_engine.h A source/blender/draw/intern/draw_armature.c M source/blender/draw/intern/draw_cache.c M source/blender/draw/intern/draw_cache.h M source/blender/draw/intern/draw_manager.c M source/blender/draw/intern/draw_mode_pass.c M source/blender/draw/intern/draw_mode_pass.h A source/blender/draw/modes/edit_armature_mode.c A source/blender/draw/modes/edit_armature_mode.h R081source/blender/draw/modes/edit_mode.c source/blender/draw/modes/edit_mesh_mode.c R075source/blender/draw/modes/edit_mode.h source/blender/draw/modes/edit_mesh_mode.h M source/blender/draw/modes/object_mode.c M source/blenderplayer/bad_level_call_stubs/stubs.c === diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index ad5a5081e1..621ac51aba 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -836,7 +836,7 @@ static void layer_collection_create_mode_settings_edit(ListBase *lb) ces->type = COLLECTION_MODE_EDIT; /* properties */ - EDIT_collection_settings_create(ces); + EDIT_MESH_collection_settings_create(ces); BLI_addtail(lb, ces); } diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index be517d799a..12722ff23e 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -55,8 +55,10 @@ set(SRC intern/draw_mode_pass.c intern/draw_cache.c intern/draw_view.c + intern/draw_armature.c engines/clay/clay.c - modes/edit_mode.c + modes/edit_armature_mode.c + modes/edit_mesh_mode.c modes/object_mode.c intern/DRW_render.h @@ -64,7 +66,8 @@ set(SRC intern/draw_cache.h intern/draw_view.h engines/clay/clay.h - modes/edit_mode.h + modes/edit_armature_mode.h + modes/edit_mesh_mode.h modes/object_mode.h ./DRW_engine.h diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h index 8ebd444b3f..05ecc7390d 100644 --- a/source/blender/draw/DRW_engine.h +++ b/source/blender/draw/DRW_engine.h @@ -43,6 +43,7 @@ void *DRW_render_settings_get(struct Scene *scene, const char *engine_name); /* Mode engines initialization */ void OBJECT_collection_settings_create(struct CollectionEngineSettings *ces); -void EDIT_collection_settings_create(struct CollectionEngineSettings *ces); +void EDIT_MESH_collection_settings_create(struct CollectionEngineSettings *ces); +void EDIT_ARMATURE_collection_settings_create(struct CollectionEngineSettings *ces); #endif /* __DRW_ENGINE_H__ */ diff --git a/source/blender/draw/intern/draw_armature.c b/source/blender/draw/intern/draw_armature.c new file mode 100644 index 00..68d1b3d7ea --- /dev/null +++ b/source/blender/draw/intern/draw_armature.c @@ -0,0 +1,323 @@ +/* + * Copyright 2016, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Blender Institute + * + */ + +/** \file draw_armature.c + * \ingroup draw + */ + +#include +#include +#include + +#include "DNA_anim_types.h" +#include "DNA_armature_types.h" +#include "DNA_constraint_types.h" +#include "DNA_scene_types.h" +#include "DNA_screen_types.h" +#include "DNA_view3d_types.h" +#include "DNA_object_types.h" + +#include "BLI_blenlib.h" +#include "BLI_math.h" +#include "BLI_dlrbTree.h" +#include "
[Bf-blender-cvs] [e003499f6f] blender2.8: OpenGl immediate mode: uvedit_smart_stich.c
Commit: e003499f6ffed72f3a166cca4d59e855774767d2 Author: Clément Foucault Date: Wed Feb 22 17:22:28 2017 +0100 Branches: blender2.8 https://developer.blender.org/rBe003499f6ffed72f3a166cca4d59e855774767d2 OpenGl immediate mode: uvedit_smart_stich.c This is a quick fix. A better fix should be to store the batches inside the StitchPreviewer struct. === M source/blender/editors/uvedit/uvedit_smart_stitch.c === diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index 50aec737c8..014aa65efb 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -63,6 +63,8 @@ #include "ED_screen.h" #include "ED_space_api.h" +#include "GPU_batch.h" + #include "RNA_access.h" #include "RNA_define.h" @@ -1538,63 +1540,118 @@ static void stitch_calculate_edge_normal(BMEditMesh *em, UvEdge *edge, float *no normalize_v2(normal); } +static void stitch_draw_vbo(VertexBuffer *vbo, int type, const float col[4]) +{ + Batch *batch = Batch_create(type, vbo, NULL); + Batch_set_builtin_program(batch, GPU_SHADER_2D_UNIFORM_COLOR); + Batch_Uniform4fv(batch, "color", col); + Batch_draw(batch); + Batch_discard_all(batch); +} + +/* TODO make things pretier : store batches inside StitchPreviewer instead of the bare verts pos */ static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *arg) { - int i, index = 0; + int j, index = 0; + unsigned int num_line = 0, num_tri, tri_idx = 0, line_idx = 0; StitchState *state = (StitchState *)arg; StitchPreviewer *stitch_preview = state->stitch_preview; + VertexBuffer *vbo, *vbo_line; + float col[4]; - glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT); - glEnableClientState(GL_VERTEX_ARRAY); + static VertexFormat format = { 0 }; + static unsigned pos_id; + if (format.attrib_ct == 0) { + pos_id = add_attrib(, "pos", GL_FLOAT, 2, KEEP_FLOAT); + } glEnable(GL_BLEND); - UI_ThemeColor4(TH_STITCH_PREVIEW_ACTIVE); - glVertexPointer(2, GL_FLOAT, 0, stitch_preview->static_tris); - glDrawArrays(GL_TRIANGLES, 0, stitch_preview->num_static_tris * 3); - - glVertexPointer(2, GL_FLOAT, 0, stitch_preview->preview_polys); - for (i = 0; i < stitch_preview->num_polys; i++) { - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - UI_ThemeColor4(TH_STITCH_PREVIEW_FACE); - glDrawArrays(GL_POLYGON, index, stitch_preview->uvs_per_polygon[i]); - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - UI_ThemeColor4(TH_STITCH_PREVIEW_EDGE); - glDrawArrays(GL_POLYGON, index, stitch_preview->uvs_per_polygon[i]); -#if 0 - glPolygonMode(GL_FRONT_AND_BACK, GL_POINT); - UI_ThemeColor4(TH_STITCH_PREVIEW_VERT); - glDrawArrays(GL_POLYGON, index, stitch_preview->uvs_per_polygon[i]); -#endif - - index += stitch_preview->uvs_per_polygon[i]; + /* Static Tris */ + UI_GetThemeColor4fv(TH_STITCH_PREVIEW_ACTIVE, col); + vbo = VertexBuffer_create_with_format(); + VertexBuffer_allocate_data(vbo, stitch_preview->num_static_tris * 3); + for (int i = 0; i < stitch_preview->num_static_tris * 3; i++) + setAttrib(vbo, pos_id, i, _preview->static_tris[i*2]); + stitch_draw_vbo(vbo, GL_TRIANGLES, col); + + + /* Preview Polys */ + for (int i = 0; i < stitch_preview->num_polys; i++) + num_line += stitch_preview->uvs_per_polygon[i]; + + num_tri = num_line - 2 * stitch_preview->num_polys; + + /* we need to convert the polys into triangles / lines */ + vbo = VertexBuffer_create_with_format(); + vbo_line = VertexBuffer_create_with_format(); + + VertexBuffer_allocate_data(vbo, num_tri * 3); + VertexBuffer_allocate_data(vbo_line, num_line * 2); + + for (int i = 0; i < stitch_preview->num_polys; i++) { + BLI_assert(stitch_preview->uvs_per_polygon[i] >= 3); + + /* Start line */ + setAttrib(vbo_line, pos_id, line_idx++, _preview->preview_polys[index]); + setAttrib(vbo_line, pos_id, line_idx++, _preview->preview_polys[index + 2]); + + for (j = 1; j < stitch_preview->uvs_per_polygon[i] - 1; ++j) { + setAttrib(vbo, pos_id, tri_idx++, _preview->preview_polys[index]); + setAttrib(vbo, pos_id, tri_idx++, _preview->preview_polys[index + (j+0)*2]); + setAttrib(vbo, pos_i
[Bf-blender-cvs] [5c39aad283] blender2.8: OpenGL immediate mode: interface_panel.c
Commit: 5c39aad2838418146d1c61ae3d3304829f6d487c Author: Clément Foucault Date: Mon Feb 20 15:17:23 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB5c39aad2838418146d1c61ae3d3304829f6d487c OpenGL immediate mode: interface_panel.c === M source/blender/editors/interface/interface_panel.c === diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index c6dc3ebd77..22129cd959 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -445,7 +445,7 @@ static void ui_draw_tria_rect(const rctf *rect, char dir) } } -static void ui_draw_anti_x(float x1, float y1, float x2, float y2) +static void ui_draw_anti_x(unsigned int pos, float x1, float y1, float x2, float y2) { /* set antialias line */ @@ -454,8 +454,8 @@ static void ui_draw_anti_x(float x1, float y1, float x2, float y2) glLineWidth(2.0); - fdrawline(x1, y1, x2, y2); - fdrawline(x1, y2, x2, y1); + imm_draw_line(pos, x1, y1, x2, y2); + imm_draw_line(pos, x1, y2, x2, y1); glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); @@ -463,16 +463,16 @@ static void ui_draw_anti_x(float x1, float y1, float x2, float y2) } /* x 'icon' for panel header */ -static void ui_draw_x_icon(float x, float y) +static void ui_draw_x_icon(unsigned int pos, float x, float y) { - ui_draw_anti_x(x, y, x + 9.375f, y + 9.375f); + ui_draw_anti_x(pos, x, y, x + 9.375f, y + 9.375f); } #define PNL_ICONUI_UNIT_X /* could be UI_UNIT_Y too */ -static void ui_draw_panel_scalewidget(const rcti *rect) +static void ui_draw_panel_scalewidget(unsigned int pos, const rcti *rect) { float xmin, xmax, dx; float ymin, ymax, dy; @@ -486,16 +486,16 @@ static void ui_draw_panel_scalewidget(const rcti *rect) dy = 0.5f * (ymax - ymin); glEnable(GL_BLEND); - glColor4ub(255, 255, 255, 50); - fdrawline(xmin, ymin, xmax, ymax); - fdrawline(xmin + dx, ymin, xmax, ymax - dy); + immUniformColor4ub(255, 255, 255, 50); + imm_draw_line(pos, xmin, ymin, xmax, ymax); + imm_draw_line(pos, xmin + dx, ymin, xmax, ymax - dy); - glColor4ub(0, 0, 0, 50); - fdrawline(xmin, ymin + 1, xmax, ymax + 1); - fdrawline(xmin + dx, ymin + 1, xmax, ymax - dy + 1); + immUniformColor4ub(0, 0, 0, 50); + imm_draw_line(pos, xmin, ymin + 1, xmax, ymax + 1); + imm_draw_line(pos, xmin + dx, ymin + 1, xmax, ymax - dy + 1); glDisable(GL_BLEND); } -static void ui_draw_panel_dragwidget(const rctf *rect) +static void ui_draw_panel_dragwidget(unsigned int pos, const rctf *rect) { unsigned char col_back[3], col_high[3], col_dark[3]; const int col_tint = 84; @@ -524,10 +524,10 @@ static void ui_draw_panel_dragwidget(const rctf *rect) const int x_co = (x_min + x_ofs) + (i_x * (box_size + box_margin)); const int y_co = (y_min + y_ofs) + (i_y * (box_size + box_margin)); - glColor3ubv(col_dark); - glRectf(x_co - box_size, y_co - px_zoom, x_co, (y_co + box_size) - px_zoom); - glColor3ubv(col_high); - glRectf(x_co - box_size, y_co, x_co, y_co + box_size); + immUniformColor3ubv(col_dark); + immRectf(pos, x_co - box_size, y_co - px_zoom, x_co, (y_co + box_size) - px_zoom); + immUniformColor3ubv(col_high); + immRectf(pos, x_co - box_size, y_co, x_co, y_co + box_size); } } } @@ -585,6 +585,9 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con headrect.ymin = headrect.ymax; headrect.ymax = headrect.ymin + floor(PNL_HEADER / block->aspect + 0.001f); + unsigned int pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, KEEP_FLOAT); + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + { float minx = rect->xmin; float maxx = is_closed_x ? (minx + PNL_HEADER / block->aspect) : rect->xmax; @@ -594,11 +597,11 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con if (UI_GetThemeValue(TH_PANEL_SHOW_HEADER)) { /* draw with background color */ - UI_ThemeColor4(TH_PANEL_HEADER); - glRectf(minx, headrect.ymin + 1, maxx, y); + immUniformThemeColor(TH_PANEL_HEADER); + immRectf(pos, minx, headrect.ymin + 1, maxx, y); - fdrawline(minx, y, maxx, y); - f
[Bf-blender-cvs] [4f2375b82f] blender2.8: OpenGL immediate mode: interface_widgets.c
Commit: 4f2375b82f721cc8157bd91cd4ee5b56d6e98985 Author: Clément Foucault Date: Mon Feb 20 21:21:04 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB4f2375b82f721cc8157bd91cd4ee5b56d6e98985 OpenGL immediate mode: interface_widgets.c Added rgba_float_args_set_ch to BLI_math_color.h === M source/blender/blenlib/BLI_math_color.h M source/blender/editors/interface/interface.c M source/blender/editors/interface/interface_intern.h M source/blender/editors/interface/interface_widgets.c === diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h index c7abe6192f..34fc52c12c 100644 --- a/source/blender/blenlib/BLI_math_color.h +++ b/source/blender/blenlib/BLI_math_color.h @@ -141,6 +141,9 @@ MINLINE void float_to_byte_dither_v3(unsigned char b[3], const float f[3], float #define rgba_char_args_set_fl(col, r, g, b, a) \ rgba_char_args_set(col, (r) * 255, (g) * 255, (b) * 255, (a) * 255) +#define rgba_float_args_set_ch(col, r, g, b, a) \ + rgba_float_args_set(col, (r) / 255.0f, (g) / 255.0f, (b) / 255.0f, (a) / 255.0f) + MINLINE void rgba_char_args_set(char col[4], const char r, const char g, const char b, const char a); MINLINE void rgba_float_args_set(float col[4], const float r, const float g, const float b, const float a); MINLINE void rgba_char_args_test_set(char col[4], const char r, const char g, const char b, const char a); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 682db20af5..fe9b3054ea 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -499,6 +499,7 @@ static int ui_but_calc_float_precision(uiBut *but, double value) static void ui_draw_linkline(uiLinkLine *line, int highlightActiveLines, int dashInactiveLines) { rcti rect; + float color[4] = {1.0f}; if (line->from == NULL || line->to == NULL) return; @@ -508,15 +509,15 @@ static void ui_draw_linkline(uiLinkLine *line, int highlightActiveLines, int das rect.ymax = BLI_rctf_cent_y(>to->rect); if (dashInactiveLines) - UI_ThemeColor(TH_GRID); + UI_GetThemeColor4fv(TH_GRID, color); else if (line->flag & UI_SELECT) - glColor3ub(100, 100, 100); + rgba_float_args_set_ch(color, 100, 100, 100, 255); else if (highlightActiveLines && ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE))) - UI_ThemeColor(TH_TEXT_HI); + UI_GetThemeColor4fv(TH_TEXT_HI, color); else - glColor3ub(0, 0, 0); + rgba_float_args_set_ch(color, 0, 0, 0, 255); - ui_draw_link_bezier(); + ui_draw_link_bezier(, color); } static void ui_draw_links(uiBlock *block) diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 73c527729e..9179f8039c 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -690,7 +690,7 @@ uiWidgetColors *ui_tooltip_get_theme(void); void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock *block, rcti *rect); void ui_draw_search_back(struct uiStyle *style, uiBlock *block, rcti *rect); bool ui_link_bezier_points(const rcti *rect, float coord_array[][2], int resol); -void ui_draw_link_bezier(const rcti *rect); +void ui_draw_link_bezier(const rcti *rect, const float color[4]); extern void ui_draw_but(const struct bContext *C, ARegion *ar, struct uiStyle *style, uiBut *but, rcti *rect); /* theme color init */ diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index ab71ff5373..6356ce1574 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -59,6 +59,7 @@ #include "GPU_basic_shader.h" #include "GPU_immediate.h" +#include "GPU_matrix.h" #ifdef WITH_INPUT_IME # include "WM_types.h" @@ -545,12 +546,27 @@ static void widget_scroll_circle(uiWidgetTrias *tria, const rcti *rect, float tr scroll_circle_face, ARRAY_SIZE(scroll_circle_face)); } -static void widget_trias_draw(uiWidgetTrias *tria) +static void widget_trias_draw(uiWidgetTrias *tria, unsigned int pos) { - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(2, GL_FLOAT, 0, tria->vec); - glDrawElements(GL_TRIANGLES, tria->tot * 3, GL_UNSIGNED_INT, tria->index); - glDisableClientState(GL_VERTEX_ARRAY); + immBegin(GL_TRIANGLES, tria->tot * 3); + for (int i = 0; i < tria->tot;
[Bf-blender-cvs] [446625c561] blender2.8: Clay Engine: Use G.debug_value to test cache performance
Commit: 446625c5610577a6a708b7550d93bd760c4fa2d5 Author: Clément Foucault Date: Sun Feb 19 14:31:02 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB446625c5610577a6a708b7550d93bd760c4fa2d5 Clay Engine: Use G.debug_value to test cache performance Use debug 666 for cache without instance buffer caching. Use debug 667 for cache with instance buffer caching. === M source/blender/draw/DRW_engine.h M source/blender/draw/engines/clay/clay.c M source/blender/draw/intern/DRW_render.h M source/blender/draw/intern/draw_manager.c M source/blender/gpu/intern/gpu_viewport.c === diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h index f5ac6e4c6c..8ebd444b3f 100644 --- a/source/blender/draw/DRW_engine.h +++ b/source/blender/draw/DRW_engine.h @@ -26,8 +26,6 @@ #ifndef __DRW_ENGINE_H__ #define __DRW_ENGINE_H__ -//#define WITH_VIEWPORT_CACHE_TEST - struct CollectionEngineSettings; struct DRWPass; struct Material; diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c index 314e0c08f6..9766bccd32 100644 --- a/source/blender/draw/engines/clay/clay.c +++ b/source/blender/draw/engines/clay/clay.c @@ -700,17 +700,8 @@ static void CLAY_view_draw(RenderEngine *UNUSED(engine), const bContext *context /* TODO : tag to refresh by the deps graph */ /* ideally only refresh when objects are added/removed */ /* or render properties / materials change */ -#ifdef WITH_VIEWPORT_CACHE_TEST - static bool once = false; -#endif - if (DRW_viewport_cache_is_dirty() -#ifdef WITH_VIEWPORT_CACHE_TEST - && !once -#endif - ) { -#ifdef WITH_VIEWPORT_CACHE_TEST - once = true; -#endif + if (DRW_viewport_cache_is_dirty()) { + SceneLayer *sl = CTX_data_scene_layer(context); CLAY_cache_init(); diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 83e48a02d1..1fa3b84eff 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -52,8 +52,6 @@ #include "RE_engine.h" -//#define WITH_VIEWPORT_CACHE_TEST - struct bContext; struct GPUFrameBuffer; struct GPUShader; diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index a834284b19..015d364fc6 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -672,9 +672,10 @@ static void shgroup_dynamic_instance(DRWShadingGroup *shgroup) static void shgroup_dynamic_batch_from_calls(DRWShadingGroup *shgroup) { -#ifdef WITH_VIEWPORT_CACHE_TEST - if (shgroup->interface->instance_vbo || shgroup->batch_geom) return; -#endif + if ((shgroup->interface->instance_vbo || shgroup->batch_geom) && + (G.debug_value == 667)) + return; + if (shgroup->type == DRW_SHG_INSTANCE) { shgroup_dynamic_instance(shgroup); } diff --git a/source/blender/gpu/intern/gpu_viewport.c b/source/blender/gpu/intern/gpu_viewport.c index a189f6770a..c8e60c089d 100644 --- a/source/blender/gpu/intern/gpu_viewport.c +++ b/source/blender/gpu/intern/gpu_viewport.c @@ -38,6 +38,8 @@ #include "DNA_vec_types.h" +#include "BKE_global.h" + #include "GPU_framebuffer.h" #include "GPU_glew.h" #include "GPU_immediate.h" @@ -115,11 +117,11 @@ void GPU_viewport_bind(GPUViewport *viewport, const rcti *rect, const char *engi /* add one pixel because of scissor test */ int rect_w = BLI_rcti_size_x(rect) + 1, rect_h = BLI_rcti_size_y(rect) + 1; -#ifndef WITH_VIEWPORT_CACHE_TEST - /* TODO for testing only, we need proper cache invalidation */ - GPU_viewport_passes_free(viewport->psl); - GPU_viewport_passes_free(viewport->psl_mode); -#endif + if (G.debug_value != 666 && G.debug_value != 667) { + /* TODO for testing only, we need proper cache invalidation */ + GPU_viewport_passes_free(viewport->psl); + GPU_viewport_passes_free(viewport->psl_mode); + } if (!STREQ(engine, viewport->engine_name)) { GPU_viewport_storage_free(viewport->stl); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [c8b7e7973a] blender2.8: OpenGL immediate mode: transform_manipulator.c
Commit: c8b7e7973af3d4675b0076103a727961e8c83ccc Author: Clément Foucault Date: Sun Feb 19 13:59:47 2017 +0100 Branches: blender2.8 https://developer.blender.org/rBc8b7e7973af3d4675b0076103a727961e8c83ccc OpenGL immediate mode: transform_manipulator.c === M source/blender/editors/transform/transform_manipulator.c === diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index 33f065b436..9072f96346 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -77,6 +77,8 @@ #include "transform.h" #include "GPU_select.h" +#include "GPU_immediate.h" +#include "GPU_matrix.h" /* return codes for select, and drawing flags */ @@ -706,10 +708,10 @@ static void test_manipulator_axis(const bContext *C) static float screen_aligned(RegionView3D *rv3d, float mat[4][4]) { - glTranslate3fv(mat[3]); + gpuTranslate3fv(mat[3]); /* sets view screen aligned */ - glRotatef(-360.0f * saacos(rv3d->viewquat[0]) / (float)M_PI, rv3d->viewquat[1], rv3d->viewquat[2], rv3d->viewquat[3]); + gpuRotate3f(-360.0f * saacos(rv3d->viewquat[0]) / (float)M_PI, rv3d->viewquat[1], rv3d->viewquat[2], rv3d->viewquat[3]); return len_v3(mat[0]); /* draw scale */ } @@ -722,7 +724,7 @@ static float screen_aligned(RegionView3D *rv3d, float mat[4][4]) * nsides = amount of points in ring * nrigns = amount of rings */ -static void partial_doughnut(float radring, float radhole, int start, int end, int nsides, int nrings) +static void partial_doughnut(unsigned int pos, float radring, float radhole, int start, int end, int nsides, int nrings) { float theta, phi, theta1; float cos_theta, sin_theta; @@ -745,7 +747,7 @@ static void partial_doughnut(float radring, float radhole, int start, int end, i sin_theta1 = sinf(theta1); if (do_caps && i == start) { // cap - glBegin(GL_POLYGON); + immBegin(GL_TRIANGLE_FAN, nsides+1); phi = 0.0; for (j = nsides; j >= 0; j--) { float cos_phi, sin_phi, dist; @@ -755,12 +757,12 @@ static void partial_doughnut(float radring, float radhole, int start, int end, i sin_phi = sinf(phi); dist = radhole + radring * cos_phi; - glVertex3f(cos_theta1 * dist, -sin_theta1 * dist, radring * sin_phi); + immVertex3f(pos, cos_theta1 * dist, -sin_theta1 * dist, radring * sin_phi); } - glEnd(); + immEnd(); } if (i >= start && i <= end) { - glBegin(GL_QUAD_STRIP); + immBegin(GL_TRIANGLE_STRIP, (nsides+1) * 2); phi = 0.0; for (j = nsides; j >= 0; j--) { float cos_phi, sin_phi, dist; @@ -770,14 +772,14 @@ static void partial_doughnut(float radring, float radhole, int start, int end, i sin_phi = sinf(phi); dist = radhole + radring * cos_phi; - glVertex3f(cos_theta1 * dist, -sin_theta1 * dist, radring * sin_phi); - glVertex3f(cos_theta * dist, -sin_theta * dist, radring * sin_phi); + immVertex3f(pos, cos_theta1 * dist, -sin_theta1 * dist, radring * sin_phi); + immVertex3f(pos, cos_theta * dist, -sin_theta * dist, radring * sin_phi); } - glEnd(); + immEnd(); } if (do_caps && i == end) {// cap - glBegin(GL_POLYGON); + immBegin(GL_TRIANGLE_FAN, nsides+1); phi = 0.0; for (j = nsides; j >= 0; j--) { float cos_phi, sin_phi, dist; @@ -787,9 +789,9 @@ static void partial_doughnut(float radring, float radhole, int start, int end, i sin_phi = sinf(phi); dist = radhole + radring * cos_phi; - glVertex3f(cos_theta * dist, -sin_theta * dist, radring * sin_phi); + immVertex3f(pos, cos_theta * dist, -sin_theta * dist, radring * sin_phi); } - glEnd(); + immEnd();
[Bf-blender-cvs] [6628446bdf] blender2.8: Opengl glaDrawPixels removal: editors/render
Commit: 6628446bdf47ae526e89755e5b0e31702a88457c Author: Clément Foucault Date: Fri Feb 24 01:16:33 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB6628446bdf47ae526e89755e5b0e31702a88457c Opengl glaDrawPixels removal: editors/render === M source/blender/editors/render/render_internal.c M source/blender/editors/render/render_preview.c === diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 950214b895..abb65d1ef1 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -1537,11 +1537,10 @@ void render_view3d_draw(RenderEngine *engine, const bContext *C) if (force_fallback == false) { if (IMB_colormanagement_setup_glsl_draw(>view_settings, >display_settings, dither, true)) { glEnable(GL_BLEND); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glPixelZoom(scale_x, scale_y); - glaDrawPixelsTex(xof, yof, rres.rectx, rres.recty, -GL_RGBA, GL_FLOAT, GL_NEAREST, rres.rectf); - glPixelZoom(1.0f, 1.0f); + glUseProgram(0); /* immDrawPixelsTex use it's own shader */ + immDrawPixelsTex(xof, yof, rres.rectx, rres.recty, +GL_RGBA, GL_FLOAT, GL_NEAREST, rres.rectf, +scale_x, scale_y, NULL);; glDisable(GL_BLEND); IMB_colormanagement_finish_glsl_draw(); @@ -1558,12 +1557,11 @@ void render_view3d_draw(RenderEngine *engine, const bContext *C) 4, dither, >view_settings, >display_settings); glEnable(GL_BLEND); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glPixelZoom(scale_x, scale_y); - glaDrawPixelsAuto(xof, yof, rres.rectx, rres.recty, - GL_RGBA, GL_UNSIGNED_BYTE, - GL_NEAREST, display_buffer); - glPixelZoom(1.0f, 1.0f); + glUseProgram(0); /* immDrawPixelsTex use it's own shader */ + immDrawPixelsTex(xof, yof, rres.rectx, rres.recty, +GL_RGBA, GL_UNSIGNED_BYTE, +GL_NEAREST, display_buffer, +scale_x, scale_y, NULL); glDisable(GL_BLEND); MEM_freeN(display_buffer); diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index b4c92ef0f9..c651cfdce0 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -599,7 +599,8 @@ static bool ed_preview_draw_rect(ScrArea *sa, int split, int first, rcti *rect, if (re) RE_AcquiredResultGet32(re, , (unsigned int *)rect_byte, 0); - glaDrawPixelsSafe(fx, fy, rres.rectx, rres.recty, rres.rectx, GL_RGBA, GL_UNSIGNED_BYTE, rect_byte); + immDrawPixelsTex(fx, fy, rres.rectx, rres.recty, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, rect_byte, +1.0f, 1.0f, NULL); MEM_freeN(rect_byte); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [45711c3fde] blender2.8: OpenGL immediate mode: new shader image shuffle color
Commit: 45711c3fde183a07810e33bd041aa3b74bd2d066 Author: Clément Foucault Date: Fri Feb 24 01:07:40 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB45711c3fde183a07810e33bd041aa3b74bd2d066 OpenGL immediate mode: new shader image shuffle color new shader to draw an image with one isolated channel === M source/blender/gpu/CMakeLists.txt M source/blender/gpu/GPU_shader.h M source/blender/gpu/intern/gpu_shader.c A source/blender/gpu/shaders/gpu_shader_image_shuffle_color_frag.glsl === diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 98c7331e8d..f4627231af 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -143,6 +143,7 @@ data_to_c_simple(shaders/gpu_shader_2D_flat_color_vert.glsl SRC) data_to_c_simple(shaders/gpu_shader_2D_smooth_color_vert.glsl SRC) data_to_c_simple(shaders/gpu_shader_2D_smooth_color_frag.glsl SRC) data_to_c_simple(shaders/gpu_shader_2D_image_vert.glsl SRC) +data_to_c_simple(shaders/gpu_shader_image_shuffle_color_frag.glsl SRC) data_to_c_simple(shaders/gpu_shader_image_mask_uniform_color_frag.glsl SRC) data_to_c_simple(shaders/gpu_shader_image_modulate_alpha_frag.glsl SRC) data_to_c_simple(shaders/gpu_shader_image_color_frag.glsl SRC) diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h index 9fe7c7a1c1..57309c2ebd 100644 --- a/source/blender/gpu/GPU_shader.h +++ b/source/blender/gpu/GPU_shader.h @@ -117,6 +117,7 @@ typedef enum GPUBuiltinShader { GPU_SHADER_3D_SMOOTH_COLOR, GPU_SHADER_3D_DEPTH_ONLY, /* basic image drawing */ + GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR, GPU_SHADER_2D_IMAGE_MASK_UNIFORM_COLOR, GPU_SHADER_3D_IMAGE_MODULATE_ALPHA, GPU_SHADER_3D_IMAGE_RECT_MODULATE_ALPHA, diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index e5c1dfb5bc..a9a8a10cc7 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -62,6 +62,7 @@ extern char datatoc_gpu_shader_2D_image_vert_glsl[]; extern char datatoc_gpu_shader_3D_image_vert_glsl[]; extern char datatoc_gpu_shader_image_color_frag_glsl[]; +extern char datatoc_gpu_shader_image_shuffle_color_frag_glsl[]; extern char datatoc_gpu_shader_image_interlace_frag_glsl[]; extern char datatoc_gpu_shader_image_mask_uniform_color_frag_glsl[]; extern char datatoc_gpu_shader_image_modulate_alpha_frag_glsl[]; @@ -690,6 +691,8 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader) datatoc_gpu_shader_2D_smooth_color_frag_glsl }, [GPU_SHADER_2D_IMAGE_COLOR] = { datatoc_gpu_shader_2D_image_vert_glsl, datatoc_gpu_shader_image_color_frag_glsl }, + [GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR] = { datatoc_gpu_shader_2D_image_vert_glsl, + datatoc_gpu_shader_image_shuffle_color_frag_glsl }, [GPU_SHADER_3D_UNIFORM_COLOR] = { datatoc_gpu_shader_3D_vert_glsl, datatoc_gpu_shader_uniform_color_frag_glsl }, [GPU_SHADER_3D_FLAT_COLOR] = { datatoc_gpu_shader_3D_flat_color_vert_glsl, datatoc_gpu_shader_flat_color_frag_glsl }, diff --git a/source/blender/gpu/shaders/gpu_shader_image_shuffle_color_frag.glsl b/source/blender/gpu/shaders/gpu_shader_image_shuffle_color_frag.glsl new file mode 100644 index 00..fa4f41b79f --- /dev/null +++ b/source/blender/gpu/shaders/gpu_shader_image_shuffle_color_frag.glsl @@ -0,0 +1,22 @@ + +#if __VERSION__ == 120 + varying vec2 texCoord_interp; + #define fragColor gl_FragColor +#else + in vec2 texCoord_interp; + out vec4 fragColor; + #define texture2D texture +#endif + +uniform sampler2D image; +uniform vec4 color; +uniform vec4 shuffle; + +void main() +{ + vec4 sample = texture2D(image, texCoord_interp); + fragColor = vec4(sample.r * shuffle.r + +sample.g * shuffle.g + +sample.b * shuffle.b + +sample.a * shuffle.a) * color; +} ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [071fdfbfb3] blender2.8: OpenGL immediate mode: fix asserts in clip dopesheet
Commit: 071fdfbfb3ad51b83da57628d9336bbce5cb8a79 Author: Clément Foucault Date: Thu Feb 23 16:38:29 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB071fdfbfb3ad51b83da57628d9336bbce5cb8a79 OpenGL immediate mode: fix asserts in clip dopesheet === M source/blender/editors/space_clip/clip_dopesheet_draw.c === diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c index 872e62dbc9..14d2ca21b0 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.c +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c @@ -216,7 +216,7 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) format = immVertexFormat(); pos_id = add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT); unsigned int size_id = add_attrib(format, "size", COMP_F32, 1, KEEP_FLOAT); - unsigned int color_id = add_attrib(format, "color", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT); + unsigned int color_id = add_attrib(format, "color", COMP_F32, 4, KEEP_FLOAT); unsigned int outline_color_id = add_attrib(format, "outlineColor", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND); @@ -225,7 +225,7 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) /* all same size with black outline */ immAttrib1f(size_id, 2.0f * STRIP_HEIGHT_HALF); - immAttrib3ub(outline_color_id, 0, 0, 0); + immAttrib4ub(outline_color_id, 0, 0, 0, 255); y = (float) CHANNEL_FIRST; /* start again at the top */ for (channel = dopesheet->channels.first; channel; channel = channel->next) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e5799d1389] blender2.8: OpenGL immediate mode: gpu_framebuffer.c
Commit: e5799d13897e43410758af4fcef9e1e71a25e719 Author: Clément Foucault Date: Wed Feb 22 19:57:58 2017 +0100 Branches: blender2.8 https://developer.blender.org/rBe5799d13897e43410758af4fcef9e1e71a25e719 OpenGL immediate mode: gpu_framebuffer.c I had to make some changes to the sep_gaussian_blur shader to be compliant for gl 3.3 leap === M source/blender/gpu/gawain/batch.c M source/blender/gpu/gawain/batch.h M source/blender/gpu/intern/gpu_framebuffer.c M source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_frag.glsl M source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_vert.glsl === diff --git a/source/blender/gpu/gawain/batch.c b/source/blender/gpu/gawain/batch.c index 81e694cc9b..a40e801d48 100644 --- a/source/blender/gpu/gawain/batch.c +++ b/source/blender/gpu/gawain/batch.c @@ -133,6 +133,17 @@ void Batch_done_using_program(Batch* batch) } } +void Batch_Uniform1i(Batch* batch, const char* name, int value) + { + int loc = glGetUniformLocation(batch->program, name); + +#if TRUST_NO_ONE + assert(loc != -1); +#endif + + glUniform1i(loc, value); + } + void Batch_Uniform1b(Batch* batch, const char* name, bool value) { int loc = glGetUniformLocation(batch->program, name); diff --git a/source/blender/gpu/gawain/batch.h b/source/blender/gpu/gawain/batch.h index 660ed9eb76..c12cc4e66a 100644 --- a/source/blender/gpu/gawain/batch.h +++ b/source/blender/gpu/gawain/batch.h @@ -50,6 +50,7 @@ void Batch_set_program(Batch*, GLuint program); void Batch_use_program(Batch*); // call before Batch_Uniform (temp hack?) void Batch_done_using_program(Batch*); +void Batch_Uniform1i(Batch*, const char* name, int value); void Batch_Uniform1b(Batch*, const char* name, bool value); void Batch_Uniform1f(Batch*, const char* name, float value); void Batch_Uniform2f(Batch*, const char* name, float x, float y); diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c index 3b44abb479..eb52825e02 100644 --- a/source/blender/gpu/intern/gpu_framebuffer.c +++ b/source/blender/gpu/intern/gpu_framebuffer.c @@ -32,9 +32,11 @@ #include "BKE_global.h" +#include "GPU_batch.h" #include "GPU_debug.h" #include "GPU_glew.h" #include "GPU_framebuffer.h" +#include "GPU_matrix.h" #include "GPU_shader.h" #include "GPU_texture.h" @@ -379,20 +381,48 @@ void GPU_framebuffer_blur( GPUFrameBuffer *fb, GPUTexture *tex, GPUFrameBuffer *blurfb, GPUTexture *blurtex) { + const float fullscreencos[4][2] = {{-1.0f, -1.0f}, {1.0f, -1.0f}, {-1.0f, 1.0f}, {1.0f, 1.0f}}; + const float fullscreenuvs[4][2] = {{0.0f, 0.0f}, {1.0f, 0.0f}, {0.0f, 1.0f}, {1.0f, 1.0f}}; + + static VertexFormat format = {0}; + static VertexBuffer vbo = {0}; + static Batch batch = {0}; + const float scaleh[2] = {1.0f / GPU_texture_width(blurtex), 0.0f}; const float scalev[2] = {0.0f, 1.0f / GPU_texture_height(tex)}; GPUShader *blur_shader = GPU_shader_get_builtin_shader(GPU_SHADER_SEP_GAUSSIAN_BLUR); - int scale_uniform, texture_source_uniform; if (!blur_shader) return; - scale_uniform = GPU_shader_get_uniform(blur_shader, "ScaleU"); - texture_source_uniform = GPU_shader_get_uniform(blur_shader, "textureSource"); + /* Preparing to draw quad */ + if (format.attrib_ct == 0) { + unsigned int i = 0; + /* Vertex format */ + unsigned int pos = add_attrib(, "pos", GL_FLOAT, 2, KEEP_FLOAT); + unsigned int uvs = add_attrib(, "uvs", GL_FLOAT, 2, KEEP_FLOAT); + + /* Vertices */ + VertexBuffer_init_with_format(, ); + VertexBuffer_allocate_data(, 36); + + for (int j = 0; j < 3; ++j) { + setAttrib(, uvs, i, fullscreenuvs[j]); setAttrib(, pos, i++, fullscreencos[j]); + } + for (int j = 1; j < 4; ++j) { + setAttrib(, uvs, i, fullscreenuvs[j]); setAttrib(, pos, i++, fullscreencos[j]); + } + + Batch_init(, GL_TRIANGLES, , NULL); + } - /* Blurring horizontally */ + glDisable(GL_DEPTH_TEST); + + /* Load fresh matrices */ + gpuMatrixBegin3D(); /* TODO: finish 2D API */ + /* Blurring horizontally */ /* We do the bind ourselves rather than using GPU_framebuffer_texture_bind() to avoid * pushing unnecessary matrices onto the OpenGL stack. */ glBindFramebuffer(GL_FRAMEBUFFER, blurfb->object); @@ -401,51 +431,32 @@ void GPU_framebuff
[Bf-blender-cvs] [c9e8584e7f] blender2.8: Opengl glaDrawPixels removal: windowmanager
Commit: c9e8584e7f9af60f9e7b6d1ae136915e300a52cb Author: Clément Foucault Date: Fri Feb 24 01:17:48 2017 +0100 Branches: blender2.8 https://developer.blender.org/rBc9e8584e7f9af60f9e7b6d1ae136915e300a52cb Opengl glaDrawPixels removal: windowmanager === M source/blender/windowmanager/intern/wm_dragdrop.c M source/blender/windowmanager/intern/wm_gesture.c === diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index 2d1dcd7f3c..3cb767f130 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -332,8 +332,9 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) if (rect) drag_rect_minmax(rect, x, y, x + drag->sx, y + drag->sy); else { - glColor4f(1.0, 1.0, 1.0, 0.65); /* this blends texture */ - glaDrawPixelsTexScaled(x, y, drag->imb->x, drag->imb->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, drag->imb->rect, drag->scale, drag->scale); + float col[4] = {1.0f, 1.0f, 1.0f, 0.65f}; /* this blends texture */ + immDrawPixelsTexScaled(x, y, drag->imb->x, drag->imb->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, + drag->imb->rect, drag->scale, drag->scale, 1.0f, 1.0f, col); } } else { diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index 4620eb..6114012404 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -52,8 +52,9 @@ #include "wm.h" #include "wm_subwindow.h" #include "wm_draw.h" -#include "GPU_basic_shader.h" +#include "GPU_basic_shader.h" +#include "GPU_shader.h" #include "BIF_glutil.h" @@ -253,6 +254,7 @@ static void draw_filled_lasso(wmWindow *win, wmGesture *gt) int i; rcti rect; rcti rect_win; + float red[4] = {1.0f, 0.0f, 0.0f, 0.0f}; for (i = 0; i < tot; i++, lasso += 2) { moves[i][0] = lasso[0]; @@ -278,28 +280,27 @@ static void draw_filled_lasso(wmWindow *win, wmGesture *gt) (const int (*)[2])moves, tot, draw_filled_lasso_px_cb, _fill_data); + /* Additive Blending */ + glEnable(GL_BLEND); + glBlendFunc(GL_ONE, GL_ONE); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glColor4f(1, 1, 1, 1); - glPixelTransferf(GL_RED_BIAS, 1); - glPixelTransferf(GL_GREEN_BIAS, 1); - glPixelTransferf(GL_BLUE_BIAS, 1); + GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR); + GPU_shader_bind(shader); + GPU_shader_uniform_vector(shader, GPU_shader_get_uniform(shader, "shuffle"), 4, 1, red); - GPU_basic_shader_bind(GPU_SHADER_TEXTURE_2D | GPU_SHADER_USE_COLOR); - - glEnable(GL_BLEND); - glaDrawPixelsTex(rect.xmin, rect.ymin, w, h, GL_ALPHA, GL_UNSIGNED_BYTE, GL_NEAREST, pixel_buf); - glDisable(GL_BLEND); + immDrawPixelsTex(rect.xmin, rect.ymin, w, h, GL_RED, GL_UNSIGNED_BYTE, GL_NEAREST, pixel_buf, 1.0f, 1.0f, NULL); + GPU_shader_unbind(); GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); - glPixelTransferf(GL_RED_BIAS, 0); - glPixelTransferf(GL_GREEN_BIAS, 0); - glPixelTransferf(GL_BLUE_BIAS, 0); - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + MEM_freeN(pixel_buf); + + glDisable(GL_BLEND); } MEM_freeN(moves); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e437841239] blender2.8: OpenGL immediate mode: modifying immDrawPixelsTex
Commit: e4378412394caaf84215ae52af0a916b71804cd0 Author: Clément Foucault Date: Thu Feb 23 14:31:40 2017 +0100 Branches: blender2.8 https://developer.blender.org/rBe4378412394caaf84215ae52af0a916b71804cd0 OpenGL immediate mode: modifying immDrawPixelsTex This way OCIO can be used with it. === M source/blender/editors/interface/interface_draw.c M source/blender/editors/screen/glutil.c === diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index c96e5c7316..afb6422ec4 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -1735,6 +1735,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc UI_draw_roundbox_gl_mode(GL_TRIANGLE_FAN, rect.xmin - 1, rect.ymin, rect.xmax + 1, rect.ymax + 1, 3.0f, color); } + GPU_shader_unbind(); /* make sure there is no program bound */ immDrawPixelsTex(rect.xmin, rect.ymin + 1, drawibuf->x, drawibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, drawibuf->rect, 1.0f, 1.0f, img_col); /* draw cross for pixel position */ diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index de24b8ec50..898fdb3bf9 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -618,8 +618,7 @@ void glaDrawPixelsAuto(float x, float y, int img_w, int img_h, int format, int t 0.0f, 0.0f, 0.0f, 0.0f); } -/* TODO this is utterly slow and need some love - * but in the meantime it's not using deprecated api */ +/* Use the currently bound shader if there is one */ void immDrawPixelsTexScaled_clipping(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect, float scaleX, float scaleY, @@ -687,9 +686,15 @@ void immDrawPixelsTexScaled_clipping(float x, float y, int img_w, int img_h, unsigned int pos = add_attrib(vert_format, "pos", GL_FLOAT, 2, KEEP_FLOAT); unsigned int texco = add_attrib(vert_format, "texCoord", GL_FLOAT, 2, KEEP_FLOAT); - immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR); - immUniform4fv("color", color); - immUniform1i("image", 0); + unsigned int program = glaGetOneInt(GL_CURRENT_PROGRAM); + + if (program) + immBindProgram(program); + else { + immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR); + immUniform1i("image", 0); + immUniform4fv("color", color); + } for (subpart_y = 0; subpart_y < nsubparts_y; subpart_y++) { for (subpart_x = 0; subpart_x < nsubparts_x; subpart_x++) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [44ea6fb857] blender2.8: OpenGL: Make glaDrawImBuf_glsl functions compatible with new immDrawPixels
Commit: 44ea6fb857fc9ea3b51734fb3782d8bfb5c05de6 Author: Clément Foucault Date: Fri Feb 24 01:15:21 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB44ea6fb857fc9ea3b51734fb3782d8bfb5c05de6 OpenGL: Make glaDrawImBuf_glsl functions compatible with new immDrawPixels And change relevant function calls. === M source/blender/editors/include/BIF_glutil.h M source/blender/editors/screen/glutil.c M source/blender/editors/space_clip/clip_draw.c M source/blender/editors/space_image/image_draw.c M source/blender/editors/space_node/drawnode.c === diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h index 2dd922be37..3ba8e2e2ec 100644 --- a/source/blender/editors/include/BIF_glutil.h +++ b/source/blender/editors/include/BIF_glutil.h @@ -297,22 +297,26 @@ void bgl_get_mats(bglMats *mats); /* Draw imbuf on a screen, preferably using GLSL display transform */ void glaDrawImBuf_glsl(struct ImBuf *ibuf, float x, float y, int zoomfilter, struct ColorManagedViewSettings *view_settings, - struct ColorManagedDisplaySettings *display_settings); + struct ColorManagedDisplaySettings *display_settings, + float zoom_x, float zoom_y); void glaDrawImBuf_glsl_clipping(struct ImBuf *ibuf, float x, float y, int zoomfilter, struct ColorManagedViewSettings *view_settings, struct ColorManagedDisplaySettings *display_settings, float clip_min_x, float clip_min_y, -float clip_max_x, float clip_max_y); +float clip_max_x, float clip_max_y, +float zoom_x, float zoom_y); /* Draw imbuf on a screen, preferably using GLSL display transform */ -void glaDrawImBuf_glsl_ctx(const struct bContext *C, struct ImBuf *ibuf, float x, float y, int zoomfilter); +void glaDrawImBuf_glsl_ctx(const struct bContext *C, struct ImBuf *ibuf, float x, float y, int zoomfilter, + float zoom_x, float zoom_y); void glaDrawImBuf_glsl_ctx_clipping(const struct bContext *C, struct ImBuf *ibuf, float x, float y, int zoomfilter, float clip_min_x, float clip_min_y, -float clip_max_x, float clip_max_y); +float clip_max_x, float clip_max_y, +float zoom_x, float zoom_y); void glaDrawBorderCorners(const struct rcti *border, float zoomx, float zoomy); diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 898fdb3bf9..8f228b2817 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -618,7 +618,11 @@ void glaDrawPixelsAuto(float x, float y, int img_w, int img_h, int format, int t 0.0f, 0.0f, 0.0f, 0.0f); } -/* Use the currently bound shader if there is one */ +/* Use the currently bound shader if there is one. + * To let it draw without other shaders use glUseProgram(0) + * or GPU_shader_unbind() before calling immDrawPixelsTex. + * + * If color is NULL then use white by default */ void immDrawPixelsTexScaled_clipping(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect, float scaleX, float scaleY, @@ -633,10 +637,8 @@ void immDrawPixelsTexScaled_clipping(float x, float y, int img_w, int img_h, int texid = get_cached_work_texture(_w, _h); int components; const bool use_clipping = ((clip_min_x < clip_max_x) && (clip_min_y < clip_max_y)); + float white[4] = {1.0f, 1.0f, 1.0f, 1.0f}; - /* Specify the color outside this function, and tex will modulate it. -* This is useful for changing alpha without using glPixelTransferf() -*/ glPixelStorei(GL_UNPACK_ROW_LENGTH, img_w); glBindTexture(GL_TEXTURE_2D, texid); @@ -688,14 +690,20 @@ void immDrawPixelsTexScaled_clipping(float x, float y, int img_w, int img_h, unsigned int program = glaGetOneInt(GL_CURRENT_PROGRAM); - if (program) + if (program) { immBindProgram(program); + + /* optionnal */ + if (glGetUniformLocation(program, "color") != -1) + immUniform4fv("color", (color) ? color : white); + } else { immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR);
[Bf-blender-cvs] [c2453007f4] blender2.8: Opengl glaDrawPixels removal: #if 0 glDrawPixels...
Commit: c2453007f4f61c2dda84a6a9dda0f9d275659f3f Author: Clément Foucault Date: Fri Feb 24 01:25:24 2017 +0100 Branches: blender2.8 https://developer.blender.org/rBc2453007f4f61c2dda84a6a9dda0f9d275659f3f Opengl glaDrawPixels removal: #if 0 glDrawPixels... === M source/blender/editors/include/BIF_glutil.h M source/blender/editors/screen/glutil.c === diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h index 3ba8e2e2ec..b81c7a8dcf 100644 --- a/source/blender/editors/include/BIF_glutil.h +++ b/source/blender/editors/include/BIF_glutil.h @@ -172,6 +172,7 @@ int glaGetOneInt(int param); */ void glaRasterPosSafe2f(float x, float y, float known_good_x, float known_good_y); +#if 0 /* Obsolete / unused */ /** * Functions like a limited glDrawPixels, except ensures that * the image is displayed onscreen even if the \a x and \a y @@ -205,11 +206,10 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo * modelview and projection matrices are assumed to define a * 1-to-1 mapping to screen space. */ - void glaDrawPixelsTex(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect); void glaDrawPixelsTex_clipping(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect, float clip_min_x, float clip_min_y, float clip_max_x, float clip_max_y); - +#endif /** * immDrawPixelsTex - Functions like a limited glDrawPixels, but actually draws the * image using textures, which can be tremendously faster on low-end @@ -227,7 +227,7 @@ void immDrawPixelsTex(float x, float y, int img_w, int img_h, int format, int ty void immDrawPixelsTex_clipping(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect, float clip_min_x, float clip_min_y, float clip_max_x, float clip_max_y, float xzoom, float yzoom, float color[4]); - +#if 0 /* Obsolete / unused */ /** * glaDrawPixelsAuto - Switches between texture or pixel drawing using UserDef. * only RGBA @@ -241,6 +241,7 @@ void glaDrawPixelsAuto_clipping(float x, float y, int img_w, int img_h, int form void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect, float scaleX, float scaleY); void glaDrawPixelsTexScaled_clipping(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect, float scaleX, float scaleY, float clip_min_x, float clip_min_y, float clip_max_x, float clip_max_y); +#endif void immDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect, float scaleX, float scaleY, float xzoom, float yzoom, float color[4]); @@ -261,7 +262,6 @@ void immDrawPixelsTexScaled_clipping(float x, float y, int img_w, int img_h, int * \param screen_rect The screen rectangle to be defined for 2D drawing. */ void glaDefine2DArea(struct rcti *screen_rect); - #if 0 /* UNUSED */ typedef struct gla2DDrawInfo gla2DDrawInfo; diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 8f228b2817..1b321c220a 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -352,6 +352,7 @@ static int get_cached_work_texture(int *r_w, int *r_h) return texid; } +#if 0 /* Obsolete / unused */ /* DEPRECATED: use immDrawPixelsTexScaled_clipping instead */ void glaDrawPixelsTexScaled_clipping(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect, @@ -617,6 +618,7 @@ void glaDrawPixelsAuto(float x, float y, int img_w, int img_h, int format, int t glaDrawPixelsAuto_clipping(x, y, img_w, img_h, format, type, zoomfilter, rect, 0.0f, 0.0f, 0.0f, 0.0f); } +#endif /* Use the currently bound shader if there is one. * To let it draw without other shaders use glUseProgram(0) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [2ea5446197] blender2.8: Opengl glaDrawPixels removal: interface
Commit: 2ea544619718796a7cb07558b680a7fe7716e877 Author: Clément Foucault Date: Fri Feb 24 01:21:02 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB2ea544619718796a7cb07558b680a7fe7716e877 Opengl glaDrawPixels removal: interface === M source/blender/editors/interface/interface_draw.c M source/blender/editors/interface/interface_icons.c M source/blender/editors/interface/interface_panel.c === diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index afb6422ec4..b48eb4d79d 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -476,6 +476,9 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w ImBuf *ibuf = (ImBuf *)but->poin; if (!ibuf) return; + + float facx = 1.0f; + float facy = 1.0f; int w = BLI_rcti_size_x(rect); int h = BLI_rcti_size_y(rect); @@ -492,16 +495,14 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w #endif glEnable(GL_BLEND); - glColor4f(0.0f, 0.0f, 0.0f, 0.0f); if (w != ibuf->x || h != ibuf->y) { - float facx = (float)w / (float)ibuf->x; - float facy = (float)h / (float)ibuf->y; - glPixelZoom(facx, facy); + facx = (float)w / (float)ibuf->x; + facy = (float)h / (float)ibuf->y; } - glaDrawPixelsAuto((float)rect->xmin, (float)rect->ymin, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, ibuf->rect); - - glPixelZoom(1.0f, 1.0f); + + immDrawPixelsTex((float)rect->xmin, (float)rect->ymin, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, ibuf->rect, +facx, facy, NULL); glDisable(GL_BLEND); @@ -1726,7 +1727,6 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc if (width > 0 && height > 0) { ImBuf *drawibuf = scopes->track_preview; - float img_col[4] = {1.0f, 1.0f, 1.0f, 1.0f}; float col_sel[4], col_outline[4]; if (scopes->use_track_mask) { @@ -1736,7 +1736,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc } GPU_shader_unbind(); /* make sure there is no program bound */ - immDrawPixelsTex(rect.xmin, rect.ymin + 1, drawibuf->x, drawibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, drawibuf->rect, 1.0f, 1.0f, img_col); + immDrawPixelsTex(rect.xmin, rect.ymin + 1, drawibuf->x, drawibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, drawibuf->rect, 1.0f, 1.0f, NULL); /* draw cross for pixel position */ gpuTranslate3f(rect.xmin + scopes->track_pos[0], rect.ymin + scopes->track_pos[1], 0.0f); diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index d6dcd0208f..3def3e3598 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -975,15 +975,13 @@ static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect), BLI_assert(!"invalid icon size"); return; } - /* modulate color */ - if (alpha != 1.0f) - glPixelTransferf(GL_ALPHA_SCALE, alpha); + float col[4] = {1.0f, 1.0f, 1.0f, alpha}; if (rgb) { - glPixelTransferf(GL_RED_SCALE, rgb[0]); - glPixelTransferf(GL_GREEN_SCALE, rgb[1]); - glPixelTransferf(GL_BLUE_SCALE, rgb[2]); + col[0] = rgb[0]; + col[1] = rgb[1]; + col[2] = rgb[2]; } /* rect contains image in 'rendersize', we only scale if needed */ @@ -1009,31 +1007,26 @@ static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect), } /* draw */ +#if 0 if (is_preview) { - glaDrawPixelsSafe(draw_x, draw_y, draw_w, draw_h, draw_w, GL_RGBA, GL_UNSIGNED_BYTE, rect); + immDrawPixelsTex(draw_x, draw_y, draw_w, draw_h, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, rect, +1.0f, 1.0f, col); } else { +#endif int bound_options; GPU_BASIC_SHADER_DISABLE_AND_STORE(bound_options); - glRasterPos2f(draw_x, draw_y); - glDrawPixels(draw_w, draw_h, GL_RGBA, GL_UNSIGNED_BYTE, rect)
[Bf-blender-cvs] [7b744f9e1a] blender2.8: Opengl glaDrawPixels removal: mask_draw.c
Commit: 7b744f9e1aac8960afab5b97c64a436e79c56f38 Author: Clément Foucault Date: Fri Feb 24 01:24:09 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB7b744f9e1aac8960afab5b97c64a436e79c56f38 Opengl glaDrawPixels removal: mask_draw.c === M source/blender/editors/mask/mask_draw.c === diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index b20862e763..f431efd80e 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -54,6 +54,7 @@ #include "GPU_immediate.h" #include "GPU_draw.h" +#include "GPU_shader.h" #include "UI_resources.h" #include "UI_view2d.h" @@ -753,17 +754,11 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar, if (draw_flag & MASK_DRAWFLAG_OVERLAY) { float *buffer = threaded_mask_rasterize(mask, width, height); - int format; - if (overlay_mode == MASK_OVERLAY_ALPHACHANNEL) { - glColor3f(1.0f, 1.0f, 1.0f); - format = GL_LUMINANCE; - } - else { + if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) { /* More blending types could be supported in the future. */ glEnable(GL_BLEND); - glBlendFunc(GL_DST_COLOR, GL_SRC_ALPHA); - format = GL_ALPHA; + glBlendFunc(GL_DST_COLOR, GL_ZERO); } glPushMatrix(); @@ -772,7 +767,12 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar, if (stabmat) { glMultMatrixf((const float *) stabmat); } - glaDrawPixelsTex(0.0f, 0.0f, width, height, format, GL_FLOAT, GL_NEAREST, buffer); + GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR); + GPU_shader_bind(shader); + float red[4] = {1.0f, 0.0f, 0.0f, 0.0f}; + GPU_shader_uniform_vector(shader, GPU_shader_get_uniform(shader, "shuffle"), 4, 1, red); + immDrawPixelsTex(0.0f, 0.0f, width, height, GL_RED, GL_FLOAT, GL_NEAREST, buffer, 1.0f, 1.0f, NULL); + GPU_shader_unbind(); glPopMatrix(); if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ab8958bbd5] blender2.8: Opengl glaDrawPixels removal: image_draw.c
Commit: ab8958bbd585997e5121d46f38ef3a35173bfe5f Author: Clément Foucault Date: Fri Feb 24 01:22:58 2017 +0100 Branches: blender2.8 https://developer.blender.org/rBab8958bbd585997e5121d46f38ef3a35173bfe5f Opengl glaDrawPixels removal: image_draw.c Using float buffer is still laggy because of the data volume we have to transfer to the GC. === M source/blender/editors/space_image/image_draw.c === diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 1f97bf6f25..00b2845798 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -71,6 +71,8 @@ #include "ED_render.h" #include "ED_screen.h" +#include "GPU_shader.h" + #include "UI_interface.h" #include "UI_resources.h" #include "UI_view2d.h" @@ -406,63 +408,36 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d } /* image drawing */ - -static void sima_draw_alpha_pixels(float x1, float y1, int rectx, int recty, unsigned int *recti) +static void sima_draw_zbuf_pixels(float x1, float y1, int rectx, int recty, int *rect, + float zoomx, float zoomy) { - - /* swap bytes, so alpha is most significant one, then just draw it as luminance int */ - if (ENDIAN_ORDER == B_ENDIAN) - glPixelStorei(GL_UNPACK_SWAP_BYTES, 1); + float red[4] = {1.0f, 0.0f, 0.0f, 0.0f}; - glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_LUMINANCE, GL_UNSIGNED_INT, recti); - glPixelStorei(GL_UNPACK_SWAP_BYTES, 0); -} + /* Slo */ + int *recti = MEM_mallocN(rectx * recty * sizeof(int), "temp"); + for (int a = rectx * recty - 1; a >= 0; a--) { + /* zbuffer values are signed, so we need to shift color range */ + recti[a] = rect[a] * 0.5f + 0.5f; + } -static void sima_draw_alpha_pixelsf(float x1, float y1, int rectx, int recty, float *rectf) -{ - float *trectf = MEM_mallocN(rectx * recty * 4, "temp"); - int a, b; - - for (a = rectx * recty - 1, b = 4 * a + 3; a >= 0; a--, b -= 4) - trectf[a] = rectf[b]; - - glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_LUMINANCE, GL_FLOAT, trectf); - MEM_freeN(trectf); - /* ogl trick below is slower... (on ATI 9600) */ -// glColorMask(1, 0, 0, 0); -// glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_RGBA, GL_FLOAT, rectf + 3); -// glColorMask(0, 1, 0, 0); -// glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_RGBA, GL_FLOAT, rectf + 2); -// glColorMask(0, 0, 1, 0); -// glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_RGBA, GL_FLOAT, rectf + 1); -// glColorMask(1, 1, 1, 1); -} + GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR); + GPU_shader_bind(shader); + GPU_shader_uniform_vector(shader, GPU_shader_get_uniform(shader, "shuffle"), 4, 1, red); -static void sima_draw_zbuf_pixels(float x1, float y1, int rectx, int recty, int *recti) -{ - /* zbuffer values are signed, so we need to shift color range */ - glPixelTransferf(GL_RED_SCALE, 0.5f); - glPixelTransferf(GL_GREEN_SCALE, 0.5f); - glPixelTransferf(GL_BLUE_SCALE, 0.5f); - glPixelTransferf(GL_RED_BIAS, 0.5f); - glPixelTransferf(GL_GREEN_BIAS, 0.5f); - glPixelTransferf(GL_BLUE_BIAS, 0.5f); - - glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_LUMINANCE, GL_INT, recti); - - glPixelTransferf(GL_RED_SCALE, 1.0f); - glPixelTransferf(GL_GREEN_SCALE, 1.0f); - glPixelTransferf(GL_BLUE_SCALE, 1.0f); - glPixelTransferf(GL_RED_BIAS, 0.0f); - glPixelTransferf(GL_GREEN_BIAS, 0.0f); - glPixelTransferf(GL_BLUE_BIAS, 0.0f); + immDrawPixelsTex(x1, y1, rectx, recty, GL_RED, GL_INT, GL_NEAREST, recti, zoomx, zoomy, NULL); + + GPU_shader_unbind(); + + MEM_freeN(recti); } -static void sima_draw_zbuffloat_pixels(Scene *scene, float x1, float y1, int rectx, int recty, float *rect_float) +static void sima_draw_zbuffloat_pixels(Scene *scene, float x1, float y1, int rectx, int recty, + float *rect_float, float zoomx, float zoomy) { float bias, scale, *rectf, clipend; int a; - + float red[4] = {1.0f, 0.0f, 0.0f, 0.0f}; + if (scene->camera && scene->camera->type == OB_CAMERA) { bias = ((Camera *)scene->camera->data)->clipsta; clipend = ((Camera *)scene->camera->data)->clipend; @@ -473,8 +448,8 @@ static void sima_draw_zbuffloat_pixels(Scene *scene, float x1, float y1, int re
[Bf-blender-cvs] [ccec97ea0a] blender2.8: Opengl glaDrawPixels removal: editors/spaces
Commit: ccec97ea0a43dc2c3befbabe26474a890ac7f26f Author: Clément Foucault Date: Fri Feb 24 01:20:30 2017 +0100 Branches: blender2.8 https://developer.blender.org/rBccec97ea0a43dc2c3befbabe26474a890ac7f26f Opengl glaDrawPixels removal: editors/spaces === M source/blender/editors/space_file/file_draw.c M source/blender/editors/space_node/drawnode.c M source/blender/editors/space_node/node_draw.c M source/blender/editors/space_view3d/view3d_draw_legacy.c === diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index dff32a5f0d..31326e2c18 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -341,6 +341,7 @@ static void file_draw_preview( float scale; int ex, ey; bool use_dropshadow = !is_icon && (typeflags & FILE_TYPE_IMAGE); + float col[4] = {1.0f, 1.0f, 1.0f, 1.0f}; BLI_assert(imb != NULL); @@ -387,12 +388,11 @@ static void file_draw_preview( /* the image */ if (!is_icon && typeflags & FILE_TYPE_FTFONT) { - UI_ThemeColor(TH_TEXT); + UI_GetThemeColor4fv(TH_TEXT, col); } - else { - glColor4f(1.0, 1.0, 1.0, 1.0); - } - glaDrawPixelsTexScaled((float)xco, (float)yco, imb->x, imb->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, imb->rect, scale, scale); + + immDrawPixelsTexScaled((float)xco, (float)yco, imb->x, imb->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, imb->rect, + scale, scale, 1.0f, 1.0f, col); if (icon) { UI_icon_draw_aspect((float)xco, (float)yco, icon, icon_aspect, 1.0f); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index be7e905786..ee93344cda 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -3178,6 +3178,7 @@ void ED_init_node_socket_type_virtual(bNodeSocketType *stype) void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeInstanceKey parent_key) { bNodeInstanceKey active_viewer_key = (snode->nodetree ? snode->nodetree->active_viewer_key : NODE_INSTANCE_KEY_NONE); + float shuffle[4] = {0.0f, 0.0f, 0.0f, 0.0f}; Image *ima; void *lock; ImBuf *ibuf; @@ -3210,43 +3211,27 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b unsigned char *display_buffer = NULL; void *cache_handle = NULL; - if (snode->flag & (SNODE_SHOW_R | SNODE_SHOW_G | SNODE_SHOW_B)) { - int ofs; + if (snode->flag & (SNODE_SHOW_R | SNODE_SHOW_G | SNODE_SHOW_B | SNODE_SHOW_ALPHA)) { display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, _handle); - -#ifdef __BIG_ENDIAN__ - if (snode->flag & SNODE_SHOW_R) ofs = 0; - else if (snode->flag & SNODE_SHOW_G) ofs = 1; - else ofs = 2; -#else - if (snode->flag & SNODE_SHOW_R) ofs = 1; - else if (snode->flag & SNODE_SHOW_G) ofs = 2; - else ofs = 3; -#endif - - glPixelZoom(snode->zoom, snode->zoom); - /* swap bytes, so alpha is most significant one, then just draw it as luminance int */ - - glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, - display_buffer - (4 - ofs)); - - glPixelZoom(1.0f, 1.0f); - } - else if (snode->flag & SNODE_SHOW_ALPHA) { - display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, _handle); - - glPixelZoom(snode->zoom, snode->zoom); - /* swap bytes, so alpha is most significant one, then just draw it as luminance int */ -#ifdef __BIG_ENDIAN__ - glPixelStorei(GL_UNPACK_SWAP_BYTES, 1); -#endif - glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UN
[Bf-blender-cvs] [1f453a8909] blender2.8: OpenColorIO: Update glsl implementation to be ready for ogl 3.3 core
Commit: 1f453a8909527a95fedd597b4fdaab90c18712f9 Author: Clément Foucault Date: Fri Feb 24 12:38:35 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB1f453a8909527a95fedd597b4fdaab90c18712f9 OpenColorIO: Update glsl implementation to be ready for ogl 3.3 core === M intern/opencolorio/CMakeLists.txt M intern/opencolorio/gpu_shader_display_transform.glsl A intern/opencolorio/gpu_shader_display_transform_vertex.glsl M intern/opencolorio/ocio_impl_glsl.cc M source/blender/gpu/shaders/gpu_shader_2D_image_vert.glsl === diff --git a/intern/opencolorio/CMakeLists.txt b/intern/opencolorio/CMakeLists.txt index 61a8d995f4..f7e8d909f2 100644 --- a/intern/opencolorio/CMakeLists.txt +++ b/intern/opencolorio/CMakeLists.txt @@ -66,6 +66,7 @@ if(WITH_OPENCOLORIO) endif() data_to_c_simple(gpu_shader_display_transform.glsl SRC) + data_to_c_simple(gpu_shader_display_transform_vertex.glsl SRC) endif() diff --git a/intern/opencolorio/gpu_shader_display_transform.glsl b/intern/opencolorio/gpu_shader_display_transform.glsl index 853bf57558..4a63405045 100644 --- a/intern/opencolorio/gpu_shader_display_transform.glsl +++ b/intern/opencolorio/gpu_shader_display_transform.glsl @@ -10,6 +10,15 @@ uniform float image_texture_width; uniform float image_texture_height; #endif +#if __VERSION__ < 130 + varying vec2 texCoord_interp; + #define fragColor gl_FragColor +#else + in vec2 texCoord_interp; + out vec4 fragColor; + #define texture2D texture +#endif + #ifdef USE_CURVE_MAPPING /* Curve mapping parameters * @@ -143,7 +152,7 @@ vec4 apply_dither(vec2 st, vec4 col) void main() { - vec4 col = texture2D(image_texture, gl_TexCoord[0].st); + vec4 col = texture2D(image_texture, texCoord_interp.st); #ifdef USE_CURVE_MAPPING col = curvemapping_evaluate_premulRGBF(col); #endif @@ -165,8 +174,8 @@ void main() vec4 result = OCIODisplay(col, lut3d_texture); #ifdef USE_DITHER - result = apply_dither(gl_TexCoord[0].st, result); + result = apply_dither(texCoord_interp.st, result); #endif - gl_FragColor = result; + fragColor = result; } diff --git a/source/blender/gpu/shaders/gpu_shader_2D_image_vert.glsl b/intern/opencolorio/gpu_shader_display_transform_vertex.glsl similarity index 100% copy from source/blender/gpu/shaders/gpu_shader_2D_image_vert.glsl copy to intern/opencolorio/gpu_shader_display_transform_vertex.glsl diff --git a/intern/opencolorio/ocio_impl_glsl.cc b/intern/opencolorio/ocio_impl_glsl.cc index bf91ea143d..9dba37f27e 100644 --- a/intern/opencolorio/ocio_impl_glsl.cc +++ b/intern/opencolorio/ocio_impl_glsl.cc @@ -58,6 +58,7 @@ using namespace OCIO_NAMESPACE; static const int LUT3D_EDGE_SIZE = 64; extern "C" char datatoc_gpu_shader_display_transform_glsl[]; +extern "C" char datatoc_gpu_shader_display_transform_vertex_glsl[]; /* OpenGL drawing routines using GLSL for color space transform * */ @@ -89,6 +90,7 @@ typedef struct OCIO_GLSLDrawState { /* GLSL stuff */ GLuint ocio_shader; + GLuint vert_shader; GLuint program; /* Previous OpenGL state. */ @@ -116,14 +118,15 @@ static GLuint compileShaderText(GLenum shaderType, const char *text) return shader; } -static GLuint linkShaders(GLuint ocio_shader) +static GLuint linkShaders(GLuint ocio_shader, GLuint vert_shader) { - if (!ocio_shader) + if (!ocio_shader || !vert_shader) return 0; GLuint program = glCreateProgram(); glAttachShader(program, ocio_shader); + glAttachShader(program, vert_shader); glLinkProgram(program); @@ -339,6 +342,25 @@ bool OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRc glDeleteShader(state->ocio_shader); } + if (state->vert_shader) { + glDeleteShader(state->vert_shader); + } + + /* Vertex shader */ + std::ostringstream osv; + + if (supportGLSL13()) { + osv << "#version 130\n"; + } + else { + osv << "#version 120\n"; + } + + osv << datatoc_gpu_shader_display_transform_vertex_glsl; + + state->vert_shader = compileShaderText(GL_VERTEX_SHADER, osv.str().c_str()); + + /* Fragment shader */ std::ostringstream os; if (supportGLSL13()) { @@ -366,8 +388,8 @@ bool OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRc state->ocio_shader = compileShaderText(GL_FRAGMENT_SHADER, os.str().c_str()); - if
[Bf-blender-cvs] [1e7475a5d7] blender2.8: Opengl glaDrawPixels removal: More descriptive setup.
Commit: 1e7475a5d7878642057ea0cb313b5ee0d4a8545e Author: Clément Foucault Date: Fri Feb 24 11:11:43 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB1e7475a5d7878642057ea0cb313b5ee0d4a8545e Opengl glaDrawPixels removal: More descriptive setup. === M source/blender/editors/include/BIF_glutil.h M source/blender/editors/interface/interface_draw.c M source/blender/editors/interface/interface_icons.c M source/blender/editors/mask/mask_draw.c M source/blender/editors/render/render_internal.c M source/blender/editors/render/render_preview.c M source/blender/editors/screen/glutil.c M source/blender/editors/space_file/file_draw.c M source/blender/editors/space_image/image_draw.c M source/blender/editors/space_node/drawnode.c M source/blender/editors/space_node/node_draw.c M source/blender/editors/space_view3d/view3d_draw_legacy.c M source/blender/windowmanager/intern/wm_dragdrop.c M source/blender/windowmanager/intern/wm_gesture.c === diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h index a3161b49d4..0b85517f33 100644 --- a/source/blender/editors/include/BIF_glutil.h +++ b/source/blender/editors/include/BIF_glutil.h @@ -210,6 +210,12 @@ void glaDrawPixelsTex(float x, float y, int img_w, int img_h, int format, int ty void glaDrawPixelsTex_clipping(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect, float clip_min_x, float clip_min_y, float clip_max_x, float clip_max_y); #endif + +/* To be used before calling immDrawPixelsTex + * Default shader is GPU_SHADER_2D_IMAGE_COLOR + * Returns a shader to be able to set uniforms */ +struct GPUShader *immDrawPixelsTexSetup(int builtin); + /** * immDrawPixelsTex - Functions like a limited glDrawPixels, but actually draws the * image using textures, which can be tremendously faster on low-end @@ -217,6 +223,8 @@ void glaDrawPixelsTex_clipping(float x, float y, int img_w, int img_h, int forma * clipped when offscreen. Pixel unpacking parameters and * the glPixelZoom values are _not_ respected. * + * \attention Use immDrawPixelsTexSetup before calling this function. + * * \attention This routine makes many assumptions: the rect data * is expected to be in RGBA byte or float format, and the * modelview and projection matrices are assumed to define a diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index b48eb4d79d..64f7b1adc3 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -501,6 +501,7 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w facy = (float)h / (float)ibuf->y; } + immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR); immDrawPixelsTex((float)rect->xmin, (float)rect->ymin, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, ibuf->rect, facx, facy, NULL); @@ -1735,7 +1736,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc UI_draw_roundbox_gl_mode(GL_TRIANGLE_FAN, rect.xmin - 1, rect.ymin, rect.xmax + 1, rect.ymax + 1, 3.0f, color); } - GPU_shader_unbind(); /* make sure there is no program bound */ + immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR); immDrawPixelsTex(rect.xmin, rect.ymin + 1, drawibuf->x, drawibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, drawibuf->rect, 1.0f, 1.0f, NULL); /* draw cross for pixel position */ diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 3def3e3598..ef394899ac 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -1009,6 +1009,7 @@ static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect), /* draw */ #if 0 if (is_preview) { + immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR); immDrawPixelsTex(draw_x, draw_y, draw_w, draw_h, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, rect, 1.0f, 1.0f, col); } @@ -1017,6 +1018,7 @@ static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect), int bound_options; GPU_BASIC_SHADER_DISABLE_AND_STORE(bound_options); + immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR); immDrawPixelsTex(draw_x, draw_y, draw_w, draw_h, GL_RGBA, GL_UNSI
[Bf-blender-cvs] [50fb3ea3de] blender2.8: Clay Engine: Separate mode drawing to different files/engines.
Commit: 50fb3ea3de8db278fd135392b990158b745e3e3f Author: Clément Foucault Date: Fri Feb 17 17:29:43 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB50fb3ea3de8db278fd135392b990158b745e3e3f Clay Engine: Separate mode drawing to different files/engines. === M source/blender/draw/CMakeLists.txt M source/blender/draw/engines/clay/clay.c M source/blender/draw/intern/DRW_render.h M source/blender/draw/intern/draw_manager.c M source/blender/draw/intern/draw_mode_pass.c M source/blender/draw/intern/draw_mode_pass.h A source/blender/draw/modes/edit_mode.c A source/blender/draw/modes/edit_mode.h A source/blender/draw/modes/object_mode.c A source/blender/draw/modes/object_mode.h M source/blender/editors/space_view3d/view3d_draw.c M source/blender/gpu/GPU_viewport.h M source/blender/gpu/intern/gpu_viewport.c === diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 006fb0fbc2..be517d799a 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -27,6 +27,7 @@ set(INC . intern engines/clay + modes/ ../blenkernel ../blenlib @@ -55,12 +56,16 @@ set(SRC intern/draw_cache.c intern/draw_view.c engines/clay/clay.c + modes/edit_mode.c + modes/object_mode.c intern/DRW_render.h intern/draw_mode_pass.h intern/draw_cache.h intern/draw_view.h engines/clay/clay.h + modes/edit_mode.h + modes/object_mode.h ./DRW_engine.h ) diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c index 1673dd219c..f121eb8600 100644 --- a/source/blender/draw/engines/clay/clay.c +++ b/source/blender/draw/engines/clay/clay.c @@ -126,17 +126,9 @@ enum { /* keep it under MAX_PASSES */ typedef struct CLAY_PassList{ - /* default */ - struct DRWPass *non_meshes_pass; - struct DRWPass *ob_center_pass; - /* engine specific */ struct DRWPass *depth_pass; struct DRWPass *depth_pass_cull; - struct DRWPass *depth_pass_hidden_wire; struct DRWPass *clay_pass; - struct DRWPass *wire_overlay_pass; - struct DRWPass *wire_outline_pass; - struct DRWPass *wire_outline_pass_hidden_wire; } CLAY_PassList; //#define GTAO @@ -286,8 +278,12 @@ MaterialEngineSettings *CLAY_material_settings_create(void) return (MaterialEngineSettings *)settings; } -static void CLAY_engine_init(CLAY_StorageList *stl, CLAY_TextureList *txl, CLAY_FramebufferList *fbl) +static void CLAY_engine_init(void) { + CLAY_StorageList *stl = DRW_engine_storage_list_get(); + CLAY_TextureList *txl = DRW_engine_texture_list_get(); + CLAY_FramebufferList *fbl = DRW_engine_framebuffer_list_get(); + /* Create Texture Array */ if (!data.matcap_array) { PreviewImage *prv[24]; /* For now use all of the 24 internal matcaps */ @@ -384,56 +380,56 @@ static void CLAY_engine_init(CLAY_StorageList *stl, CLAY_TextureList *txl, CLAY_ (int)viewport_size[0], (int)viewport_size[1], , 1); } -} -static void CLAY_ssao_setup(void) -{ - float invproj[4][4]; - float dfdyfacs[2]; - bool is_persp = DRW_viewport_is_persp_get(); - /* view vectors for the corners of the view frustum. Can be used to recreate the world space position easily */ - float viewvecs[3][4] = { - {-1.0f, -1.0f, -1.0f, 1.0f}, - {1.0f, -1.0f, -1.0f, 1.0f}, - {-1.0f, 1.0f, -1.0f, 1.0f} - }; - int i; - float *size = DRW_viewport_size_get(); - RenderEngineSettingsClay *settings = DRW_render_settings_get(NULL, RE_engine_id_BLENDER_CLAY); - - DRW_get_dfdy_factors(dfdyfacs); - - data.ssao_params[0] = settings->ssao_samples; - data.ssao_params[1] = size[0] / 64.0; - data.ssao_params[2] = size[1] / 64.0; - data.ssao_params[3] = dfdyfacs[1]; /* dfdy sign for offscreen */ - - /* invert the view matrix */ - DRW_viewport_matrix_get(data.winmat, DRW_MAT_WIN); - invert_m4_m4(invproj, data.winmat); - - /* convert the view vectors to view space */ - for (i = 0; i < 3; i++) { - mul_m4_v4(invproj, viewvecs[i]); - /* normalized trick see http://www.derschmale.com/2014/01/26/reconstructing-positions-from-the-depth-buffer */ - mul_v3_fl(viewvecs[i], 1.0f / viewvecs[i][3]); - if (is_persp) - mul_v3_fl(viewvecs[i], 1.0f / viewvecs[i][2]); - viewvecs[i][3] = 1.0; - - copy_v4_v4(data.viewvecs[i], viewvecs[i]); - } + /
[Bf-blender-cvs] [efc499cb99] blender2.8: OpenGL immediate mode: paint_stroke.c
Commit: efc499cb991f1a432632d7c3a38070d36a3168b4 Author: Clément Foucault Date: Wed Feb 22 18:19:42 2017 +0100 Branches: blender2.8 https://developer.blender.org/rBefc499cb991f1a432632d7c3a38070d36a3168b4 OpenGL immediate mode: paint_stroke.c === M source/blender/editors/sculpt_paint/paint_stroke.c === diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 05270dbfa0..38827b16e3 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -58,7 +58,7 @@ #include "BIF_gl.h" #include "BIF_glutil.h" -#include "GPU_basic_shader.h" +#include "GPU_immediate.h" #include "ED_screen.h" #include "ED_view3d.h" @@ -145,9 +145,17 @@ static void paint_draw_smooth_cursor(bContext *C, int x, int y, void *customdata if (stroke && brush) { glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); - glColor4ubv(paint->paint_cursor_col); - sdrawline(x, y, (int)stroke->last_mouse_position[0], - (int)stroke->last_mouse_position[1]); + + unsigned int pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, KEEP_FLOAT); + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + immUniformColor4ubv(paint->paint_cursor_col); + + immBegin(GL_LINES, 2); + imm_draw_line(pos, x, y, stroke->last_mouse_position[0], + stroke->last_mouse_position[1]); + immEnd(); + immUnbindProgram(); + glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); } @@ -161,32 +169,35 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata) glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); - GPU_basic_shader_bind_enable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE); - GPU_basic_shader_line_stipple(3, 0x); - GPU_basic_shader_line_width(3.0); + setlinestyle(3); + glLineWidth(3.0f); - glColor4ub(0, 0, 0, paint->paint_cursor_col[3]); + unsigned int pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, KEEP_FLOAT); + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + + immUniformColor4ub(0, 0, 0, paint->paint_cursor_col[3]); if (stroke->constrain_line) { - sdrawline((int)stroke->last_mouse_position[0], (int)stroke->last_mouse_position[1], + imm_draw_line(pos, stroke->last_mouse_position[0], stroke->last_mouse_position[1], stroke->constrained_pos[0], stroke->constrained_pos[1]); } else { - sdrawline((int)stroke->last_mouse_position[0], (int)stroke->last_mouse_position[1], + imm_draw_line(pos, stroke->last_mouse_position[0], stroke->last_mouse_position[1], x, y); } - glColor4ub(255, 255, 255, paint->paint_cursor_col[3]); - GPU_basic_shader_line_width(1.0); + glLineWidth(1.0f); + immUniformColor4ub(255, 255, 255, paint->paint_cursor_col[3]); if (stroke->constrain_line) { - sdrawline((int)stroke->last_mouse_position[0], (int)stroke->last_mouse_position[1], + imm_draw_line(pos, stroke->last_mouse_position[0], stroke->last_mouse_position[1], stroke->constrained_pos[0], stroke->constrained_pos[1]); } else { - sdrawline((int)stroke->last_mouse_position[0], (int)stroke->last_mouse_position[1], + imm_draw_line(pos, stroke->last_mouse_position[0], stroke->last_mouse_position[1], x, y); } + immUnbindProgram(); - GPU_basic_shader_bind_disable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE); + setlinestyle(0); glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [eb473143a8] blender2.8: Clay Engine: Convert Lamp to use new instancing feature.
Commit: eb473143a8cf26260bd165cb63e043ae9da7a216 Author: Clément Foucault Date: Thu Feb 9 18:33:50 2017 +0100 Branches: blender2.8 https://developer.blender.org/rBeb473143a8cf26260bd165cb63e043ae9da7a216 Clay Engine: Convert Lamp to use new instancing feature. === M source/blender/draw/intern/draw_mode_pass.c M source/blender/gpu/intern/gpu_shader.c M source/blender/gpu/shaders/gpu_shader_3D_lamp_vert.glsl === diff --git a/source/blender/draw/intern/draw_mode_pass.c b/source/blender/draw/intern/draw_mode_pass.c index 4a9a340cf1..53ee769c04 100644 --- a/source/blender/draw/intern/draw_mode_pass.c +++ b/source/blender/draw/intern/draw_mode_pass.c @@ -100,23 +100,8 @@ static DRWShadingGroup *lamp_center_group; static DRWShadingGroup *lamp_groundpoint; static DRWShadingGroup *lamp_groundline; static DRWShadingGroup *lamp_circle; -static DRWShadingGroup *lamp_circle_active; -static DRWShadingGroup *lamp_circle_select; -static DRWShadingGroup *lamp_circle_transform; -static DRWShadingGroup *lamp_circle_group; -static DRWShadingGroup *lamp_circle_group_active; static DRWShadingGroup *lamp_circle_shadow; -static DRWShadingGroup *lamp_circle_shadow_active; -static DRWShadingGroup *lamp_circle_shadow_select; -static DRWShadingGroup *lamp_circle_shadow_transform; -static DRWShadingGroup *lamp_circle_shadow_group; -static DRWShadingGroup *lamp_circle_shadow_group_active; static DRWShadingGroup *lamp_sunrays; -static DRWShadingGroup *lamp_sunrays_active; -static DRWShadingGroup *lamp_sunrays_select; -static DRWShadingGroup *lamp_sunrays_transform; -static DRWShadingGroup *lamp_sunrays_group; -static DRWShadingGroup *lamp_sunrays_group_active; /* Helpers */ static DRWShadingGroup *relationship_lines; @@ -186,13 +171,13 @@ static DRWShadingGroup *shgroup_groundpoints_uniform_color(DRWPass *pass, float return grp; } -static DRWShadingGroup *shgroup_lamp(DRWPass *pass, struct Batch *geom, float color[4], float *size) +static DRWShadingGroup *shgroup_lamp(DRWPass *pass, struct Batch *geom, float *size) { GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_LAMP_COMMON); DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom); - DRW_shgroup_attrib_float(grp, "InstanceModelMatrix", 16); - DRW_shgroup_uniform_vec4(grp, "color", color, 1); + DRW_shgroup_attrib_float(grp, "lamp_pos", 3); + DRW_shgroup_attrib_float(grp, "color", 3); DRW_shgroup_uniform_float(grp, "size", size, 1); DRW_shgroup_uniform_float(grp, "pixel_size", DRW_viewport_pixelsize_get(), 1); DRW_shgroup_uniform_vec3(grp, "screen_vecs", DRW_viewport_screenvecs_get(), 2); @@ -324,26 +309,11 @@ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPa lamp_center_group = shgroup_dynpoints_uniform_color(*non_meshes, colorGroup, ); geom = DRW_cache_lamp_get(); - lamp_circle = shgroup_lamp(*non_meshes, geom, colorLampNoAlpha, ); - lamp_circle_active = shgroup_lamp(*non_meshes, geom, colorActive, ); - lamp_circle_select = shgroup_lamp(*non_meshes, geom, colorSelect, ); - lamp_circle_transform = shgroup_lamp(*non_meshes, geom, colorTransform, ); - lamp_circle_group = shgroup_lamp(*non_meshes, geom, colorGroup, ); - lamp_circle_group_active = shgroup_lamp(*non_meshes, geom, colorGroupActive, ); - lamp_circle_shadow = shgroup_lamp(*non_meshes, geom, colorLampNoAlpha, ); - lamp_circle_shadow_active = shgroup_lamp(*non_meshes, geom, colorActive, ); - lamp_circle_shadow_select = shgroup_lamp(*non_meshes, geom, colorSelect, ); - lamp_circle_shadow_transform = shgroup_lamp(*non_meshes, geom, colorTransform, ); - lamp_circle_shadow_group = shgroup_lamp(*non_meshes, geom, colorGroup, ); - lamp_circle_shadow_group_active = shgroup_lamp(*non_meshes, geom, colorGroupActive, ); + lamp_circle = shgroup_lamp(*non_meshes, geom, ); + lamp_circle_shadow = shgroup_lamp(*non_meshes, geom, ); geom = DRW_cache_lamp_sunrays_get(); - lamp_sunrays = shgroup_lamp(*non_meshes, geom, colorLampNoAlpha, ); - lamp_sunrays_active = shgroup_lamp(*non_meshes, geom, colorActive, ); - lamp_sunrays_select = shgroup_lamp(*non_meshes, geom, colorSelect, ); - lamp_sunrays_transform = shgroup_lamp(*non_meshes, geom, colorTransform, ); - lamp_sunrays_group = shgroup_lamp(*non_meshes, geom, colorGroup, ); - lamp_sunrays_group_active = shgroup_lamp(*non_meshes, geom, colorGroupAc
[Bf-blender-cvs] [e05800d23b] blender2.8: Clay Engine: converted Empties to the new instancing method
Commit: e05800d23b40a6eda0b154de934f8f8c6e1b3438 Author: Clément Foucault Date: Thu Feb 9 20:55:31 2017 +0100 Branches: blender2.8 https://developer.blender.org/rBe05800d23b40a6eda0b154de934f8f8c6e1b3438 Clay Engine: converted Empties to the new instancing method === M source/blender/draw/intern/draw_mode_pass.c M source/blender/gpu/CMakeLists.txt M source/blender/gpu/GPU_shader.h M source/blender/gpu/intern/gpu_shader.c A source/blender/gpu/shaders/gpu_shader_instance_variying_size_variying_color_vert.glsl R100source/blender/gpu/shaders/gpu_shader_3D_instance_vert.glsl source/blender/gpu/shaders/gpu_shader_instance_vert.glsl === diff --git a/source/blender/draw/intern/draw_mode_pass.c b/source/blender/draw/intern/draw_mode_pass.c index 53ee769c04..a5b2d0a09c 100644 --- a/source/blender/draw/intern/draw_mode_pass.c +++ b/source/blender/draw/intern/draw_mode_pass.c @@ -38,61 +38,14 @@ /* Store list of shading group for easy access*/ /* Empties */ -static DRWShadingGroup *plain_axes_wire; -static DRWShadingGroup *plain_axes_active; -static DRWShadingGroup *plain_axes_select; -static DRWShadingGroup *plain_axes_transform; -static DRWShadingGroup *plain_axes_group; -static DRWShadingGroup *plain_axes_group_active; - -static DRWShadingGroup *cube_wire; -static DRWShadingGroup *cube_active; -static DRWShadingGroup *cube_select; -static DRWShadingGroup *cube_transform; -static DRWShadingGroup *cube_group; -static DRWShadingGroup *cube_group_active; - -static DRWShadingGroup *circle_wire; -static DRWShadingGroup *circle_active; -static DRWShadingGroup *circle_select; -static DRWShadingGroup *circle_transform; -static DRWShadingGroup *circle_group; -static DRWShadingGroup *circle_group_active; - -static DRWShadingGroup *sphere_wire; -static DRWShadingGroup *sphere_active; -static DRWShadingGroup *sphere_select; -static DRWShadingGroup *sphere_transform; -static DRWShadingGroup *sphere_group; -static DRWShadingGroup *sphere_group_active; - -static DRWShadingGroup *cone_wire; -static DRWShadingGroup *cone_active; -static DRWShadingGroup *cone_select; -static DRWShadingGroup *cone_transform; -static DRWShadingGroup *cone_group; -static DRWShadingGroup *cone_group_active; - -static DRWShadingGroup *single_arrow_wire; -static DRWShadingGroup *single_arrow_active; -static DRWShadingGroup *single_arrow_select; -static DRWShadingGroup *single_arrow_transform; -static DRWShadingGroup *single_arrow_group; -static DRWShadingGroup *single_arrow_group_active; - -static DRWShadingGroup *single_arrow_line_wire; -static DRWShadingGroup *single_arrow_line_active; -static DRWShadingGroup *single_arrow_line_select; -static DRWShadingGroup *single_arrow_line_transform; -static DRWShadingGroup *single_arrow_line_group; -static DRWShadingGroup *single_arrow_line_group_active; - -static DRWShadingGroup *arrows_wire; -static DRWShadingGroup *arrows_active; -static DRWShadingGroup *arrows_select; -static DRWShadingGroup *arrows_transform; -static DRWShadingGroup *arrows_group; -static DRWShadingGroup *arrows_group_active; +static DRWShadingGroup *plain_axes; +static DRWShadingGroup *cube; +static DRWShadingGroup *circle; +static DRWShadingGroup *sphere; +static DRWShadingGroup *cone; +static DRWShadingGroup *single_arrow; +static DRWShadingGroup *single_arrow_line; +static DRWShadingGroup *arrows; /* Lamps */ static DRWShadingGroup *lamp_center; @@ -117,17 +70,6 @@ static float colorActive[4], colorSelect[4], colorTransform[4], colorGroup[4], c static float colorEmpty[4], colorLamp[4], colorCamera[4], colorSpeaker[4]; static float lampCenterSize, lampCircleRad, lampCircleShadowRad, colorLampNoAlpha[4]; -static DRWShadingGroup *shgroup_instance_uniform_color(DRWPass *pass, struct Batch *geom, float color[4]) -{ - GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR_INSTANCE); - - DRWShadingGroup *grp = DRW_shgroup_instance_create(sh_inst, pass, geom); - DRW_shgroup_attrib_float(grp, "InstanceModelMatrix", 16); - DRW_shgroup_uniform_vec4(grp, "color", color, 1); - - return grp; -} - static DRWShadingGroup *shgroup_dynlines_uniform_color(DRWPass *pass, float color[4]) { GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR); @@ -186,6 +128,18 @@ static DRWShadingGroup *shgroup_lamp(DRWPass *pass, struct Batch *geom, float *s return grp; } +static DRWShadingGroup *shgroup_empty(DRWPass *pass, struct Batch *geom) +{ + GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE); + + DRWShadingGroup *grp = DRW_shgroup_instance_create(sh_inst, pass, geom); + DRW_shgroup_attrib_float(grp, "color", 3); + DRW_shgroup_attrib_float(grp, "size",
[Bf-blender-cvs] [fc0797142d] blender2.8: Clay Engine: Refactoring of the dynamic batches
Commit: fc0797142d0c94342832bbead9db40e3e6ca9186 Author: Clément Foucault Date: Thu Feb 9 17:26:13 2017 +0100 Branches: blender2.8 https://developer.blender.org/rBfc0797142d0c94342832bbead9db40e3e6ca9186 Clay Engine: Refactoring of the dynamic batches Support more attribs for interesting instancing === M source/blender/draw/intern/DRW_render.h M source/blender/draw/intern/draw_manager.c M source/blender/draw/intern/draw_mode_pass.c M source/blender/gpu/gawain/batch.c M source/blender/gpu/gawain/batch.h === diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 2cd0634168..78edae803b 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -158,16 +158,17 @@ typedef enum { DRW_STATE_BLEND = (1 << 12), } DRWState; -/* Used by DRWShadingGroup.dyntype */ -#define DRW_DYN_POINTS 1 -#define DRW_DYN_LINES 2 -#define DRW_DYN_INSTANCE 3 - DRWShadingGroup *DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass); +DRWShadingGroup *DRW_shgroup_instance_create(struct GPUShader *shader, DRWPass *pass, struct Batch *geom); +DRWShadingGroup *DRW_shgroup_point_batch_create(struct GPUShader *shader, DRWPass *pass); +DRWShadingGroup *DRW_shgroup_line_batch_create(struct GPUShader *shader, DRWPass *pass); + void DRW_shgroup_free(struct DRWShadingGroup *shgroup); void DRW_shgroup_call_add(DRWShadingGroup *shgroup, struct Batch *geom, float (*obmat)[4]); +void DRW_shgroup_dynamic_call_add(DRWShadingGroup *shgroup, ...); void DRW_shgroup_state_set(DRWShadingGroup *shgroup, DRWState state); -void DRW_shgroup_dyntype_set(DRWShadingGroup *shgroup, int type); +void DRW_shgroup_attrib_int(DRWShadingGroup *shgroup, const char *name, int size); +void DRW_shgroup_attrib_float(DRWShadingGroup *shgroup, const char *name, int size); void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, const struct GPUTexture *tex, int loc); void DRW_shgroup_uniform_block(DRWShadingGroup *shgroup, const char *name, const struct GPUUniformBuffer *ubo, int loc); @@ -185,7 +186,6 @@ void DRW_shgroup_uniform_mat4(DRWShadingGroup *shgroup, const char *name, const /* Passes */ DRWPass *DRW_pass_create(const char *name, DRWState state); -DRWShadingGroup *DRW_pass_nth_shgroup_get(DRWPass *pass, int n); /* Viewport */ typedef enum { diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 983f22bad5..55ef8359e2 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -58,6 +58,8 @@ #include "clay.h" +#define MAX_ATTRIB_NAME 32 + extern char datatoc_gpu_shader_2D_vert_glsl[]; extern char datatoc_gpu_shader_3D_vert_glsl[]; extern char datatoc_gpu_shader_basic_vert_glsl[]; @@ -74,7 +76,12 @@ typedef enum { DRW_UNIFORM_BLOCK } DRWUniformType; -struct DRWUniform { +typedef enum { + DRW_ATTRIB_INT, + DRW_ATTRIB_FLOAT, +} DRWAttribType; + +typedef struct DRWUniform { struct DRWUniform *next, *prev; DRWUniformType type; int location; @@ -82,10 +89,24 @@ struct DRWUniform { int arraysize; int bindloc; const void *value; -}; +} DRWUniform; + +typedef struct DRWAttrib { + struct DRWAttrib *next, *prev; + char name[MAX_ATTRIB_NAME]; + int location; + int format_id; + int size; /* number of component */ + int type; +} DRWAttrib; struct DRWInterface { - ListBase uniforms; + ListBase uniforms; /* DRWUniform */ + ListBase attribs;/* DRWAttrib */ + int attribs_count; + int attribs_stride; + int attribs_size[16]; + int attribs_loc[16]; /* matrices locations */ int modelview; int projection; @@ -93,10 +114,14 @@ struct DRWInterface { int viewprojection; int normal; int eye; + /* Dynamic batch */ + GLuint instance_vbo; + int instance_count; + VertexFormat vbo_format; }; struct DRWPass { - ListBase shgroups; + ListBase shgroups; /* DRWShadingGroup */ DRWState state; float state_param; /* Line / Point width */ }; @@ -104,19 +129,33 @@ struct DRWPass { typedef struct DRWCall { struct DRWCall *next, *prev; Batch *geometry; - float(*obmat)[4]; + float (*obmat)[4]; } DRWCall; +typedef struct DRWDynamicCall { + struct DRWDynamicCall *next, *prev; + const void *data[]; +} DRWDynamicCall; + struct DRWShadingGroup { struct DRWShadingGroup *next, *prev; + struct GPUShader *shader;/* Shader to bind */ struct DRWInterface *interface; /* Uniforms pointers */ - ListBase calls; /* List w
[Bf-blender-cvs] [1abd2f279d] blender2.8: Clay Engine: Small instancing fixes
Commit: 1abd2f279dfe87c2d1d648b9780f25697a9b2c52 Author: Clément Foucault Date: Thu Feb 9 20:54:37 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB1abd2f279dfe87c2d1d648b9780f25697a9b2c52 Clay Engine: Small instancing fixes === M source/blender/draw/intern/draw_manager.c === diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 55ef8359e2..0cfe75c311 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -623,6 +623,7 @@ static void shgroup_dynamic_instance(DRWShadingGroup *shgroup) int offset = 0; DRWInterface *interface = shgroup->interface; int vert_nbr = interface->instance_count; + int buffer_size = 0; if (vert_nbr == 0) { if (interface->instance_vbo) { @@ -635,6 +636,7 @@ static void shgroup_dynamic_instance(DRWShadingGroup *shgroup) /* only once */ if (interface->attribs_stride == 0) { for (DRWAttrib *attrib = interface->attribs.first; attrib; attrib = attrib->next, i++) { + BLI_assert(attrib->type == DRW_ATTRIB_FLOAT); /* Only float for now */ interface->attribs_stride += attrib->size; interface->attribs_size[i] = attrib->size; interface->attribs_loc[i] = attrib->location; @@ -642,15 +644,13 @@ static void shgroup_dynamic_instance(DRWShadingGroup *shgroup) } /* Gather Data */ - float *data = MEM_mallocN(sizeof(float) * interface->attribs_stride * vert_nbr , "Instance VBO data"); + buffer_size = sizeof(float) * interface->attribs_stride * vert_nbr; + float *data = MEM_mallocN(buffer_size, "Instance VBO data"); - i = 0; - for (DRWDynamicCall *call = shgroup->calls.first; call; call = call->next, i++) { - int j = 0; - for (DRWAttrib *attrib = interface->attribs.first; attrib; attrib = attrib->next, j++) { - BLI_assert(attrib->type == DRW_ATTRIB_FLOAT); /* Only float for now */ - memcpy(data + offset, call->data[j], sizeof(float) * attrib->size); - offset += attrib->size; + for (DRWDynamicCall *call = shgroup->calls.first; call; call = call->next) { + for (int j = 0; j < interface->attribs_count; ++j) { + memcpy(data + offset, call->data[j], sizeof(float) * interface->attribs_size[j]); + offset += interface->attribs_size[j]; } } @@ -662,7 +662,7 @@ static void shgroup_dynamic_instance(DRWShadingGroup *shgroup) glGenBuffers(1, >instance_vbo); glBindBuffer(GL_ARRAY_BUFFER, interface->instance_vbo); - glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 4 * 4 * vert_nbr, data, GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, buffer_size, data, GL_STATIC_DRAW); MEM_freeN(data); } @@ -785,10 +785,10 @@ typedef struct DRWBoundTexture { GPUTexture *tex; } DRWBoundTexture; -static void draw_geometry(DRWShadingGroup *shgroup, DRWInterface *interface, Batch *geom, - unsigned int instance_vbo, int instance_count, const float (*obmat)[4]) +static void draw_geometry(DRWShadingGroup *shgroup, Batch *geom, const float (*obmat)[4]) { RegionView3D *rv3d = CTX_wm_region_view3d(DST.context); + DRWInterface *interface = shgroup->interface; float mvp[4][4], mv[4][4], n[3][3]; float eye[3] = { 0.0f, 0.0f, 1.0f }; /* looking into the screen */ @@ -840,8 +840,8 @@ static void draw_geometry(DRWShadingGroup *shgroup, DRWInterface *interface, Bat /* step 2 : bind vertex array & draw */ Batch_set_program(geom, GPU_shader_get_program(shgroup->shader)); - if (instance_vbo) { - Batch_draw_stupid_instanced(geom, instance_vbo, instance_count, interface->attribs_count, + if (interface->instance_vbo) { + Batch_draw_stupid_instanced(geom, interface->instance_vbo, interface->instance_count, interface->attribs_count, interface->attribs_stride, interface->attribs_size, interface->attribs_loc); } else { @@ -918,18 +918,18 @@ static void draw_shgroup(DRWShadingGroup *shgroup) unit_m4(obmat); if (shgroup->type == DRW_SHG_INSTANCE && interface->instance_count > 0) { - draw_geometry(shgroup, interface, shgroup->instance_geom, interface->instance_vbo, interface->instance_count, obmat); +
[Bf-blender-cvs] [1976fd7af1] blender2.8: Clay Engine: Fix instance attrib.
Commit: 1976fd7af18bd784fadccc1ba4abbf7be878689d Author: Clément Foucault Date: Thu Feb 9 18:33:12 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB1976fd7af18bd784fadccc1ba4abbf7be878689d Clay Engine: Fix instance attrib. === M source/blender/gpu/gawain/batch.c === diff --git a/source/blender/gpu/gawain/batch.c b/source/blender/gpu/gawain/batch.c index 6beddaca6c..55ccd94a55 100644 --- a/source/blender/gpu/gawain/batch.c +++ b/source/blender/gpu/gawain/batch.c @@ -314,9 +314,9 @@ void Batch_draw_stupid_instanced(Batch* batch, unsigned int instance_vbo, int in glVertexAttribPointer(loc + atr_ofs, (size > 4) ? 4 : size, GL_FLOAT, GL_FALSE, sizeof(float) * attrib_stride, (GLvoid*)(sizeof(float) * ptr_ofs)); glVertexAttribDivisor(loc + atr_ofs, 1); - size -= 4; atr_ofs++; ptr_ofs += (size > 4) ? 4 : size; + size -= 4; } } glBindBuffer(GL_ARRAY_BUFFER, 0); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [737d349dbc] blender2.8: Clay Engine: fix instancing (again)
Commit: 737d349dbce972459df5db03bf861c28604c3826 Author: Clément Foucault Date: Thu Feb 9 23:57:54 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB737d349dbce972459df5db03bf861c28604c3826 Clay Engine: fix instancing (again) === M source/blender/draw/intern/draw_manager.c === diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 0cfe75c311..970bd2f6de 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -334,6 +334,7 @@ static DRWInterface *DRW_interface_create(GPUShader *shader) interface->instance_count = 0; interface->attribs_count = 0; interface->attribs_stride = 0; + interface->instance_vbo = 0; memset(>vbo_format, 0, sizeof(VertexFormat)); @@ -577,7 +578,6 @@ void DRW_shgroup_uniform_mat4(DRWShadingGroup *shgroup, const char *name, const /* Creates a VBO containing OGL primitives for all DRWDynamicCall */ static void shgroup_dynamic_batch(DRWShadingGroup *shgroup) { - int i = 0; DRWInterface *interface = shgroup->interface; int nbr = interface->instance_count; @@ -587,25 +587,28 @@ static void shgroup_dynamic_batch(DRWShadingGroup *shgroup) return; /* Upload Data */ - for (DRWAttrib *attrib = interface->attribs.first; attrib; attrib = attrib->next) { - BLI_assert(attrib->size <= 4); /* matrices have no place here for now */ - if (attrib->type == DRW_ATTRIB_FLOAT) { - attrib->format_id = add_attrib(>vbo_format, attrib->name, GL_FLOAT, attrib->size, KEEP_FLOAT); - } - else if (attrib->type == DRW_ATTRIB_INT) { - attrib->format_id = add_attrib(>vbo_format, attrib->name, GL_BYTE, attrib->size, KEEP_INT); - } - else { - BLI_assert(false); + if (interface->vbo_format.attrib_ct == 0) { + for (DRWAttrib *attrib = interface->attribs.first; attrib; attrib = attrib->next) { + BLI_assert(attrib->size <= 4); /* matrices have no place here for now */ + if (attrib->type == DRW_ATTRIB_FLOAT) { + attrib->format_id = add_attrib(>vbo_format, attrib->name, GL_FLOAT, attrib->size, KEEP_FLOAT); + } + else if (attrib->type == DRW_ATTRIB_INT) { + attrib->format_id = add_attrib(>vbo_format, attrib->name, GL_BYTE, attrib->size, KEEP_INT); + } + else { + BLI_assert(false); + } } } VertexBuffer *vbo = VertexBuffer_create_with_format(>vbo_format); VertexBuffer_allocate_data(vbo, nbr); - for (DRWAttrib *attrib = interface->attribs.first; attrib; attrib = attrib->next, i++) { - int j = 0; - for (DRWDynamicCall *call = shgroup->calls.first; call; call = call->next, j++) { + int j = 0; + for (DRWDynamicCall *call = shgroup->calls.first; call; call = call->next, j++) { + int i = 0; + for (DRWAttrib *attrib = interface->attribs.first; attrib; attrib = attrib->next, i++) { setAttrib(vbo, attrib->format_id, j, call->data[i]); } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [08c1afb088] blender2.8: Clay Engine: Separate batch for Z straight line
Commit: 08c1afb088743a57eb2e9475a6e531ae27b8b4ac Author: Clément Foucault Date: Thu Feb 9 17:27:01 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB08c1afb088743a57eb2e9475a6e531ae27b8b4ac Clay Engine: Separate batch for Z straight line === M source/blender/draw/intern/draw_cache.c M source/blender/draw/intern/draw_cache.h === diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index 1255a083b8..7ea6b8d006 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -42,9 +42,9 @@ static struct DRWShapeCache{ Batch *drw_fullscreen_quad; Batch *drw_plain_axes; Batch *drw_single_arrow; - Batch *drw_single_arrow_line; Batch *drw_cube; Batch *drw_circle; + Batch *drw_line; Batch *drw_empty_sphere; Batch *drw_empty_cone; Batch *drw_arrows; @@ -62,12 +62,12 @@ void DRW_shape_cache_free(void) Batch_discard_all(SHC.drw_plain_axes); if (SHC.drw_single_arrow) Batch_discard_all(SHC.drw_single_arrow); - if (SHC.drw_single_arrow_line) - Batch_discard_all(SHC.drw_single_arrow_line); if (SHC.drw_cube) Batch_discard_all(SHC.drw_cube); if (SHC.drw_circle) Batch_discard_all(SHC.drw_circle); + if (SHC.drw_line) + Batch_discard_all(SHC.drw_line); if (SHC.drw_empty_sphere) Batch_discard_all(SHC.drw_empty_sphere); if (SHC.drw_empty_cone) @@ -149,7 +149,6 @@ Batch *DRW_cache_cube_get(void) return SHC.drw_cube; } - Batch *DRW_cache_circle_get(void) { #define CIRCLE_RESOL 32 @@ -184,6 +183,31 @@ Batch *DRW_cache_circle_get(void) #undef CIRCLE_RESOL } +Batch *DRW_cache_single_line_get(void) +{ + /* Z axis line */ + if (!SHC.drw_line) { + float v1[3] = {0.0f, 0.0f, 0.0f}; + float v2[3] = {0.0f, 0.0f, 1.0f}; + + /* Position Only 3D format */ + static VertexFormat format = { 0 }; + static unsigned pos_id; + if (format.attrib_ct == 0) { + pos_id = add_attrib(, "pos", GL_FLOAT, 3, KEEP_FLOAT); + } + + VertexBuffer *vbo = VertexBuffer_create_with_format(); + VertexBuffer_allocate_data(vbo, 2); + + setAttrib(vbo, pos_id, 0, v1); + setAttrib(vbo, pos_id, 1, v2); + + SHC.drw_line = Batch_create(GL_LINES, vbo, NULL); + } + return SHC.drw_line; +} + /* Empties */ Batch *DRW_cache_plain_axes_get(void) { @@ -218,9 +242,9 @@ Batch *DRW_cache_plain_axes_get(void) return SHC.drw_plain_axes; } -Batch *DRW_cache_single_arrow_get(Batch **line) +Batch *DRW_cache_single_arrow_get(void) { - if (!SHC.drw_single_arrow_line || !SHC.drw_single_arrow) { + if (!SHC.drw_single_arrow) { float v1[3] = {0.0f, 0.0f, 0.0f}, v2[3], v3[3]; /* Position Only 3D format */ @@ -230,18 +254,8 @@ Batch *DRW_cache_single_arrow_get(Batch **line) pos_id = add_attrib(, "pos", GL_FLOAT, 3, KEEP_FLOAT); } - /* Line */ - VertexBuffer *vbo = VertexBuffer_create_with_format(); - VertexBuffer_allocate_data(vbo, 2); - - setAttrib(vbo, pos_id, 0, v1); - v1[2] = 1.0f; - setAttrib(vbo, pos_id, 1, v1); - - SHC.drw_single_arrow_line = Batch_create(GL_LINES, vbo, NULL); - /* Square Pyramid */ - vbo = VertexBuffer_create_with_format(); + VertexBuffer *vbo = VertexBuffer_create_with_format(); VertexBuffer_allocate_data(vbo, 12); v2[0] = 0.035f; v2[1] = 0.035f; @@ -265,7 +279,6 @@ Batch *DRW_cache_single_arrow_get(Batch **line) SHC.drw_single_arrow = Batch_create(GL_TRIANGLES, vbo, NULL); } - *line = SHC.drw_single_arrow_line; return SHC.drw_single_arrow; } diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h index c53f3d88af..0e467bddbf 100644 --- a/source/blender/draw/intern/draw_cache.h +++ b/source/blender/draw/intern/draw_cache.h @@ -34,10 +34,11 @@ void DRW_shape_cache_free(void); /* Common Shapes */ struct Batch *DRW_cache_fullscreen_quad_get(void); struct Batch *DRW_cache_single_vert_get(void); +struct Batch *DRW_cache_single_line_get(void); /* Empties */ struct Batch *DRW_cache_plain_axes_get(void); -struct Batch *DRW_cache_single_arrow_get(struct Batch **line); +struct Batch *DRW_cache_single_arrow_get(void); struct Batch *DRW_cache_cube_get(void); struct Batch *DRW_cache_circle_get(
[Bf-blender-cvs] [24703c97a1] blender2.8: GPU shaders / Clay engine : small renaming / cleanup
Commit: 24703c97a15dc5c071d768274d3ebdcd4b4a7324 Author: Clément Foucault Date: Sat Feb 11 21:15:46 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB24703c97a15dc5c071d768274d3ebdcd4b4a7324 GPU shaders / Clay engine : small renaming / cleanup === M source/blender/draw/intern/draw_mode_pass.c M source/blender/gpu/CMakeLists.txt M source/blender/gpu/GPU_shader.h M source/blender/gpu/intern/gpu_shader.c M source/blender/gpu/shaders/gpu_shader_3D_groundpoint_vert.glsl R100source/blender/gpu/shaders/gpu_shader_3D_groundline_vert.glsl source/blender/gpu/shaders/gpu_shader_3D_passthrough_vert.glsl R066source/blender/gpu/shaders/gpu_shader_3D_lamp_vert.glsl source/blender/gpu/shaders/gpu_shader_instance_screenspace_variying_color_vert.glsl M source/blender/gpu/shaders/gpu_shader_instance_variying_size_variying_color_vert.glsl M source/blender/gpu/shaders/gpu_shader_instance_vert.glsl === diff --git a/source/blender/draw/intern/draw_mode_pass.c b/source/blender/draw/intern/draw_mode_pass.c index a5b2d0a09c..0298db1a5c 100644 --- a/source/blender/draw/intern/draw_mode_pass.c +++ b/source/blender/draw/intern/draw_mode_pass.c @@ -113,12 +113,13 @@ static DRWShadingGroup *shgroup_groundpoints_uniform_color(DRWPass *pass, float return grp; } -static DRWShadingGroup *shgroup_lamp(DRWPass *pass, struct Batch *geom, float *size) +static DRWShadingGroup *shgroup_instance_screenspace(DRWPass *pass, struct Batch *geom, float *size) { - GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_LAMP_COMMON); + GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_SCREENSPACE_VARIYING_COLOR +); DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom); - DRW_shgroup_attrib_float(grp, "lamp_pos", 3); + DRW_shgroup_attrib_float(grp, "world_pos", 3); DRW_shgroup_attrib_float(grp, "color", 3); DRW_shgroup_uniform_float(grp, "size", size, 1); DRW_shgroup_uniform_float(grp, "pixel_size", DRW_viewport_pixelsize_get(), 1); @@ -128,7 +129,7 @@ static DRWShadingGroup *shgroup_lamp(DRWPass *pass, struct Batch *geom, float *s return grp; } -static DRWShadingGroup *shgroup_empty(DRWPass *pass, struct Batch *geom) +static DRWShadingGroup *shgroup_instance(DRWPass *pass, struct Batch *geom) { GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE); @@ -144,9 +145,6 @@ static DRWShadingGroup *shgroup_empty(DRWPass *pass, struct Batch *geom) * The passes are populated by the rendering engine using the DRW_shgroup_* functions. */ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPass **non_meshes, DRWPass **ob_center) { - /* Theses are defined for the whole application so make sure they rely on global settings */ - - UI_GetThemeColor4fv(TH_WIRE, colorWire); UI_GetThemeColor4fv(TH_WIRE_EDIT, colorWireEdit); UI_GetThemeColor4fv(TH_ACTIVE, colorActive); @@ -189,28 +187,28 @@ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPa /* Empties */ geom = DRW_cache_plain_axes_get(); - plain_axes = shgroup_empty(*non_meshes, geom); + plain_axes = shgroup_instance(*non_meshes, geom); geom = DRW_cache_cube_get(); - cube = shgroup_empty(*non_meshes, geom); + cube = shgroup_instance(*non_meshes, geom); geom = DRW_cache_circle_get(); - circle = shgroup_empty(*non_meshes, geom); + circle = shgroup_instance(*non_meshes, geom); geom = DRW_cache_empty_sphere_get(); - sphere = shgroup_empty(*non_meshes, geom); + sphere = shgroup_instance(*non_meshes, geom); geom = DRW_cache_empty_cone_get(); - cone = shgroup_empty(*non_meshes, geom); + cone = shgroup_instance(*non_meshes, geom); geom = DRW_cache_single_arrow_get(); - single_arrow = shgroup_empty(*non_meshes, geom); + single_arrow = shgroup_instance(*non_meshes, geom); geom = DRW_cache_single_line_get(); - single_arrow_line = shgroup_empty(*non_meshes, geom); + single_arrow_line = shgroup_instance(*non_meshes, geom); geom = DRW_cache_single_arrow_get(); - arrows = shgroup_empty(*non_meshes, geom); + arrows = shgroup_instance(*non_meshes, geom); /* Lamps */ lampCenterSize = (U.obcenter_dia + 1.5f) * U.pixelsize; @@ -223,11 +221,11 @@ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wir
[Bf-blender-cvs] [7fc632a856] blender2.8: OpenGL immediate mode: drawarmature.c (end)
Commit: 7fc632a8564000731779bb66c7ddd6066b6511cd Author: Clément Foucault Date: Tue Feb 14 00:34:52 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB7fc632a8564000731779bb66c7ddd6066b6511cd OpenGL immediate mode: drawarmature.c (end) No deprecated call left. === M source/blender/editors/space_view3d/drawarmature.c M source/blender/editors/space_view3d/drawobject.c M source/blender/editors/space_view3d/view3d_intern.h === diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index 1de862b72e..c14a4f980a 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -153,7 +153,6 @@ static void cp_shade_color3ub(unsigned char cp[3], const int offset) /* This function sets the gl-color for coloring a certain bone (based on bcolor) */ static bool set_pchan_glColor(short colCode, int boneflag, short constflag) { - /* TODO remove glColor/UI_ThemeColor functions when no longer needed */ switch (colCode) { case PCHAN_COLOR_NORMAL: { @@ -175,24 +174,19 @@ static bool set_pchan_glColor(short colCode, int boneflag, short constflag) cp_shade_color3ub(cp, -50); } - glColor3ubv(cp); rgb_uchar_to_float(fcolor, cp); } else { if ((boneflag & BONE_DRAW_ACTIVE) && (boneflag & BONE_SELECTED)) { - UI_ThemeColor(TH_BONE_POSE_ACTIVE); UI_GetThemeColor4fv(TH_BONE_POSE_ACTIVE, fcolor); } else if (boneflag & BONE_DRAW_ACTIVE) { - UI_ThemeColorBlend(TH_WIRE, TH_BONE_POSE, 0.15f); /* unselected active */ UI_GetThemeColorBlendShade4fv(TH_WIRE, TH_BONE_POSE, 0.15f, 0, fcolor); } else if (boneflag & BONE_SELECTED) { - UI_ThemeColor(TH_BONE_POSE); UI_GetThemeColor4fv(TH_BONE_POSE, fcolor); } else { - UI_ThemeColor(TH_WIRE); UI_GetThemeColor4fv(TH_WIRE, fcolor); } } @@ -202,11 +196,9 @@ static bool set_pchan_glColor(short colCode, int boneflag, short constflag) case PCHAN_COLOR_SOLID: { if (bcolor) { - glColor3ubv((unsigned char *)bcolor->solid); rgb_uchar_to_float(fcolor, (unsigned char *)bcolor->solid); } else { - UI_ThemeColor(TH_BONE_SOLID); UI_GetThemeColor4fv(TH_BONE_SOLID, fcolor); } @@ -221,7 +213,6 @@ static bool set_pchan_glColor(short colCode, int boneflag, short constflag) else if (constflag & PCHAN_HAS_SPLINEIK) rgba_char_args_set((char *)cp, 200, 255, 0, 80); else if (constflag & PCHAN_HAS_CONST) rgba_char_args_set((char *)cp, 0, 255, 120, 80); - glColor4ubv(cp); rgba_uchar_to_float(fcolor, cp); return true; @@ -243,20 +234,16 @@ static bool set_pchan_glColor(short colCode, int boneflag, short constflag) copy_v3_v3_char((char *)cp, bcolor->solid); } - glColor3ubv(cp); rgb_uchar_to_float(fcolor, cp); } else { if (boneflag & BONE_DRAW_ACTIVE) { - UI_ThemeColorShade(TH_BONE_POSE, 40); UI_GetThemeColorShade4fv(TH_BONE_POSE, 40, fcolor); } else if (boneflag & BONE_SELECTED) { - UI_ThemeColor(TH_BONE_POSE); UI_GetThemeColor4fv(TH_BONE_POSE, fcolor); } else { -
[Bf-blender-cvs] [0790976b6c] blender2.8: OpenGL immediate mode: fix inverted normal in sphere batch
Commit: 0790976b6c37b4d6d688b196093358a0369a2ee0 Author: Clément Foucault Date: Sun Feb 12 19:25:49 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB0790976b6c37b4d6d688b196093358a0369a2ee0 OpenGL immediate mode: fix inverted normal in sphere batch === M source/blender/editors/interface/interface_draw.c M source/blender/gpu/intern/gpu_batch.c === diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 7b17c3d644..efd920aef6 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -1301,7 +1301,6 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect) /* setup lights */ ui_but_v3_get(but, light); - light[2] = -light[2]; /* transform to button */ gpuMatrixBegin3D_legacy(); diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c index 716c5e55b3..5e86f1e26b 100644 --- a/source/blender/gpu/intern/gpu_batch.c +++ b/source/blender/gpu/intern/gpu_batch.c @@ -78,15 +78,15 @@ static Batch *batch_sphere(int lat_res, int lon_res) lat = 0.0f; for(int j = 0; j < lat_res; j++, lat += lat_inc) { if (j != lat_res - 1) { /* Pole */ - batch_sphere_lat_lon_vert(lat, lon); - batch_sphere_lat_lon_vert(lat+lat_inc, lon); batch_sphere_lat_lon_vert(lat+lat_inc, lon+lon_inc); + batch_sphere_lat_lon_vert(lat+lat_inc, lon); + batch_sphere_lat_lon_vert(lat, lon); } if (j != 0) { /* Pole */ - batch_sphere_lat_lon_vert(lat, lon); - batch_sphere_lat_lon_vert(lat+lat_inc, lon+lon_inc); batch_sphere_lat_lon_vert(lat, lon+lon_inc); + batch_sphere_lat_lon_vert(lat+lat_inc, lon+lon_inc); + batch_sphere_lat_lon_vert(lat, lon); } } } @@ -109,7 +109,7 @@ Batch *Batch_get_sphere(int lod) void gpu_batch_init(void) { /* Hard coded resolution */ - sphere_low = batch_sphere(8, 8); + sphere_low = batch_sphere(8, 16); sphere_med = batch_sphere(16, 10); sphere_high = batch_sphere(32, 24); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [22df54acb6] blender2.8: OpenGL immediate mode: drawarmature.c (cont)
Commit: 22df54acb62084cf8a8409203e8656f176c28a29 Author: Clément Foucault Date: Mon Feb 13 12:41:05 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB22df54acb62084cf8a8409203e8656f176c28a29 OpenGL immediate mode: drawarmature.c (cont) All (except for stick and wire) are now rendered using batch or immediate API. Using simple front facing lighting for now, waiting for gpu_basic_shader.c to be recoded. === M source/blender/editors/space_view3d/drawarmature.c M source/blender/gpu/gawain/batch.c === diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index a7bff0a830..1de862b72e 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -64,6 +64,7 @@ #include "GPU_basic_shader.h" #include "GPU_batch.h" +#include "GPU_immediate.h" #include "GPU_matrix.h" #include "UI_resources.h" @@ -77,6 +78,7 @@ /* global here is reset before drawing each bone */ static ThemeWireColor *bcolor = NULL; static float fcolor[4] = {0.0f}; +static bool flat_color; /* values of colCode for set_pchan_glcolor */ enum { @@ -355,6 +357,17 @@ static void set_ebone_glColor(const unsigned int boneflag) /* *** Armature drawing, helper calls for parts *** */ +static void add_solid_flat_triangle(VertexBuffer *vbo, unsigned int *vertex, unsigned int pos, unsigned int nor, +const float p1[3], const float p2[3], const float p3[3], const float n[3]) +{ + setAttrib(vbo, nor, *vertex, n); + setAttrib(vbo, pos, (*vertex)++, p1); + setAttrib(vbo, nor, *vertex, n); + setAttrib(vbo, pos, (*vertex)++, p2); + setAttrib(vbo, nor, *vertex, n); + setAttrib(vbo, pos, (*vertex)++, p3); +} + /* half the cube, in Y */ static const float cube_vert[8][3] = { {-1.0, 0.0, -1.0}, @@ -375,44 +388,63 @@ static const float cube_wire[24] = { static void drawsolidcube_size(float xsize, float ysize, float zsize) { - static GLuint displist = 0; - float n[3] = {0.0f}; - - glScalef(xsize, ysize, zsize); + static VertexFormat format = {0}; + static VertexBuffer vbo = {0}; + static Batch batch = {0}; + const float light_vec[3] = {0.0f, 0.0f, 1.0f}; + + if (format.attrib_ct == 0) { + unsigned int i = 0; + float n[3] = {0.0f}; + /* Vertex format */ + unsigned int pos = add_attrib(, "pos", GL_FLOAT, 3, KEEP_FLOAT); + unsigned int nor = add_attrib(, "nor", GL_FLOAT, 3, KEEP_FLOAT); - if (displist == 0) { - displist = glGenLists(1); - glNewList(displist, GL_COMPILE); + /* Vertices */ + VertexBuffer_init_with_format(, ); + VertexBuffer_allocate_data(, 36); - glBegin(GL_QUADS); n[0] = -1.0; - glNormal3fv(n); - glVertex3fv(cube_vert[0]); glVertex3fv(cube_vert[1]); glVertex3fv(cube_vert[2]); glVertex3fv(cube_vert[3]); + add_solid_flat_triangle(, , pos, nor, cube_vert[0], cube_vert[1], cube_vert[2], n); + add_solid_flat_triangle(, , pos, nor, cube_vert[2], cube_vert[3], cube_vert[0], n); n[0] = 0; n[1] = -1.0; - glNormal3fv(n); - glVertex3fv(cube_vert[0]); glVertex3fv(cube_vert[4]); glVertex3fv(cube_vert[5]); glVertex3fv(cube_vert[1]); + add_solid_flat_triangle(, , pos, nor, cube_vert[0], cube_vert[4], cube_vert[5], n); + add_solid_flat_triangle(, , pos, nor, cube_vert[5], cube_vert[1], cube_vert[0], n); n[1] = 0; n[0] = 1.0; - glNormal3fv(n); - glVertex3fv(cube_vert[4]); glVertex3fv(cube_vert[7]); glVertex3fv(cube_vert[6]); glVertex3fv(cube_vert[5]); + add_solid_flat_triangle(, , pos, nor, cube_vert[4], cube_vert[7], cube_vert[6], n); + add_solid_flat_triangle(, , pos, nor, cube_vert[6], cube_vert[5], cube_vert[4], n); n[0] = 0; n[1] = 1.0; - glNormal3fv(n); - glVertex3fv(cube_vert[7]); glVertex3fv(cube_vert[3]); glVertex3fv(cube_vert[2]); glVertex3fv(cube_vert[6]); + add_solid_flat_triangle(, , pos, nor, cube_vert[7], cube_vert[3], cube_vert[2], n); + add_solid_flat_triangle(, , pos, nor, cube_vert[2], cube_vert[6], cube_vert[7], n); n[1] = 0; n[2] = 1.0; - glNormal3fv(n); - glVertex3fv(cube_vert[1]); glVertex3fv(cube_vert[5]); glVertex3fv(cube_vert[6]); glVertex3
[Bf-blender-cvs] [1089294439] blender2.8: OpenGL immediate mode: Remove unecessary light shader
Commit: 10892944399ebca856163cc8c805c0de3c598614 Author: Clément Foucault Date: Tue Feb 14 00:49:16 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB10892944399ebca856163cc8c805c0de3c598614 OpenGL immediate mode: Remove unecessary light shader === M source/blender/editors/curve/editcurve_paint.c === diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c index 01d9167cdb..7b93e00b86 100644 --- a/source/blender/editors/curve/editcurve_paint.c +++ b/source/blender/editors/curve/editcurve_paint.c @@ -479,13 +479,9 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS float color[3]; UI_GetThemeColor3fv(TH_WIRE, color); - /* silly light-less shader, non-critical task, so it's fine */ - float light[3] = {0.0f, 0.0f, 0.0f}; - Batch *sphere = Batch_get_sphere(0); - Batch_set_builtin_program(sphere, GPU_SHADER_SIMPLE_LIGHTING); + Batch_set_builtin_program(sphere, GPU_SHADER_3D_UNIFORM_COLOR); Batch_Uniform3fv(sphere, "color", color); - Batch_Uniform3fv(sphere, "light", light); /* scale to edit-mode space */ gpuMatrixBegin3D_legacy(); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [9c35907ca2] blender2.8: OpenGL immediate mode: Replacement for gluCylinder
Commit: 9c35907ca2c7963d722de469e9116350da70b71b Author: Clément Foucault Date: Sun Feb 12 19:19:35 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB9c35907ca2c7963d722de469e9116350da70b71b OpenGL immediate mode: Replacement for gluCylinder === M source/blender/editors/include/BIF_glutil.h M source/blender/editors/screen/glutil.c === diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h index d0bd951344..0355925f83 100644 --- a/source/blender/editors/include/BIF_glutil.h +++ b/source/blender/editors/include/BIF_glutil.h @@ -138,6 +138,20 @@ void imm_draw_line(unsigned pos, float x1, float y1, float x2, float y2); void imm_cpack(unsigned int x); /** +* Draw a cylinder. Replacement for gluCylinder. +* _warning_ : Slow, better use it only if you no other choices. +* +* \param pos The vertex attribute number for position. +* \param nor The vertex attribute number for normal. +* \param base Specifies the radius of the cylinder at z = 0. +* \param top Specifies the radius of the cylinder at z = height. +* \param height Specifies the height of the cylinder. +* \param slices Specifies the number of subdivisions around the z axis. +* \param stacks Specifies the number of subdivisions along the z axis. +*/ +void imm_cylinder(unsigned int pos, unsigned int nor, float base, float top, float height, int slices, int stacks); + +/** * Returns a float value as obtained by glGetFloatv. * The param must cause only one value to be gotten from GL. */ diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index dde4762676..4a8edef4ca 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -251,6 +251,57 @@ void imm_cpack(unsigned int x) (((x) >> 16) & 0xFF)); } +void imm_cylinder(unsigned int pos, unsigned int nor, float base, float top, float height, int slices, int stacks) +{ + immBegin(GL_TRIANGLES, 6 * slices * stacks); + for (int i = 0; i < slices; ++i) { + const float angle1 = 2 * M_PI * ((float)i / (float)slices); + const float angle2 = 2 * M_PI * ((float)(i+1) / (float)slices); + const float cos1 = cosf(angle1); + const float sin1 = sinf(angle1); + const float cos2 = cosf(angle2); + const float sin2 = sinf(angle2); + + for (int j = 0; j < stacks; ++j) { + float fac1 = (float)j / (float)stacks; + float fac2 = (float)(j+1) / (float)stacks; + float r1 = base * (1.f - fac1) + top * fac1; + float r2 = base * (1.f - fac2) + top * fac2; + float h1 = height * ((float)j / (float)stacks); + float h2 = height * ((float)(j+1) / (float)stacks); + + float v1[3] = {r1 * cos2, r1 * sin2, h1}; + float v2[3] = {r2 * cos2, r2 * sin2, h2}; + float v3[3] = {r2 * cos1, r2 * sin1, h2}; + float v4[3] = {r1 * cos1, r1 * sin1, h1}; + float n1[3], n2[3]; + + /* calc normals */ + sub_v3_v3v3(n1, v2, v1); + normalize_v3(n1); + n1[0] = cos1; n1[1] = sin1; n1[2] = 1-n1[2]; + + sub_v3_v3v3(n2, v3, v4); + normalize_v3(n2); + n2[0] = cos2; n2[1] = sin2; n2[2] = 1-n2[2]; + + /* first tri */ + immAttrib3fv(nor, n2); + immVertex3fv(pos, v1); + immVertex3fv(pos, v2); + immAttrib3fv(nor, n1); + immVertex3fv(pos, v3); + + /* second tri */ + immVertex3fv(pos, v3); + immVertex3fv(pos, v4); + immAttrib3fv(nor, n2); + immVertex3fv(pos, v1); + } + } + immEnd(); +} + float glaGetOneFloat(int param) { GLfloat v; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs