Sunday, February 1, 2015

DevArt - Graphics Glitches can be Pretty...

One of the things I love about doing graphics development is that sometimes, your code stuff-ups can have some very pretty results that you wouldn't have imagined... Today, I ran into one of these, and decided to capture it for all to see! Enjoy :)

After capturing the screencast featured in that video (using Blender's built-in screencast feature; it's main limitation though is that it is limited to 10fps and also limited output formats, and has no audio), I decided to try sticking some titles on it. One thing led to another, and soon I was digging up some of the recordings of me randomly thumping a piano - lo and behold, this track seemed to fit quite nicely!

As this was re-rendered through Blender's sequencer, I did once again run into problems with those blasted FFMPEG encoding settings panels! Aarrggh! Those things are awful! I don't want, need, nor care what bitrate or min/max bounds apply on that, or of the whole container/codecs issue... Just give me a bloody "quality" slider + some presets for outputting to common output formats (which have been tested to work well with common setups), and let the other specialist tools deal with all the other cases! Anyways, here's the raw video, which doesn't suffer from some of the ghosting artifacts!


Oh, and in case anyone is curious to have a play around with these glitches, here is a patch against 3f5771475d55ed981bd98ee5810e62b68bccbb38:

diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 895fc66..35ed92d 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -35,6 +35,8 @@

+#include "MEM_guardedalloc.h"
#include "BLI_sys_types.h"

#include "BLI_math.h"
@@ -325,6 +327,44 @@ static void gp_draw_stroke_volumetric_3d(bGPDspoint *points, int totpoints, shor

/* --------------- Stroke Fills ----------------- */

+/* draw fills for 3D strokes */
+static void gp_draw_stroke_fill_3d(bGPDspoint *points, int totpoints, short sflag,
+ int offsx, int offsy, int winx, int winy)
+ bGPDspoint *pt;
+ int i;
+ int (*spoints)[2] = MEM_mallocN(sizeof(*spoints) * totpoints, __func__);
+ float modelview[4][4], imat[4][4];
+ BLI_assert(totpoints >= 3);
+ /* get modelview matrix (to get into "screen-aligned" space) */
+ glGetFloatv(GL_MODELVIEW_MATRIX, (float *)modelview);
+ invert_m4_m4(imat, modelview);
+ /* project 3D points to 2D coordinates in screenspace... */
+ for (i = 0, pt = points; i < totpoints; i++, pt++) { + float sco[3]; /* screen-space coordinates */ + + mul_v3_m4v3(sco, imat, &pt->x);
+ spoints[i][0] = (int)sco[0];
+ spoints[i][1] = (int)sco[1];
+ }
+ // XXX: double check that this works
+ /* plot these new points in 2D */
+ glBegin(GL_POLYGON);
+ for (i = 0; i < totpoints; i++) { + glVertex2iv(spoints[i]); + } + glEnd(); + + /* cleanup */ + MEM_freeN(spoints); +} + /* draw fills for shapes */ static void gp_draw_stroke_fill(bGPDspoint *points, int totpoints, short UNUSED(thickness), short UNUSED(dflag), short sflag, @@ -335,6 +375,11 @@ static void gp_draw_stroke_fill(bGPDspoint *points, int totpoints, short UNUSED( BLI_assert(totpoints >= 3);

+ if (G.debug_value == 1) {
+ gp_draw_stroke_fill_3d(points, totpoints, sflag, offsx, offsy, winx, winy);
+ return;
+ }
/* As an initial implementation, we use the OpenGL filled polygon drawing
* here since it's the easiest option to implement for this case. It does
* come with limitations (notably for concave shapes), though it shouldn't

No comments:

Post a Comment