Friday, August 21, 2009

Fisheye lens distortion using MOSAIC and Aqsis

Greetings again Blender heads and RenderMan junkies :)

Well I've been hard at work with MOSAIC and recently needed a good test case for the volume shader I'm currently working on. It just so happened at that moment someone over at BlenderArtists inquired about lens distortion so I decided to do a test project and developer blog demonstrating lens distortion but also testing several area of MOSAIC. I've been asked to copy that blog to share with all the good people here also....


From the original developer blog here http://sourceforge.net/apps/wordpress/ribmosaic/

I've recently had someone at BlenderArtists ask whether MOSAIC could do lens distortions. Well since that's not a standard feature of Blender I have no built-in solution for this, however knowing this could be done I figured I'd tell him that RenderMan could do it easy and MOSAIC can set it up. As I was writing the reply I realized that I hadn't actually tried this myself and I'm currently needing an good project to test the new volume shader so... thus was born this fisheye project :) This post is not intended as a tutorial but just an overview of how I achieved this effect, I'll also include the blend if anyone wants to play with it.

Well the first thing I did of course is look around for examples of techniques, and as it so often turns out there's several different ways to do this. If looking for just mild image distortion/displacement then the simplest solution is to just use an image shader to process the image (the same as the post process filter in Blender's compositor). If looking for something more extreme such as the 360 degree fisheye effect then more radical steps are required. One approach is to use a warped plane in front of the camera and use raytracing with the surface normal refraction to fake the lens effect. Another technique, which I prefer, is to render the camera as a cube map in separate passes and then combine the maps into an empty beauty pass with an image shader. This approach can see distortions all the way around the camera, has fine tuned control over image quality and camera rotations and lens distortion and can even be animated with the same maps as long as camera translation doesn't change!

I found several example shaders but was surprised to find one written by my friend Chris Foster in the Aqsis example folder! I only made a few small changes to the shader for creative control:

  • I added a rather wide filter to the lens mask to blur its edge

  • I added the ability to flatten the distortion so the lensing effect can be pulled in and out of

  • I added the ability to rotate the forward vector in the cube lookup on x,y and z axises


The idea behind this technique is simple: use a cube map pass from the camera's position to generate cube faces, then in the beauty pass lookup into the cube faces with the image shader to project the warped perspective on the frame. The first step is to build a standard scene, I decided to use checker displacements on a ground plane and columns around the camera to emphasize the effect. I also decided to test faked soft shadows in a larger more complex space and also to include my partially rewritten volume shader to produce more daigonal light streaks for effect (the finished shader will be included in next CVS update). Next I added the fisheye image shader and created a shader fragment.

First off there's several tricks I had to play on the beauty pass:

  • Enable an empty scene layer. This is so nothing is rendererd except the image shader otherwise you'll waste time rendering object not seen.

  • Create and select a RIBset on the camera with the fisheye shader enabled. This is so the beauty uses the fisheye shader but we can force the default RIBset with no fisheye effect for other passes.


Next I created a User Autopass to use as the cube renders with a few filter options applied:

  • Blank the "Layers Scene:" filter. This is so we can specify what layers to use in this pass, otherwise it will use the beauty's empty layer.

  • Set "RIBset Bypass:" to DEFAULT. This makes sure the camera used from the beauty pass is not using the fisheye lens.


An autopass is necessary instead of just using a global env pass because better filtering can be achieved in Aqsis using textures then an env map. In this custom pass I made several custom scene RIBset's named as numbers from 0000 to 0005. Then I set this pass in the Project tab to use "RIBSETPASSES" so MOSAIC will export the numbered RIBset's as separate passes and ignore the DEFAULT RIBset. This is so I can use the same scene setup for each cube perspective. Then for each RIBset I used the "Show Autopass Settings" to setup the following:

  • For each RIBset I use one of each of the cube Camera: Perspectives (Object: nx, Object: px, Object: ny, Object: py, Object: nz, Object: pz). I use the Object instead of World perspectives so the cube faces are relative to the cameras orientation.

  • Setup each "file" display to point to ./Maps/ and use the name of each cube face, as "ny.tif", "py.tif" ect.

  • Setup the "Texture" dialog to convert each file display tif into mipmapped tex, as "ny.tif" - "ny.tex"ect. This is not strictly necessary but produces much better results with the image shader ;)


So at this point what's happening is the user autopass is exporting each RIBset using the active camera from the beauty scene with one of each cube face directions and optimizing them into one of 6 images. Now all that has to do done is pull up the fisheye shader in the shader editor and put in each of the images from the cube pass and adjust "thetaMax" to the distortion angle and render the beauty pass.

However since the cube faces can be reused in a simple rotational animation with minimal render time I decided to take things further and do a 20 second animation. Also since the cube faces are static I decided to try really high quality occlusion maps, shadow map with faked soft shadows, DOF and volume atmosphere shading. This is because the addition time needed to calculate these passes on the first frame are more then made up for by the really fast render times of the animation in the imager pass (it only has to grab the cube faces and calculate lookup direction and lensing). I also thought it would be interesting to synchronize settings across the pipeline from Blender to MOSAIC by adding animated composting effects and by using the same camera controls to drive multiple shader parameters in MOSAIC. In particular I'm animating the "lens" control on the camera and hooking that to the thetaMax shader control but also grabbing the same lens data and modifying it in a python token to control the lens distortion parameter and finally using the frame count in another python token to feed y axis rotation in the cube lookup. As a finishing touch I've animated a spectral lens distortion effect in Blender's compositor, this could fairly easily be done in the image shader but this gave me a chance to try sychronizing animation in Blender's compositor with RenderMan :) Anyway Here's the video, project file and a few frames of the animation from my gallery...

Here's the youTube video...


Here's a direct download of the mp4...
http://www.dreamscapearts.com/Public/fisheye.mp4

Here's a frame at 100 degree lens at 0 degrees rotation...


Here's a frame at 200 degree lens at 90 degrees rotation...


Here's a frame at 360 degree lens at 180 degrees rotation...


Here's a frame at 360 degree lens at 180 degrees rotation...


And if anybody want's to play with the blend here it is too.
NOTE: I embedded a modified version of MOSAIC that includes the Object:py-nz camera perspecitves that is not in CVS yet so you'll need to run MOSAIC from the text editor!!
http://www.dreamscapearts.com/Public/fisheye.blend

That's it, thanks for reading :)
Eric Back (WHiTeRaBBiT)

Tuesday, July 21, 2009

SIGGRAPH 2009




I decided that with 2 weeks until this years SIGGRAPH convention that I should make a post about some of the behind the scenes talks between myself and the Animux devs. Since a lot of Blender to RenderMan integration has been done on the Animux distro, Mark Puttnam (the founder of Animux) has asked for some screencasts and imagery so that he can show this during his presentation.

So I decided that instead of just showing off normal screenshots of the default Blender startup screen, why not show something with some punch to it? Such as the one below, a simple test render done for Project Widow in early June.




So the idea is to setup and render at least static frames of Project Widow, if not maybe 10 seconds of animation of the spider, the tunnel system and the train. This not only would be the first official test of the pipeline, it will also serve as a small technical demo for the SIGGRAPH presentation. Most likely this preview will not end up in the final production short, much like Pixar did for the first Finding Nemo trailer. What this will do is not only draw attention to Project Widow itself, it will also draw attention to the whole Blender to RenderMan idea. SIGGRAPH has traditionally been the place to present "proof of concept" ideas and papers, showcasing new technologies and amazing artwork. So it only makes sense that after years of pain staking work trying to get where we are now that we at least begin to present our efforts at the biggest CG event in the industry.

The downside is that I am not able to attend this, I cannot afford it. I am not upset though since what we are showcasing is more of how Blender to RenderMan works with one OS - Animux, rather than how it can work for everyone. It just so happens that Animux is delivering us to SIGGRAPH. We could not ask for more publicity than SIGGRAPH anyway. If anyone does manage to get to New Orleans this year, please stop by the Animux Birds of a Feather meeting, take pictures too!

Monday, 3 August

Animux: Free Software for Animators
Animux is an absolutely FREE animation toolset that is used to handle all the tasks of pre-production, production, and post-production stages of a high-quality animation project.

Monday, 11 am - 1 pm
Ernest N. Morial Convention Center
Room 264
Mark Puttnam

Wednesday, June 03, 2009

The ball starts rolling

Since the last post there has been quite a bit of activity on the net in relation to the Blender to RenderMan projects, chatter on websites and our group has seen a very large increase of posts. Seems that we are bigger than we thought, that our collective efforts are starting to get noticed and paying off. I for one can say that I have underestimated the effect and reach this website has. So I am taking this time to inform people some of the things that are going on around the world.








Animux
http://www.animux.org

This is a newer Linux distribution that I only recently found, why I only just found it I can't say, however from what I have seen on the website this seems to be much like my idea of having a Blender to Renderman Linux distro. Not only is this available NOW but they have been following this site. This is right up our alley! This is exactly what we've been trying to influence! Best part is that I don't have to do the hard part as I have never even tried to make my own Linux distro and I wouldn't know where to start. This is here now and only getting better.

So.... I am making an unofficial statement of which Animux would be considered as the Blender to RenderMan "primary" Linux distro. The reason is that they have established quite a bit to make it workable for artists and TD's alike, for all skill levels not just the Linux guru's. That was one of the main issues I felt was important. They also have quite a roster of people that are either developing it or advising, some of these people are very important to the success of the open source 3D movement.

One of the coolest things I have seen is their IKEA renderfarm how-to! This is something anyone could, and SHOULD build.

http://www.animux.org/wiki/index.php?title=Animux_Caseless_%22Ikea%22_Rackmount_Renderfarm



One aspect of the Blender to RenderMan pipeline that kind of got overlooked was Digital Asset Management, something of which is VERY important for any kind of studio. They are working on what is known as ADAM, short for Animation Digital Asset Management. They seem to be well on their way to something very special for us 3D artists.

That is all I can say about that right now ;)

"Project Widow"

This is very much an early announcement (something I was going to hold back for a little longer but got excited tonight over the Animux finding). Though if anyone has been in the forum group section, this really is not much of a surprise. This is a short 1-2 minute "test" that some of us have been pulling together, something that has taken off quite fast. This was started as a Blenderartist forum topic discussion where the debate over whether or not Aqsis was being used to render the new Blender Foundation Open Movie "Durian". Well no is that answer. Either way over the next week the subject kept coming up and somehow a test was thought up. But it is not like any normal test, this is a short story, very short but it is still a story and not just some walk cycle. I felt it was more important to use an original story to make our statement heard and that is Blender to RenderMan WORKS.

Over the next couple of weeks a LOT of progress has been made. We have Paul Gregory and Chris Foster from the Aqsis team backing us up, we are also using Aqsis 1.5.0 development builds to be the test bed for that version. They are helping us with the technical issues, we are helping them find some obscure bugs. We also have the help of WhiteRabbit (Eric Back) who is furiously busy writing the next version of Mosaic, again we are going to test that version out as well. We have a talented modeller, Daniel Wray, that has built the vast majority of our assets so far, including the main character model. We also have the help from Cedric, an animator. Not only that but we also have the help from a couple of concept artists and a sound fx engineer. We are still on the lookout for some more animators and RenderMan users. This week I am busy with my local film friend punch out the final storyboard so we can start blocking out camera shots. My own tasks are quite varied but it's been in the shading and TD area, writing the pipeline documentation and testing things in both Blender and Aqsis to make sure when we get to that stage - it will work without too much trouble.

The short is being done to test the pipeline, to put it through a real world situation that involves a number of people working together on different parts of the "production". The nice part about this short is that we are doing this over the internet, which also has made it very challenging.

For more information and to watch our progress as we plug along on this here is the website.

http://projectwidow.wikidot.com/


Things seem to be starting here and I have been wishing for this day for a very very long time, so it is nice to see a little progress here.

"It's a very exciting time!"
- a quote from one of my favorite movies.

Sunday, May 03, 2009

Blender to Renderman Artist Tools v 0.5 Released! (UPDATE!!!!)




(EDIT: UPDATE! See below original post for more info!!!)

Finally this LONG awaited release has come! Sorry for such a long delay everyone, it has been a hectic year for me. Over the past 2 months I have been working hard on testing Blender 2.48 and the recent versions of Aqsis and Pixie to make sure that it can be considered "production stable", I have been on and off with making this ISO over the past year (to many people's dismay - sorry again) but so far with latest developments this looks good. Most of the tests I have done have been successful and I decided to finally put together this ISO for everyone to use, previous versions were not so bug free. I am listing it as version 0.5 because this is the fifth time I have undertaken such a task, the first time was just for my own use and each time since marked another "version" of this toolkit.

Anywho...... on to the goods!!!!

In this release are:

Compiled and sources of Blender 2.48, Aqsis 1.4.2, Pixie 2.2.5
Mosaic 0.2 Beta
Python 2.5.4 (installation for Windows - Linux already has it)
CGKit 2.0
Shaderman 0.7 and ShadermanNEXT
SLer
Shader sources (hundreds of them!!)
Shaderman shader projects
OpenEXR 1.4.0 (Windows install, Windows and Linux source)
OpenEXR 1.4.0 sample images
Dr. Queue (compiled and source)
Cutter
GIMP
Cinepaint (Linux only!! There is no recent Windows build)
Documentation from Pixars Online Research library as well as SIGGRAPH papers
Crimson Editor (Windows code editor)
Dev C++ and MinGW (Windows only, Linux has gcc which is the basis for all Linux builds)
Python scripts for Blender (various usefull ones not released with Blender)
Voodoo (for visual effects camera matchmoving)
Blender files (examples and test files)
Some usefull textures


This ISO is available HERE and we are also working on having it hosted elsewhere on a more permanent basis. This ISO is available free of charge, nobody is making money off of this at all, we have included all the required licenses (such as GPL and BSD). You are free to host this ISO and redistribute it as we have done so, we only require you to credit Blendertorenderman.org as original source since it has taken quite a number of man hours to test the software and put together the ISO. Please note that Pixar and ILM do have copyright information that MUST be included with the package, we do NOT want to upset these guys and it is only respectful that we do this since they pretty much influenced the industry and provided us with the means to do all of this.

Please note that while this is a "production stable" release, that there may be unforeseen bugs. Due to the nature of programming on different operating systems there is always the chance that something might be wrong. While this has been tested on Linux and Windows by myself personally, I have experienced some bugs here and there. That is the nature of the game, sometimes things get broken in the mix and there is a lot of code between all of the software. For the most part, and I mean %95 of the time, this release is stable enough for production, be it small studio or individual.

Also I am posting my updated Blender to Renderman Pipeline document originally posted in 2006. This has been revised to reflect current developments but is still being worked on and should be complete by late May, at most.

All the Development software for Windows like MinGW and DevC++ are to be considered AS IS! Like I said I am not a programmer but have included these into the ISO anyway, it is up to the end user to collect the necessary libraries and tools. I have not included any Linux libraries because it is easier to download them as needed from a repository, thus ensuring proper compiling of code. Any Linux programmer will be well versed in the trials of finding the right source if not found in repositories.

Lastly I want to thank the following people for their work and contributions towards this (of course not listed in any order).

Temujin
Eric Beck
Ildar Ahmetgaleev
Ton Roosendaal
Paul Gregory and the entire Aqsis development team
Okan Arikan
Alexei Puzikov (ShaderMan!)
Bobby Parker
Malcolm Kesson
Syoyo Fujita
Andrew Silke (for the original Generi Rig!!)
Larry Gritz
Saty Raghavachary
Tal L. Lancaster
Florian Kainz (for developing OpenEXR)
Robin Rowe

And everyone else who has joined our project, offered advice, testing and support!! Without everyone's encouragement none of this would be possible.

Oh yeah and thank you
Google for developing superb software to host our site!!

UPDATE

Due to some oversight an update was required. Sorry for that and promise to not make the same mistake!

Changes :

Code:Blocks added to replace Dev C++
GIMP source added
Python source added
CGKit 2.0 source added
Blend files removed (plan to add it next update with BRAT stable models, some required too much initial setup and didn't render right)

Hosting update

For now a torrent file has been created for this update but we are still hosting the original ISO as well since not everyone uses torrent programs.

BRAT 0.5rc1 (original host)

BRAT Release Update 0.5rc2



RenderMan is a registered trademark of Pixar.
All other products mentioned are registered trademarks of their respective holders.
© 2009 Lucas Digital Ltd. LLC. OpenEXR, Industrial Light & Magic and ILM are trademarks and service marks of Lucasfilm Ltd.; all associated intellectual property is protected by the laws of the United States and other countries. All rights reserved.