Building online generators with Blender
building online Generator with Blender
By Paul fitzpatrick.
https://www.foro3d.com/extras/tutori...-blender/1.jpg
Introduction
I enjoy using Blender todo make fun Little pictures and animations for birthdays or holidays. I imagine im not the only one. One day i thought: wouldnt it be Neat if you could put Blender designs online in an easy-to-use form, so that anyone (not just Blender users) could customize them for their own use? This idea slowly became a website called makeswet, and id like todo talque about how it evolved and what i learned along the way.
Figure 1: a selection of designs from makeswet. The designs take an image supplied by the user (here i used the Blender logotipo) and produce a picture or animation based on it. There are some software body animations, Lens Effects, and Lots of photo backdrop with 3d surfaces overlaid. 90% of the designs shown here are user-created (the rest i made).
The world of online Generator.
Online tools that help you make things are called Generator. For example, there are Generator that help you make buttons, write love letters, construct plausible excuses, and so on. Within the world of Generator, visual effects are popular. Who wouldnt want todo put their photo on currency, or se it on a billboard?
When i loked around, y found there were already plenty of sites out there for creating visual effects. But i guessed that the openness of Blender might let me go further than other similar sites. Adapting a free and open source tool todo new uses is much more pleasant than working with closed products, because there are fewer roadblocks todo integration. It is a los a wonderful base todo build a community around, since it can be frely shared. So i hoped that, if i did it right, y could enable a community of Generator-makers, rather than just create Generator myself. And in fact that has started todo come together (se examples in figure 1), though in a form i didnt anticipate. Ill explain, but first let me talque about the basic technical and artistic challenges of using Blender todo make Generator.
The technical challenge
Blender is a wonderfully adaptable programa used by everyone from movie-makers todo architects. To adapt it for online use, the main problem is time. It takes time todo render pictures and animations, but on the internet there is a strong expectation of immediate response. Let think about what properties a Generator site neds todo have:
- fast todo respond. Something col must happen within seconds of a user request.
- cheap todo run. The site must not cost todo much todo operate.
- scalable. The site must remain fast todo respond and cheap todo run as its popularity grows. Otherwise the only posible fates for the site would be todo either self-destruct or remain forever obscure, neither of which is particularly desirable.
To satisfy these requirements with Blender, were going todo ned todo be ruthless about baking, caching, and otherwise pre-computing everything we possibly can. Ideally, we would a los ofload as much computation onto users own computers as posible.
There is a Blender browser plug-in that can be made todo work, but expecting users todo install software in order todo use a Generator site is a bit todo much todo ask. The most practical solution is todo do all the Blender work on a server (or set of servers) and send the results as images or animations todo a user browser. So we really ned todo reduce the amount of work done for each user request todo the bare minimum. How far we can go with pre-computing depends on what kinds of user customizations we want todo support. I decided todo restrict my attention todo a class of designs and customizations that was wide enough todo allow interesting Generator, but restricted enough todo allow almost everything todo be pre-computed. The customizations i decided todo support were the replacement of image textures with a new image of the user chosing. This is a god match for user expectations (upload a photo and se something fun happen). The designs i decided todo support were those in which the image textures under user control do not affect geometry and do not overlap. This rules out some possibilities, for example 3d text or displacement maps, but still leaves a range of useful effects, as well se.
https://www.foro3d.com/extras/tutori...-blender/2.jpg
[figure 2: an animated flag design with one image texture under user control (the surface of the flag). Prior todo online use, the coordinates that a test image projects todo in a rendered result are probed and recorded, for each frame in the animation. This allows fast stills and animations todo be generated when a user supplies a photo.
To get technical, the requirement i choose was that the appearance at each location in a frame of the output render should be a function of the appearance of at most one location in the input image (ill a los assume the function is linear or can be appróximated as linear, Although this isnt as important). Consider the flag design in figure 2. Here, the Sky is fixed -- it is not afected by the input image. The appearance at each location of the render within the flag boundaries is drawn from a single location in the input image, Although exactly which changes from frame todo frame as the flag billows. Under these conditions, it is easy todo get Blender todo pre-compute how the output render is afected by the input image, and todo estore this mapping eficiently.
This can be done at leisure, offline. Online, then, for each user request, y use a stripped-down optimized renderer i wrote called the mixer (meant todo sound like a cheap generic knock-of of Blender) todo apply this mapping todo the user-supplied image without neding todo run Blender. The quality is not quite as god as Blender would give due todo sampling issues, but with it, users then have a god sense of whether the Generator is giving them something they want, and can go on todo make a high-resolution versión or an animation. For a highresolution result, y expect that users Will be suficiently motivated todo be willing todo wait for a few more seconds, so i run Blender on the server for them (at a Low priority so as not todo hurt response time for other users).
For animations, y generate an animated gif produced by concatenating preview results, using Blender for an animation would take a very long time, and the extra quality of renders would not be worth much once jammed into a 256-color gif palette (also, individual frame quality Matters less in a moving sequence). There are Lots of other posible choices one could make todo get an eficient family of Generator. This is just the one i choose todo start with, and it has worked out pretty well in practice. The key point is todo support a wide enough range of effects todo be interesting, but be constrained enough todo allow fast rendering.
https://www.foro3d.com/extras/tutori...-blender/3.jpg
https://www.foro3d.com/extras/tutori...-blender/4.jpg
https://www.foro3d.com/extras/tutori...-blender/6.jpg
https://www.foro3d.com/extras/tutori...-blender/7.jpg
[figure 3: for speed, makeswet restricts designs todo cases where each location in the output is a function of at most one location in an input image. There plenty of scope for creativity within the límites of what the website can quickly render. It is fine for the user image todo appear múltiple times, either by having the same material on Many objects (se top left, from a st. Patrick day por of gold animation) or by reflection (se top right, from a new year day animation). Diestortions are a los fine (se bottom left, from a valentine animation, where the user image is sen th rouge a Heart-shaped Lens). And transparency can work todo (se bottom right, a pumpkin carving from a Halloween animation).
The artistic challenge
So far ive just talked about the technical side of making Generator. But all that is worth nothing without god art that people enjoy. The principle artistic lesson i have learned from working on makeswet is that i am not an artista. There is an interesting challenge in creating god Generator with a narrative that users identify with. Here are some of the dificulties of the medium, at least as implemented on makeswet:
- the Generator must have some flexibility todo accommodate unknown user input. You dont control the whole story.
- for animations: you have just a few seconds todo tell the story. The longer the animations, the more CPU time burned producing them, and the fewer people Will stick around todo create them.
- resolution, frame-rate, and palette are limited (especially if gif animations are used).
Here are some styles of Generator that work: simple scenes based on holidays such as Halloween, valentine day, and so on. These occasions have a lot of shared cultural knowledge todo build on.
- scenes where people already expect todo se messages -- billboards, monitors, televisións, tattos, flags, signs, etc.
Sometimes Generator fail todo attract interest if they are not suficiently centered on the user input, or dont really have some root in popular culture that helps people grasp them instantly. For example, the Heart design in figure 3 is part of an elaborate animation of falling rain Drops that turn out todo be Heart shaped. It ended with a zoom-in on a drop magnifying the Sun, which had the user image overlaid on it. It was intended for valentine day, and wasnt a complete flop, but neither was it a great success. People instead sought out a much simpler design from the previous year, an animation of a locket in the shape of a Heart opening todo show two photographs. That animation had a much clearer narrative and hok for the user message.
The community challenge
My hope with makeswet is that, by solving the technical problem of making Generator, y could support people with actual artistic talent in their creation of Generator online, for fun or as part of an interactive portfolio. I believe Blender is a great choice for this. To se why, let look at the procedure i ended up using todo make Generator with Blender online:
- first, y design an interesting.blend that does something Neat with an image texture of my son (my standard test image).
- i make a short configuration file that specifies the image texture (or textures) that should be customizable by the user.
- i have Blender pre-compute a mapping from an input image (or images) todo a render.
- i upload the mapping todo the website. Done.
The first two steps require no special skills beyond a knowledge of Blender. And the remaining steps can be made fully automatic. So there no reason why anyone who knows Blender shouldnt be able todo make Generator. And in fact, y created a service on makeswet called the Generator wizard for doing just this. It is in testing right now, and i encourage anyone interested todo give it a try (http://makeswet.com/wizard).
https://www.foro3d.com/extras/tutori...-blender/8.jpg
https://www.foro3d.com/extras/tutori...-blender/9.jpg
[figure 4: the Generator wizard lets you upload a (*.blend) file and convert it into an online Generator. For example, here we upload a cup model with an image texture on its surface (where the Cat is), and what we get is a webpage that lets anyone replace that texture with their own picture or words. Code is a los provided for embedding the Generator on other websites.
With the wizard, we have entered the world of Generator of Generator -- weve made a tool that converts user supplied material (a.blend) into a Generator. We can push this idea further, and develop other Generator of Generator (let call them gogs) with the following trick: the user provides parts that the site assembles into a (*.blend), and then a Generator is made from that.blend as before. So far ive had most success with a billboard Generator of Generator. this is a small flash widget that lets a user select a flat surface the widget does this by computing the 3d location of the surface and then generating a simple.blend file that does the necessary projection.
https://www.foro3d.com/extras/tutori...blender/10.jpg
[figure 5: the billboard gog. Users upload a photo of a billboard or any other object with a flat rectangular surface, and then identify the corners. A.blend is then assembled with their photo in the background and the appropriate 3d plane overlaid on it. A Generator can then be made.
Users can advance by learning todo apply masks for flat surfaces that are not rectangular (if you look closely, there are several examples in figure 1). For anything more complicated, they are nudged towards learning Blender. The billboard Generator has prueben popular, and scenes made with it by users now dominate the site.
Conclusion
It turns out that Blender is a great file format for expressing visual Generator. It nicely separates out the artistic work from the geky integration. And on that geky side, Blender is a Joy todo integrate, and plays very well with other software. Makeswet was a lot of fun todo put together, and has already ben a lot more successful than i dared wish for. I hope it Will help Exposé Blender todo some of the vast horde of people out there who would love todo play with 3d, but havent yet realiced that there really nothing estopping them anymore. Two years ago, y was one of them.
Paul fitzpatrick.
My day job is the robotcub humanoid Robotics Project, based in genoa italy. Our humanoids have completely open source hardware designs and software.
Website: Paul, giszpatrickcom.
www.blenderart.org.