Page MenuHome

world_color6.diff

Authored By
Jacob F (raccoon)
Nov 13 2013, 2:43 PM
Size
11 KB
Subscribers
None

world_color6.diff

Index: release/scripts/startup/bl_ui/space_view3d.py
===================================================================
--- release/scripts/startup/bl_ui/space_view3d.py (revision 36044)
+++ release/scripts/startup/bl_ui/space_view3d.py (working copy)
@@ -2101,6 +2101,9 @@
subsub = sub.column(align=True)
subsub.active = scene.unit_settings.system == 'NONE'
subsub.prop(view, "grid_subdivisions", text="Subdivisions")
+
+ col = layout.column()
+ col.prop(view, "display_world_color")
col = layout.column()
col.label(text="Shading:")
Index: source/blender/makesdna/DNA_view3d_types.h
===================================================================
--- source/blender/makesdna/DNA_view3d_types.h (revision 36044)
+++ source/blender/makesdna/DNA_view3d_types.h (working copy)
@@ -244,6 +244,7 @@
#define V3D_RENDER_OVERRIDE 4
#define V3D_SOLID_TEX 8
#define V3D_DISPGP 16
+#define V3D_WORLD_COLOR 32
/* View3D->around */
#define V3D_CENTER 0
Index: source/blender/makesrna/intern/rna_world.c
===================================================================
--- source/blender/makesrna/intern/rna_world.c (revision 36044)
+++ source/blender/makesrna/intern/rna_world.c (working copy)
@@ -503,14 +503,14 @@
RNA_def_property_ui_text(prop, "Horizon Color", "Color at the horizon");
/* RNA_def_property_update(prop, 0, "rna_World_update"); */
/* render-only uses this */
- RNA_def_property_update(prop, NC_WORLD|ND_WORLD_DRAW, "rna_World_update");
+ RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, "rna_World_update");
prop= RNA_def_property(srna, "zenith_color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "zenr");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Zenith Color", "Color at the zenith");
- RNA_def_property_update(prop, 0, "rna_World_update");
+ RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, "rna_World_update");
prop= RNA_def_property(srna, "ambient_color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "ambr");
@@ -535,12 +535,13 @@
prop= RNA_def_property(srna, "use_sky_blend", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "skytype", WO_SKYBLEND);
RNA_def_property_ui_text(prop, "Blend Sky", "Render background with natural progression from horizon to zenith");
- RNA_def_property_update(prop, 0, "rna_World_update");
+ RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, "rna_World_update");
prop= RNA_def_property(srna, "use_sky_paper", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "skytype", WO_SKYPAPER);
RNA_def_property_ui_text(prop, "Paper Sky", "Flatten blend or texture coordinates");
RNA_def_property_update(prop, 0, "rna_World_update");
+ RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, "rna_World_update");
prop= RNA_def_property(srna, "use_sky_real", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "skytype", WO_SKYREAL);
Index: source/blender/makesrna/intern/rna_space.c
===================================================================
--- source/blender/makesrna/intern/rna_space.c (revision 36044)
+++ source/blender/makesrna/intern/rna_space.c (working copy)
@@ -1121,6 +1121,11 @@
RNA_def_property_ui_text(prop, "3D Cursor Location", "3D cursor location for this view (dependent on local view setting)");
RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 4);
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL);
+
+ prop= RNA_def_property(srna, "display_world_color", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_WORLD_COLOR);
+ RNA_def_property_ui_text(prop, "Use World Color", "Use the world settings for the background");
+ RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL);
prop= RNA_def_property(srna, "lens", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "lens");
Index: source/blender/editors/space_view3d/view3d_draw.c
===================================================================
--- source/blender/editors/space_view3d/view3d_draw.c (revision 36044)
+++ source/blender/editors/space_view3d/view3d_draw.c (working copy)
@@ -249,7 +249,7 @@
#define GRID_MIN_PX 6.0f
-static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **grid_unit)
+static void drawgrid(UnitSettings *unit, ARegion *ar, Scene *scene, View3D *v3d, char **grid_unit)
{
/* extern short bgpicmode; */
RegionView3D *rv3d= ar->regiondata;
@@ -287,6 +287,11 @@
/* check zoom out */
UI_ThemeColor(TH_GRID);
+ if(v3d->flag2 & V3D_WORLD_COLOR) {
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ }
+
if(unit->system) {
/* Use GRID_MIN_PX*2 for units because very very small grid
* items are less useful when dealing with units */
@@ -316,10 +321,12 @@
/* tweak to have the fade a bit nicer */
blend_fac= (blend_fac * blend_fac) * 2.0f;
CLAMP(blend_fac, 0.3f, 1.0f);
+
+ if((v3d->flag2 & V3D_WORLD_COLOR)==0)
+ UI_ThemeColorBlend(TH_BACK, TH_GRID, blend_fac);
+ else
+ UI_ThemeColorShadeAlpha(TH_GRID, 0, blend_fac * 255 - 255);
-
- UI_ThemeColorBlend(TH_BACK, TH_GRID, blend_fac);
-
drawgrid_draw(ar, wx, wy, x, y, dx_scalar);
}
}
@@ -345,7 +352,11 @@
}
}
else { // start blending out
- UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ if((v3d->flag2 & V3D_WORLD_COLOR)==0)
+ UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ else
+ UI_ThemeColorShadeAlpha(TH_GRID, 0, dx/(GRID_MIN_PX*6) * 255 - 255);
+
drawgrid_draw(ar, wx, wy, x, y, dx);
UI_ThemeColor(TH_GRID);
@@ -353,7 +364,11 @@
}
}
else { // start blending out (GRID_MIN_PX < dx < (GRID_MIN_PX*10))
- UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ if((v3d->flag2 & V3D_WORLD_COLOR)==0)
+ UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ else
+ UI_ThemeColorShadeAlpha(TH_GRID, 0, dx/(GRID_MIN_PX*6) * 255 - 255);
+
drawgrid_draw(ar, wx, wy, x, y, dx);
UI_ThemeColor(TH_GRID);
@@ -372,21 +387,32 @@
drawgrid_draw(ar, wx, wy, x, y, dx);
}
else {
- UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ if((v3d->flag2 & V3D_WORLD_COLOR)==0)
+ UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ else
+ UI_ThemeColorShadeAlpha(TH_GRID, 0, dx/(GRID_MIN_PX*6) * 255 - 255);
+
drawgrid_draw(ar, wx, wy, x, y, dx);
UI_ThemeColor(TH_GRID);
drawgrid_draw(ar, wx, wy, x, y, dx*sublines);
}
}
else {
- UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ if((v3d->flag2 & V3D_WORLD_COLOR)==0)
+ UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ else
+ UI_ThemeColorShadeAlpha(TH_GRID, 0, dx/(GRID_MIN_PX*6) * 255 - 255);
drawgrid_draw(ar, wx, wy, x, y, dx);
UI_ThemeColor(TH_GRID);
drawgrid_draw(ar, wx, wy, x, y, dx*sublines);
}
}
else {
- UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ if((v3d->flag2 & V3D_WORLD_COLOR)==0)
+ UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ else
+ UI_ThemeColorShadeAlpha(TH_GRID, 0, dx/(GRID_MIN_PX*6) * 255 - 255);
+
drawgrid_draw(ar, wx, wy, x, y, dx);
UI_ThemeColor(TH_GRID);
drawgrid_draw(ar, wx, wy, x, y, dx*sublines);
@@ -394,6 +420,8 @@
}
}
+ if(v3d->flag2 & V3D_WORLD_COLOR)
+ glDisable(GL_BLEND);
x+= (wx);
y+= (wy);
@@ -685,10 +713,10 @@
icon= ICON_AXIS_FRONT;
else if( ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT))
icon= ICON_AXIS_SIDE;
- else return ;
+ else return;
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
UI_icon_draw(5.0, 5.0, icon);
@@ -2323,18 +2351,81 @@
}
/* clear background */
- if((v3d->flag2 & V3D_RENDER_OVERRIDE) && scene->world) {
- if(scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
- linearrgb_to_srgb_v3_v3(backcol, &scene->world->horr);
+ if (!scene->world || (v3d->flag2 & V3D_WORLD_COLOR)==0) { // clear with solid color
+ if((v3d->flag2 & V3D_RENDER_OVERRIDE) && scene->world) {
+ if(scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
+ linearrgb_to_srgb_v3_v3(backcol, &scene->world->horr);
+ else
+ copy_v3_v3(backcol, &scene->world->horr);
+ glClearColor(backcol[0], backcol[1], backcol[2], 0.0);
+ }
else
- copy_v3_v3(backcol, &scene->world->horr);
- glClearColor(backcol[0], backcol[1], backcol[2], 0.0);
+ UI_ThemeClearColor(TH_BACK);
+
+ glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
}
- else
- UI_ThemeClearColor(TH_BACK);
+ else { // clear with gradient
+ if(scene->world->skytype & WO_SKYBLEND) { // blend sky
+ float box = 1.0;
+
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glShadeModel(GL_SMOOTH);
+
+
+ if(!(scene->world->skytype & WO_SKYPAPER)) {
+ float r = -rv3d->viewmat[2][0] * 90;
+ float s = 0.001913 / rv3d->pixsize; //0.001913 is pixsize when lens = 35
+
+ if(rv3d->viewmat[2][1] < 0)
+ r = 180 - r;
+
+ glRotatef(r, 0, 0, 1);
+
+ if(s < 1) // otherwise the box isn't big enough to cover the viewport
+ s = 1; // could add more vertices to the box and expand the solid colors
+
+ glScalef(s, s, 1);
+ box = 1.57;
+ }
+
+ glBegin(GL_QUADS);
+ //horizon
+ if(scene->world->skytype & WO_SKYPAPER || rv3d->viewmat[2][2] > 0)
+ glColor3f(scene->world->horr, scene->world->horg, scene->world->horb);
+ else {
+ glColor3f(scene->world->horr * (1 + rv3d->viewmat[2][2]) + scene->world->zenr * -rv3d->viewmat[2][2],
+ scene->world->horg * (1 + rv3d->viewmat[2][2]) + scene->world->zeng * -rv3d->viewmat[2][2],
+ scene->world->horb * (1 + rv3d->viewmat[2][2]) + scene->world->zenb * -rv3d->viewmat[2][2]);
+ }
+
+ glVertex2f(-box,-box);
+ glVertex2f(box,-box);
+ //zenith
+ if(scene->world->skytype & WO_SKYPAPER || rv3d->viewmat[2][2] < 0)
+ glColor3f(scene->world->zenr, scene->world->zeng, scene->world->zenb);
+ else {
+ glColor3f(scene->world->zenr * (1 - rv3d->viewmat[2][2]) + scene->world->horr * rv3d->viewmat[2][2],
+ scene->world->zeng * (1 - rv3d->viewmat[2][2]) + scene->world->horg * rv3d->viewmat[2][2],
+ scene->world->zenb * (1 - rv3d->viewmat[2][2]) + scene->world->horb * rv3d->viewmat[2][2]);
+ }
+ glVertex2f(box, box);
+ glVertex2f(-box, box);
+ glEnd();
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
-
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+ glShadeModel(GL_FLAT);
+ }
+ else { // solid sky
+ glClearColor(scene->world->horr, scene->world->horg, scene->world->horb, 0.0);
+ glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+ }
+ }
/* setup view matrices */
view3d_main_area_setup_view(scene, v3d, ar, NULL, NULL);
@@ -2377,7 +2468,7 @@
else {
if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) {
ED_region_pixelspace(ar);
- drawgrid(&scene->unit, ar, v3d, &grid_unit);
+ drawgrid(&scene->unit, ar, scene, v3d, &grid_unit);
/* XXX make function? replaces persp(1) */
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(rv3d->winmat);

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
c4/1f/41f519d177a3d2f37ca6f0a1a724

Event Timeline