Page MenuHome

world_color7.diff

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

world_color7.diff

Index: release/scripts/startup/bl_ui/space_view3d.py
===================================================================
--- release/scripts/startup/bl_ui/space_view3d.py (revision 39781)
+++ release/scripts/startup/bl_ui/space_view3d.py (working copy)
@@ -2170,6 +2170,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 39781)
+++ source/blender/makesdna/DNA_view3d_types.h (working copy)
@@ -248,6 +248,7 @@
#define V3D_DISPGP 16
#define V3D_LOCK_CAMERA 32
#define V3D_RENDER_SHADOW 64 /* This is a runtime only flag that's used to tell draw_mesh_object() that we're doing a shadow pass instead of a regular draw */
+#define V3D_WORLD_COLOR 128
/* View3D->around */
#define V3D_CENTER 0
Index: source/blender/makesrna/intern/rna_world.c
===================================================================
--- source/blender/makesrna/intern/rna_world.c (revision 39781)
+++ 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 39781)
+++ source/blender/makesrna/intern/rna_space.c (working copy)
@@ -1215,6 +1215,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 39781)
+++ source/blender/editors/space_view3d/view3d_draw.c (working copy)
@@ -288,6 +288,8 @@
/* check zoom out */
UI_ThemeColor(TH_GRID);
+ glEnable(GL_BLEND);
+
if(unit->system) {
/* Use GRID_MIN_PX*2 for units because very very small grid
* items are less useful when dealing with units */
@@ -317,10 +319,9 @@
/* tweak to have the fade a bit nicer */
blend_fac= (blend_fac * blend_fac) * 2.0f;
CLAMP(blend_fac, 0.3f, 1.0f);
+
+ 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);
}
}
@@ -346,7 +347,8 @@
}
}
else { // start blending out
- UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ UI_ThemeColorShadeAlpha(TH_GRID, 0, dx/(GRID_MIN_PX*6) * 255 - 255);
+
drawgrid_draw(ar, wx, wy, x, y, dx);
UI_ThemeColor(TH_GRID);
@@ -354,7 +356,8 @@
}
}
else { // start blending out (GRID_MIN_PX < dx < (GRID_MIN_PX*10))
- UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ UI_ThemeColorShadeAlpha(TH_GRID, 0, dx/(GRID_MIN_PX*6) * 255 - 255);
+
drawgrid_draw(ar, wx, wy, x, y, dx);
UI_ThemeColor(TH_GRID);
@@ -373,21 +376,23 @@
drawgrid_draw(ar, wx, wy, x, y, dx);
}
else {
- UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ 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));
+ 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));
+ 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);
@@ -395,6 +400,7 @@
}
}
+ glDisable(GL_BLEND);
x+= (wx);
y+= (wy);
@@ -784,10 +790,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);
@@ -2566,18 +2572,72 @@
}
/* 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) { /* paper sky */
+ glClear(GL_DEPTH_BUFFER_BIT);
+
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+ glShadeModel(GL_SMOOTH);
+
+ if(scene->world->skytype & WO_SKYPAPER) {
+ glBegin(GL_QUADS);
+ glColor3f(scene->world->horr, scene->world->horg, scene->world->horb);
+ glVertex2f(-1.0f,-1.0f);
+ glVertex2f(1.0f,-1.0f);
+ glColor3f(scene->world->zenr, scene->world->zeng, scene->world->zenb);
+ glVertex2f(1.0f, 1.0f);
+ glVertex2f(-1.0f, 1.0f);
+ glEnd();
+ }
+ else { /* blend sky */
+ float x, y, c;
+ glBegin(GL_QUADS);
+
+ /* Loop through the 4 corners of the background quad */
+ for(y = -1.0f; y != 3.0f; y += 2.0f)
+ for(x = y; x != 3.0f * -y; x += 2.0f * -y) {
+ c = (rv3d->viewmat[2][0] * x + rv3d->viewmat[2][1] * y) / (M_PI) * 0.5f + 0.5f;
+
+ c = c * (rv3d->viewmat[2][2] + 1.0f);
+
+ glColor3f(scene->world->horr * (1.0f - c) + scene->world->zenr * c,
+ scene->world->horg * (1.0f - c) + scene->world->zeng * c,
+ scene->world->horb * (1.0f - c) + scene->world->zenb * c);
+ glVertex2f(x,y);
+ }
+
+ glEnd();
+ }
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
-
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ 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);

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
46/d4/1541841cd4f650c4966c729ca282

Event Timeline