Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_draw.c
| /* | /* | ||||
| * ***** BEGIN GPL LICENSE BLOCK ***** | * ***** BEGIN GPL LICENSE BLOCK ***** | ||||
| * | * | ||||
| * This program is free software; you can redistribute it and/or | * This program is free software; you can redistribute it and/or | ||||
| * modify it under the terms of the GNU General Public License | * modify it under the terms of the GNU General Public License | ||||
| * as published by the Free Software Foundation; either version 2 | * as published by the Free Software Foundation; either version 2 | ||||
| * of the License, or (at your option) any later version. | * of the License, or (at your option) any later version. | ||||
| * | * | ||||
| * This program is distributed in the hope that it will be useful, | * This program is distributed in the hope that it will be useful, | ||||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
| * GNU General Public License for more details. | * GNU General Public License for more details. | ||||
| * | * | ||||
| * You should have received a copy of the GNU General Public License | * You should have received a copy of the GNU General Public License | ||||
| * along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
| * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
| * | * | ||||
| * The Original Code is Copyright (C) 2008 Blender Foundation. | * The Original Code is Copyright (C) 2008 Blender Foundation. | ||||
| * All rights reserved. | * All rights reserved. | ||||
| * | * | ||||
brecht: I just noticed that ED_view3d_draw_offscreen_init actually needs these world settings as well… | |||||
| * | * | ||||
| * Contributor(s): Blender Foundation | * Contributor(s): Blender Foundation | ||||
| * | * | ||||
| * ***** END GPL LICENSE BLOCK ***** | * ***** END GPL LICENSE BLOCK ***** | ||||
| */ | */ | ||||
| /** \file blender/editors/space_view3d/view3d_draw.c | /** \file blender/editors/space_view3d/view3d_draw.c | ||||
| * \ingroup spview3d | * \ingroup spview3d | ||||
| ▲ Show 20 Lines • Show All 2,447 Lines • ▼ Show 20 Lines | if (lamp) { | ||||
| if (layers && GPU_lamp_override_visible(lamp, srl, NULL) && GPU_lamp_has_shadow_buffer(lamp)) { | if (layers && GPU_lamp_override_visible(lamp, srl, NULL) && GPU_lamp_has_shadow_buffer(lamp)) { | ||||
| shadow = MEM_callocN(sizeof(View3DShadow), "View3DShadow"); | shadow = MEM_callocN(sizeof(View3DShadow), "View3DShadow"); | ||||
| shadow->lamp = lamp; | shadow->lamp = lamp; | ||||
| BLI_addtail(shadows, shadow); | BLI_addtail(shadows, shadow); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d) | static void gpu_update_lamps_shadows_world(Scene *scene, View3D *v3d) | ||||
| { | { | ||||
| ListBase shadows; | ListBase shadows; | ||||
| View3DShadow *shadow; | View3DShadow *shadow; | ||||
| Scene *sce_iter; | Scene *sce_iter; | ||||
| Base *base; | Base *base; | ||||
| Object *ob; | Object *ob; | ||||
| World *world = scene->world; | |||||
| SceneRenderLayer *srl = v3d->scenelock ? BLI_findlink(&scene->r.layers, scene->r.actlay) : NULL; | SceneRenderLayer *srl = v3d->scenelock ? BLI_findlink(&scene->r.layers, scene->r.actlay) : NULL; | ||||
| BLI_listbase_clear(&shadows); | BLI_listbase_clear(&shadows); | ||||
| /* update lamp transform and gather shadow lamps */ | /* update lamp transform and gather shadow lamps */ | ||||
| for (SETLOOPER(scene, sce_iter, base)) { | for (SETLOOPER(scene, sce_iter, base)) { | ||||
| ob = base->object; | ob = base->object; | ||||
| ▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | for (shadow = shadows.first; shadow; shadow = shadow->next) { | ||||
| GPU_lamp_shadow_buffer_unbind(shadow->lamp); | GPU_lamp_shadow_buffer_unbind(shadow->lamp); | ||||
| v3d->drawtype = drawtype; | v3d->drawtype = drawtype; | ||||
| v3d->lay = lay; | v3d->lay = lay; | ||||
| v3d->flag2 = flag2; | v3d->flag2 = flag2; | ||||
| } | } | ||||
| BLI_freelistN(&shadows); | BLI_freelistN(&shadows); | ||||
| /* update world values */ | |||||
| if (world) { | |||||
| GPU_mist_update_enable(world->mode & WO_MIST); | |||||
| GPU_mist_update_values(world->mistype, world->miststa, world->mistdist, world->misi, &world->horr); | |||||
| GPU_horizon_update_color(&world->horr); | |||||
| GPU_ambient_update_color(&world->ambr); | |||||
| } | |||||
| } | } | ||||
| /* *********************** customdata **************** */ | /* *********************** customdata **************** */ | ||||
| CustomDataMask ED_view3d_datamask(const Scene *scene, const View3D *v3d) | CustomDataMask ED_view3d_datamask(const Scene *scene, const View3D *v3d) | ||||
| { | { | ||||
| CustomDataMask mask = 0; | CustomDataMask mask = 0; | ||||
| ▲ Show 20 Lines • Show All 307 Lines • ▼ Show 20 Lines | static void view3d_main_area_setup_view(Scene *scene, View3D *v3d, ARegion *ar, float viewmat[4][4], float winmat[4][4]) | ||||
| glMatrixMode(GL_MODELVIEW); | glMatrixMode(GL_MODELVIEW); | ||||
| glLoadMatrixf(rv3d->viewmat); | glLoadMatrixf(rv3d->viewmat); | ||||
| } | } | ||||
| void ED_view3d_draw_offscreen_init(Scene *scene, View3D *v3d) | void ED_view3d_draw_offscreen_init(Scene *scene, View3D *v3d) | ||||
| { | { | ||||
| /* shadow buffers, before we setup matrices */ | /* shadow buffers, before we setup matrices */ | ||||
| if (draw_glsl_material(scene, NULL, v3d, v3d->drawtype)) | if (draw_glsl_material(scene, NULL, v3d, v3d->drawtype)) | ||||
| gpu_update_lamps_shadows(scene, v3d); | gpu_update_lamps_shadows_world(scene, v3d); | ||||
| } | } | ||||
| /* | /* | ||||
| * Function to clear the view | * Function to clear the view | ||||
| */ | */ | ||||
| static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar) | static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar) | ||||
| { | { | ||||
| if (scene->world && (v3d->flag3 & V3D_SHOW_WORLD)) { | if (scene->world && (v3d->flag3 & V3D_SHOW_WORLD)) { | ||||
| ▲ Show 20 Lines • Show All 350 Lines • ▼ Show 20 Lines | ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, int sizex, int sizey, unsigned int flag, | ||||
| else if (ibuf->rect) | else if (ibuf->rect) | ||||
| GPU_offscreen_read_pixels(ofs, GL_UNSIGNED_BYTE, ibuf->rect); | GPU_offscreen_read_pixels(ofs, GL_UNSIGNED_BYTE, ibuf->rect); | ||||
| /* unbind */ | /* unbind */ | ||||
| GPU_offscreen_unbind(ofs, true); | GPU_offscreen_unbind(ofs, true); | ||||
| GPU_offscreen_free(ofs); | GPU_offscreen_free(ofs); | ||||
| glPopAttrib(); | glPopAttrib(); | ||||
| if (ibuf->rect_float && ibuf->rect) | if (ibuf->rect_float && ibuf->rect) | ||||
| IMB_rect_from_float(ibuf); | IMB_rect_from_float(ibuf); | ||||
| return ibuf; | return ibuf; | ||||
| } | } | ||||
Not Done Inline ActionsCan you only do this in case GLSL drawing is enabled? There is a check for it before calling gpu_update_lamps_shadows a bit earlier in this function. brecht: Can you only do this in case GLSL drawing is enabled? There is a check for it before calling… | |||||
| /* creates own 3d views, used by the sequencer */ | /* creates own 3d views, used by the sequencer */ | ||||
| ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int width, int height, unsigned int flag, int drawtype, | ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int width, int height, unsigned int flag, int drawtype, | ||||
| bool use_solid_tex, bool use_gpencil, bool draw_background, int alpha_mode, char err_out[256]) | bool use_solid_tex, bool use_gpencil, bool draw_background, int alpha_mode, char err_out[256]) | ||||
| { | { | ||||
| View3D v3d = {NULL}; | View3D v3d = {NULL}; | ||||
| ARegion ar = {NULL}; | ARegion ar = {NULL}; | ||||
| RegionView3D rv3d = {{{0}}}; | RegionView3D rv3d = {{{0}}}; | ||||
| ▲ Show 20 Lines • Show All 262 Lines • ▼ Show 20 Lines | static void view3d_main_area_draw_objects(const bContext *C, Scene *scene, View3D *v3d, | ||||
| RegionView3D *rv3d = ar->regiondata; | RegionView3D *rv3d = ar->regiondata; | ||||
| unsigned int lay_used = v3d->lay_used; | unsigned int lay_used = v3d->lay_used; | ||||
| /* post processing */ | /* post processing */ | ||||
| bool do_compositing = false; | bool do_compositing = false; | ||||
| /* shadow buffers, before we setup matrices */ | /* shadow buffers, before we setup matrices */ | ||||
| if (draw_glsl_material(scene, NULL, v3d, v3d->drawtype)) | if (draw_glsl_material(scene, NULL, v3d, v3d->drawtype)) | ||||
| gpu_update_lamps_shadows(scene, v3d); | gpu_update_lamps_shadows_world(scene, v3d); | ||||
| /* reset default OpenGL lights if needed (i.e. after preferences have been altered) */ | /* reset default OpenGL lights if needed (i.e. after preferences have been altered) */ | ||||
| if (rv3d->rflag & RV3D_GPULIGHT_UPDATE) { | if (rv3d->rflag & RV3D_GPULIGHT_UPDATE) { | ||||
| rv3d->rflag &= ~RV3D_GPULIGHT_UPDATE; | rv3d->rflag &= ~RV3D_GPULIGHT_UPDATE; | ||||
| GPU_default_lights(); | GPU_default_lights(); | ||||
| } | } | ||||
| /* setup view matrices */ | /* setup view matrices */ | ||||
| view3d_main_area_setup_view(scene, v3d, ar, NULL, NULL); | view3d_main_area_setup_view(scene, v3d, ar, NULL, NULL); | ||||
| ▲ Show 20 Lines • Show All 312 Lines • Show Last 20 Lines | |||||
I just noticed that ED_view3d_draw_offscreen_init actually needs these world settings as well for OpenGL render. Can you move these 4 lines into gpu_update_lamps_shadows so they are handled in both cases? The function could be renamed to gpu_update_lamps_shadows_world.