Der Schmale – David Lenaerts’s blog

Flash Platform Experiments

One year later: a short retrospective

Tags: , , ,

birthdaypieThe first post on this blog dates from May 4th, 2008, so I thought it fitting to look back at the year that has passed since then.

Over the time I’ve done some experiments/projects that, when I look back at them, make me think “What was I thinking?!”. On the other hand, there are luckily a few of which I’m actually proud, or at least content with how they turned out – whether they were practically useful or not (which is not exactly always my goal). A lot of the things I did, I did as a way to learn. As such there was Wick3d, a (now defunct) basic 3d engine to rehash my algebra (actually, I worked on it some more after the last update without comitting anything to svn). And of course Pixel Bender came along, giving me a whole new area to explore, as did Alchemy.

I do feel I learned quite a bit, but at the same time it seems with everything I learn, there’s twice as much I still need to study. Feels like a constant battle against ineptitude, especially when talking to those who actually seem to know what they’re talking about ;)

Lastly, I’d like to pass some more updates on Farbe. I recently made some updates implementing oil paint and airbrush. There’s still so much work to do before it can go public, but soon it will be time to look for a Flex UI-designer/skin artist. If you know or are anyone with experience, send me a hoot with some examples! AS3/MXML/CSS experience is a must of course :) Just keep in mind, the project is free and will likely be open-sourced eventually (which is also a cheap way of saying: no money involved ;) ). If you follow me on Twitter, you might have seen some demo pictures being tweeted. Those that haven’t: here’s some previews of Farbe simulating pencils (1, 2), oil paint and airbrush.

Off towards another year! Thanks to all you readers!

Leave a comment (4 comments)

Status update on Wick3d

Tags: , ,

This blog’s been a bit silent the past couple of weeks, but I haven’t been idling at all – quite the opposite. Even with fresh copies of Dead Space, Fable 2 and Fallout 3 laying too near for comfort, most of my free time has been taken up by Wick3d (1 | 2). Recent developments in Papervision3D and Away3D (the choices for commercial-grade Flash 3D) only made me more excited to do some extra studying and experimentation. Just to clear things out now – there won’t be any demos in this post, but I will mention what I’ve been working on, and hope to merge with the Wick3d repository sooner than later :)

  • Lighting/Shaders: The old Wick3d (before I started over, that is) had some basic support already, but shading is going to make an improved reentrance.
  • Correct Z-Sorting: a tricky one. Since a stencil (z-)buffer isn’t an option in Flash, the only way I know how to sort triangles correctly is the Newell-Newell-Sancha algorithm (an extension to the simple painter’s algorithm). However, since it’s an O(n²) algorithm it can slow down to a crawl rapidly with enough triangles. Organizing the triangles in a quadtree (similar to PV3D’s latest addition) could improve performance, but still – per quad – there’s the n² issue. I’m sure there’s better ways to solve this problem and I’ll keep up the research. Any tips on this subject would be most welcome, of course :D
  • Working with the BSPRenderPipeline has been reworked and now supports dynamic objects moving about in the BSP tree (this one’s actually done, but not comitted to the trunk yet - check out the dev branch if you’re feeling brave :)  ). Create a BSPWorld3D instead of a World3D, passing the static base to the constructor, and add dynamic children with addChildren as usual. A demo with source will follow soon, with some luck.
  • Redone Collada support. It’s still very basic, no hierarchy, but parsing is much faster. It will be improved whenever needed. Parsing files is not my preferred pass-time, so I tend to keep it at this point until I personally need more support.
  • Restructuring of certain parts of the engine. For example, Rasterizers are now classes on their own, so different types can be used in any render pipeline.
  • Various optimizations and trivial updates.
  • Thinking about FP10 and how I could harness the power of drawTriangles when dealing with (virtually) a polygon soup. I guess you’d still be drawing every triangle separately without sharing the vertices.

Heh, at least I’m not slacking off! ;) It might take a while before these updates are comitted to the main trunk, so I thought I’d give this rundown of things to come – hopefully! Any brilliant insights? Let me know :D

Leave a comment (7 comments)

Wick3d update: BSP sorting

Tags: , ,

After some developments in Papervision3D and Alternativa3D, I decided to try to tackle BSP sorting myself (yeah yeah, months after everyone else did :p). It gets rid of those typical annoying z-sorting anomalies, and allows for intersecting objects to be rendered flawlessly. However, due to the cpu-intensity of building the initial bsp tree, it can only be applied on static scenes. I haven’t yet built in support for movable or animated objects inside the 3D world. The current implementation will probably change a lot, but as this is mainly a self-study project, it’ll do for now ;)

Check out the demo, and check the source. The cubes are generated randomly, so performance may vary from time to time, due to the BSP tree. But note how, even tho intersecting, all triangles are rendered in the correct order. And please, forgive the uglyness of the demo. The Wick3d source can still be found on Google Code.

The past few weeks have also seen some bugfixes (the matrix invert function was warped causing the camera to behave oddly) and some refactors. And more importantly, there now is a DisplayObjectMaterial which is interactive. It’s probably very buggy tho, I haven’t had time to test it thoroughly, and it’s not one of my favourite aspects of a 3D engine (creating it, that is, I love using it ;) ).

Finally, I recently got back from Flash on the Beach ‘08 (thanks to Nascom for sending us). Because Sakri already wrote a pretty accurate article on the time we had there, just check out his post at the Nascom blog. We had a great time, and some good opportunities to chat and have beers with some flash heroes and like-minded people. Needless to say, I came home stoked and full of inspiration!

Leave a comment (1 comment)

On an unrelated note… (and some updates)

Tags: , , ,

I always told myself not to post anything unrelated to Actionscript or music, but this time I’ll just have to make an exception to that rule, because I’d like to introduce two new inhabitants of my apartment. Meet Flash and Bundy, the two feline hellraisers that have taken up residence with me and, in the process, are well on their way of destroying every single thing I own ;) (Pictures below)

Cats aside, I’ve been working regularly on Wick3d since I got back from holidays and I hope I can post some interesting stuff soon. So keep an eye out for it :)

And while I’m updating, I might as well start plugging. Check out one of Nascom’s recent projects, for which I had to do the particle stream in the background: www.fullhd.be. Fun times :D

Leave a comment (3 comments)

Wick3d source available + MD2 animated model demo

Tags: , , ,

Aah, finally :) I’ve been spending a large part of my free time working on Wick3d, and I’ve arrived to the point where I wouldn’t mind people looking at the source (link at the bottom of the post). I’ve said it before, and I’ll say it again: looking at it and experimenting with it is encouraged, but actually using it for a project is looking for trouble – it’s in no state to be used as such ;) My to do list just keeps on growing, but at least there’s some useful functionality.

Main things updated:

  • Major performance boost and improvement in render pipeline flow.
  • Very basic Collada support (only single objects, no hierarchic structures; buggy).
  • Animated MD2 mesh support (Quake 2 models, etc.)
  • Improved transformations: Support for Euler angles (yaw/pitch/roll), lookAt, camera target …
  • (Animated) DisplayObjectMaterial
  • Added more Primitive models

Some things you’ll find in the source aren’t used (yet), and some things might be refactored completely. Feel free to drop requests or remarks, I can always use a reason or tips to work on it ;)

Also linked below is a demonstration of the MD2 animated model support (MD2 is the file format used by f.e. Quake II). The model might take a bit to load, but it’ll show up eventually :)

To close off, I’ll be abroad for 2 weeks in a few days, so it might take long for comments to get approved.

Enjoy!

Leave a comment (6 comments)

Wick3d from scratch

Tags: , ,

After some books finally arrived by mail, I’ve been spending the past two weeks reading up on 3D maths. Being unhappy with how my playground engine Wick3d was evolving (bad code flow resulting in poor maintainability being the worst of it), I decided to put some of this newly acquired knowledge to practice and redo the engine from scratch. Perhaps the biggest structural improvement would be that the operations such as transformations, culling, drawing, etc… are now being executed from a centralized render pipeline. Furthermore, some other things are done more correctly. For instance, the render target is now a viewport and the camera works with field of view instead of some random zoom factor. The latest addition is a rudimentary clipper, which clips triangles intersecting the projection plane so they don’t just disappear when they’re too close. Regretfully, it doesn’t look too great yet (I have linear texture mapping to thank for that). The shading that was in the previous version hasn’t been reinserted, and it will probably be a while. There’s still plenty of other things that I want to realise before I get back to that.

The code still isn’t available yet, mainly since the code’s not entirely the way I’d like it. In any case, this project is just a study case for me. But who knows what the future might bring ;)

Check the demo if you feel bored, move around the mouse a bit and use the mouse wheel to change the field of view (and notice how fast it starts to look ugly).

Leave a comment (3 comments)

Phong shading (in progress) in AS3

Tags: , , ,

The past week, I’ve mainly spent trying to figure out how to do (fake) Phong shading and environment mapping. In the case of phong, the result can be seen here. A few alternatives that I tried didn’t work out, but after some quick hints from Ralph and lots of calculations, I found a solution that more or less works (at least for me ;) ). Weirdly enough, most of my time went into figuring out how not to show the lighting on the opposite side of the lit object (it’s a normal effect since this shading technique borrows from environment mapping). As you might notice, it’s still not quite right…

In the demo, you can see more or less the same cube and sphere from the Gouraud post. The uv-mapping is still off on the seem where the two horizontal ends of the texture (should) connect, but at least now I know why :) The texture “wraps back” because the U-coordinates are on opposite sides of the texture. I’ll have to figure out how to fix it… If it looks like a familiar problem, any suggestions are welcome :)

Next task: heavy duty optimization and refactoring! Good times :D

Leave a comment (8 comments)

wick3d introduction + Gouraud shading

Tags: , , ,

Since some time, I’ve been working (off and on, and more off than on) on a rudimentary 3D engine in ActionScript 3, code name Wick3d (hah, I know, rediculous!). Not to become the next Papervision, since there are plenty of engines doing a much better job (just check Papervision, Away3D, Sandy or Alternativa3D and keep a tissue close in case of droolage). Anyway, I’m just interested in 3D algebra and whenever I see something cool, I want to know how it works, and if it results in stuff like this, I’m having tons of fun as well :)

It’s surprisingly easy to get messy code while adding functionalities, so I had to start from scratch a couple of times. I also had to throw out some work such as coloured light sources, which were killing cpu when used with textures, and to be honest, no one really wants to use untextured objects so I might as well streamline it to be the same for all types of surfaces. This weekend, I reworked the lighting calculations according to Lambert’s cosine law for diffuse lighting and added support for specular highlights. Finally, I also added a Gouraud shader (I have to admit I had a grin on my face when it finally worked). Basically, it’s using a linear gradient image map and defining uv-coordinates on it based on the lighting per vertex normal. After that, it’s drawn the same as any affine texture map.

The code is not public (yet), coz it really needs a lot of cleaning up, and well… It can’t do much right now (apart from creating cubes and spheres). Of course, if there’s people who want to look at it out of interest, I can always clean up the mess I made in there and put it online.

Check the demo if you want, as you can see the frame rate isn’t all that high :( And apart from that, something is wrong with my UV-mapping. I’m not sure if it’s an error in the texture mapping or the calculations for the spherical coordinates (I suspect the latter…).

Leave a comment (1 comment)

© 2009 Der Schmale – David Lenaerts’s blog. All Rights Reserved.

This blog is powered by Wordpress and Magatheme by Bryan Helmig.