Just 3D Editor Experiments

Hello,

I was experimenting with changes to the 3D editor a couple of weeks ago and thought I would share them in case anyone, who compiles their own copy of Blender, is interested.

There are three changes:

Gradient Background. You can alter the editor background so it shows a smooth gradient, instead of the single color you see normally. By default it shows the background as one color, but you can move a slider to alter the contrast between the top and bottom. Personally I don’t think it makes any difference for most uses, but I do like it while sculpting.

Multi-dimensional grid lines. We can usually just show, or not show, the grid floor (Z=0). But I always thought that it was odd to only allow this one grid. If it useful to show blender units in this direction, it is also useful to show them in other directions too sometimes. This patch allows you to turn on grids for any of the three dimensions. You can show two at a time or all three at once. This could also come in handy if you are used to a different direction being “up”.

Translucent floors. Normally the grid floor is just a bunch of lines, but this option allows you to show any floor as a solid translucent surface. You can adjust the transparency of these.

The following image shows a screenshot of the changes in action:
http://www.pasteall.org/pic/11329

The following link is to the diff, if you do your own compiling and want to give it a try:
http://www.pasteall.org/21036/diff

Harley

This Is great Harley! :slight_smile:
I also love the grid thingy you’ve got there. I’ve posted some ideas for the viewport a while back, maybe it could inspire you:

  1. Upgrade the visual stile, and some other little features for the 3D view. That is, for example:
    :diamonds: A gradient for the background
    :diamonds: Transparency for Wireframes, grid, etc.
    :diamonds: Highlighting objects/edges/verts/faces that you are about to select, so you know what you will select.
    :diamonds: “View axis (x,y,z) lock” on the header instead of “turntable/trackball” switch in the preferences
    :diamonds: Up vector selection
    :diamonds: X Y grids intstead of just Z
    :diamonds: AA switch in the preferences for the 3D view (for those guys with high end comps)
    :diamonds: Retopology visual improvements (Edges seen through other models, but backfaces aren’t visible)
    :diamonds: A textbox on the mouse showing what you type with the numpad when rotating, moving, whatever.
    :diamonds: Etc. etc… Anything you could think of to make the 3D view more awesome.

Not a very heavy on math kind of a project, so should be relatively easy.

Here are some examples of neat visual stiles for 3D view:
http://snj.main.jp/blog/wp-content/u...0127toilet.png
http://pub.ne.jp/fireman1/image/user/1239646153.jpg
http://garagarape.free.fr/takarabako/horse_retopo.jpg

Freemind,

> X Y grids instead of just Z

Actually it was your post that made me look into those grids. That change, on its own, makes a lot of sense so I submitted an official patch for that a couple of weeks ago:

http://projects.blender.org/tracker/index.php?func=detail&aid=26766&group_id=9&atid=127

I somehow doubt it will get approved though, but it is fun just experimenting some times.

Harley

Hi Harley. Nice experiments. I’ve just compiled a build with your patch.

There are some horizontal lines in the viewport. Is this normal?

Screenshot

Btw, here is the patched build for Win32

Click here.

DemoHero,

> There are some horizontal lines in the viewport. Is this normal?

No, I don’t see those on mine. I’m sure I’ve just done something dumb.

Those funny lines show up when you enable the Y axis line or the Y grid lines?

Harley

Those funny lines show up when you enable the Y axis line or the Y grid lines?
This is not about grid or axis lines. I only changed the background value. (Those green rectangles in the screenshot shows the thin grey lines.)

Btw, alpha color doesn’t work in this build or I don’t know how to use it.

Edit: My bad. alpha color works with grid floors.

DemoHero,

> This is not about grid or axis lines…

weird. I’ll look into that tonight. sounds interesting.

> Edit: My bad. alpha color works with grid floors.

Not your bad. I didn’t explain myself well or put any effort into the UI at all. Turning on a grid floor without changing the alpha from the default of zero shows no apparent change, nor changing the alpha without a floor showing. So you just turn on a floor and then set the alpha to some low value (like 0.05). Sorry for the confusion.

Harley

very impressive i would most certainly use it and many more would too , just a couple things, what is the performance hit, does it have sane defaults, like have blender default and is the OGL clean and elegant, as in it works on intel cards and the like.

If these are true, then certainly someone would commit the patch (I would but its not my area), put it on the tracker and send the link to the bf-commitors mailing list.

mfoxdogg,

> what is the performance hit?

The gradient background is a single quad aligned with the viewport, with different colors at the top and bottom vertices, so it shouldn’t be noticeable at all.

The translucent floors are each just big quads (4 per axis) in the same locations as the grid lines. They are displayed after everything else and use glPolygonOffset so they don’t z-fight with the grid lines. If you turn on all of them it is just 12 quads shown with alpha which shouldn’t have any noticeable performance hit.

> is the OGL clean and elegant, as in it works on intel cards and the like.

No idea really. I don’t have much experience with OpenGL so I just winged it. I was only trying to get it to work correctly on my own card, a crappy ATI Radion HD 5570.

> certainly someone would commit the patch…

The patch for just the multiple grid lines is in the patch tracker, and someone will probably notice and comment on it one of these days.

As for the gradient background, that is an extremely trivial thing so there is probably a very good reason why Blender doesn’t already do this.

The translucent floors are just eye candy. Although I like seeing it this way, it takes more than saying “it looks nice” to be accepted; it would have to improve things.

Harley

+10 for the gradient 3d view background, something I wanted for a long time. I compile blender on my own, could you make a diff for just the gradient background ? the else I dont see any use for.

can I take 506
static void DrawGradientBackground(View3D *v3d)

function only to use gradient background?

uhm

I think this should be added to the trunk.

The gradient might be of visual quality only while I like it
but I think the grid options are very very useful for work.

Great Stuff Man

aermartin,

The part that draws it is …/editors/space_view3d/view3d_draw.c:


static void DrawGradientBackground(View3D *v3d)
{
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glShadeModel(GL_SMOOTH);

    glDisable(GL_LIGHTING);
    glBegin(GL_QUADS);
    UI_ThemeColorShade(TH_BACK, (0-v3d->gradientbackgroundcontrast));
    glVertex2f(-1.0,-1.0);
    glVertex2f(1.0,-1.0);
    UI_ThemeColorShade(TH_BACK, v3d->gradientbackgroundcontrast);
    glVertex2f(1.0, 1.0);
    glVertex2f(-1.0, 1.0);
    glEnd();

    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    glShadeModel(GL_FLAT);
}

But it is using variables defined elsewhere for the top and bottom colors. You could replace those with hardcoded amounts in place of “v3d->gradientbackgroundcontrast”.

Further down inside function “view3d_main_area_draw” you have to call it just after the first glClear. You only want to call it if it is in perspective mode though so you do this:


if(rv3d->view==0 || rv3d->persp != RV3D_ORTHO) {
        DrawGradientBackground(v3d);
}

I could make you a patch for just this if you want though. That way you would get changes to makesrna, makesdna, and the python ui code.

Harley

aermartin,

Hmmnm… I remembered your other threads about UI themes and colors, etc. In my DrawGradientBackground you will notice there is a line like “UI_ThemeColorShade…” followed by two vertices, then another UI_ThemeColorShade, then two more vertices.

UI_ThemeColorShade is getting the background color (TH_BACK) from your preferences. The number after that is an offset from that color. It is just added to the system color to make it lighter, or darker if the number is negative. I’m just using one value but using the negative value for the second color.

Anyway, if you were going to play around an make your own gradient, you could change those lines to this instead:


glColor3f(1,1,1);
glVertex2f(-1.0,-1.0);
glColor3f(1,1,1);
glVertex2f(1.0,-1.0);
glColor3f(1,1,1);
glVertex2f(1.0, 1.0);
glColor3f(1,1,1);
glVertex2f(-1.0, 1.0);

Now you have a custom color for each corner of the background quad. In the code above each vertex is going to be colored white, glColor3f(1,1,1), but you just change each 1,1,1 to something else. Red, Green, then Blue values between 0 and 1.

So my gradient was just different shades of the system background color in a simple vertical gradient. You can make one that uses different colors for each corner and you can get some pretty funky effects.

Have fun.

Harley

Do you think you could add an option so that the colors used in the built in sky gradients when being used can be seen in the 3D view as well when pressed (linking the RNA color values in the sky panel to your gradient options)?

For BI users, this would be useful to preview the sky background before rendering as the renderer doesn’t actually use it as a wrap-around shader and instead uses it as a backdrop.

+1

These tweaks look slick

Ace,

That’s certainly possible, but…

Most people that have mentioned wanting a gradient background want it because they’d like to model (or sculpt) with that as the background. In this case the background would not change at all when you look up or down; it remains the same.

That’s quite different from trying to match the background when the scene is rendered. In that case you’d want it to change when you look up, down, or pan around.

I think what we both want is an option to select “plain”, “gradient”, or “environment” as the background. Gradient would be nice for modeling, but selecting “environment” would be so nice when you are using sun/sky, an HDRI, etc.

Harley

ooh add me to the list of people who’d love a gradient viewport option and alpha settings for edges make it into the trunk! :slight_smile:

thanks Harley for these experiments!

Harley, When if you want to quote, there is a button in the toolbox to make text a quote: [QUOTE*]Text[/QUOTE] (delete the star) or you can write this manually. It’s cleaner this way.

And thanks again for the effort.

Just make sure your code is clean and it will surely reach trunk.

Nice work!

when all 3 planes are visible it can look a little messy.

What’d be a cool feature is fading the grids as they become perpendicular to the view … maybe multiply the alpha for grid floor and grid lines by dot product of grid normal and view vector?

and/or you could get some depth cue-ing on the grid lines? (blend a color based on zdepth )

Actually I’d love that for all wireframes really!
Already very cool though!

+1 for this patch, it looks nice and useful!