March 14th, 2010 / No Comments » / by Andrei Toplician
I’ve been playing a lot with VRay inside of 3ds max in the last couple of weeks so I decided to start and write a series of blog posts on some of my favorite features of VRay, a few tricks that I discovered or read about and some best practices. In the first of these series I’m going to point out a few things about Light Cache.
1.What is Light Cache ?
Light Cache is one of the 4 available methods for computing Global Illumination inside of VRay. It is an approximation technique. The other 3 methods are quasi Monte Carlo (QMC or brute force) which is exact, Irradiance Map and Photon Map which are also approximate.
2.Why Light Cache?
Light Cache is similar in concept with Photon Map, but unlike Photon Map it generates rays by emitting them from the observer’s point of view rather than from the light source. Because of this Light Cache only calculates samples that are visible to the camera.
The main advantage would be the fact that because it only computes the visible samples it saves a lot of render time (unlike Photon Map which calculates the samples for all the scene, even those that are not visible) but there’s a little disadvantage to this when it comes to animation. For example in an animation where only the camera moves calculating the GI for all the scene could be a good things because you can use it for all the frames.
But here comes another great feature of Light Cache, the ability to save the information and store it in a map file. So even if Light Cache calculates the samples that are visible, you can reuse that information and only add new samples to the file as your animation progresses.
Another great thing about Light Cache is the fact that it works with any light-source (including skylight and self-illuminated objects) , regardless of the fact that it emits or not photons, unlike Photon Map.
One of the limitations I’ve seen and read about in Light Cache is when you have bump maps in your scene. In this situation I feel it’s better to use Irradiance Map and QMC rather than trying to make Light Cache work out.
There are few situations when using Light Cache for both primary and secondary bounces would give great results but if you pair it with say QMC or Irradiance Map you can expect some great quality in very good render times.
3.How do I setup Light Cache inside of VRay?
Light Cache is actually quite simple to setup. There are only a few important steps to follow to make sure you get the best results.
First you need to specify the number of rays to be shot from the camera in the Subdivs input. Remember that the actual number of rays being emitted is the square of the number you type in the Subdivs input. So say you type 100, it will emit 10000 rays.
The next thing you need to take care about is the Sample Size, which goes hand in hand with the Subdivs. You have to take in consideration that the smaller the samples the more details get preserved but it also requires more memory for computing. Another thing to remember is that the Sample Size is based on the Scale you set (Screen or World).
For example if you set the scale to Screen and set the Sample Size to 1 it will only create one sample for the whole image.
Another great tip is the Store Direct Light checkbox. If you check that then Light Cache will calculate the direct light also reducing the rendering time but also reducing quality. So keep in mind that if you let Light Cache take care of the direct light also you will get faster render time but at the expense of quality. I find this feature to be very useful in scenes where you have more than 2 light and when you want to make fast previews, before the final render. When I render my final image I never check this option.
There are a few other parameters that you can play with, like the Number of passes (which depends on your CPU and available threads), Show calc phase (which shows the GI as it’s being computed), Pre-filter (which filters the samples before rendering), etc.
Also very important is the Filter option. This determines how the samples in the Light Cache map are interpolated. Unlike Pre-filter this is applied during the final rendering process.
I recommend using Fixed when you use Light Cache for primary bounces and Nearest for when you use it for secondary bounces. None is good for fast previews but does not produce great results.
There’s also another way to use Light Cache and that is Progressive Path Tracing. When you use that mode you can only set the number of Subdivs and every thing else it taken care of. This method is different that the others since it computes the whole image at once. Good thing is that you can also stop the process at any time and use the calculated results.
4.Some final notes.
A lot of people, including I are familiar with QMC because of the simplicity of the setup and the great results it produces, but at the expense of very very long rendering times. Light Cache is quite new to me too but I really like this method. The setup is not that difficult once you get used to it and the results are astonishing.
There are quite a few setups you can choose from depending on the situation and to be honest I haven’t had the opportunity to test all the situation. But from what I’ve tried so far I found that using QMC or Irradiance Map for primary bounces and Light Cache for secondary bounces gives the best results in the majority of cases. You can use Light Cache for both primary and secondary bounces but I suggest you only use that when calculating the GI and not for the final render, since QMC and Irradiance Map give better results when rendering the final image.
Being the first in the series, this was more of an informative post but for future posts I’ll try to provide some render results and also comparisons with similar engines, like mental ray and finalRender.
That being said, I hope you liked this article and found it useful and start digging more into VRay.
February 18th, 2010 / 1 Comment » / by Andrei Toplician
Here’s a list of a few questions a Robotlegs beginner might have, provided with answers. You would probably find all these answers if you read the Best Practices doc (which i strongly encourage! ) , but this is intended for quick lookup. Currently it’s only a small list and does not cover all the problems a beginner might stumble upon but I’ll keep updating it. Any tips or requests are also welcome. And of course you can always check out the Knowledge Base and the Google Groups for more information.
Answer: The base implementation that Robotlegs comes with is just an example, a reference to help developers jump start to using the framework. It does follow best practices and you can use as much as you want from it. Of course you can define your own implementation of the framework to suit your needs.
Update : I got this tip from Max Nylin that in Flash CS5, you can check the Publish ‘Settings > Flash > Export SWC’ setting and Robotlegs will work without defining the XML to the injector.
Answer: First, you have to map your class so that the injector knows what you want to inject. Than you can simply use the [Inject] metadata wherever you want to perform the injection. There is a second way of achieve this and that is of manually performing the injections.
Answer: Well, injection is indeed performed by the Injector. Both the mediatorMap and the commandMap are making use of the Injector as well, though they are both equipped with additional functionality to help these tiers (Mediators and Commands).
Answer: Well, first off, the “singletons are bad” debate is probably a never-ending discussions. There are pros and cons, so let’s not get into that right now. Secondly, the mapSingleton method in Robotlegs provides a single instance of the class to be used in all injections. This instance is not a Singleton enforced by the class itseslf, but rather an instance provided by the framework.
Answer: mapSingletonOf is used for mapping interfaces or abstract classes. It also requires you to pass an interface or an abstract class. mapSingleton is used for concrete implementations.
Answer: The mediator class is created when your view class is added to the stage. At that point the onRegister function of the Mediator class is being called.
Answer: If set to true, the command will execute only one time and then be unmapped. That means that if the same event triggers again the command will no longer execute. If set to false (the default is false) than the command will execute each time the event is triggered.
Answer: Well, you can use only one class to perform both duties but that is not intended as best practices. The Model and Service class do both implement the same Actor class but the separation is because of the different functionality that the 2 tiers have in an application.
Answer: No. Robotlegs promotes decoupling of tiers so you should very easily refactor your classes to suit other needs. For example View, Model, Service and VO classes are intended to be highly portable.
Answer: Well, as a best practice advice I advice that you capture events that require to perform work directly on a view component in the Mediator and let the other events trigger a Command.
Answer: No. A Command is instantiated by the framework and called in response the framework event it was mapped to. You should never attempt to instantiate or make a direct call to a Command from another class.
Answer: The mapListener is a method of the EventMap which makes sure each event is removed when the mediator is no longer used by the framework. This ensures the classes are collected by the Garbage Collector and are no longer used by the Flash Player. You can use the standard way but you have to manually remove the events.
Answer: I strongly encourage to implement an Interface in your Service and/or Model class and use that interface in all your injections instead of the concrete class because it promotes decoupling and helps you better unit test your application. By doing so you can easily swap service and/or model classes at runtime.
Answer: Simple. You can map a single instance of your class for all injections using the mapSingleton method and then inject it whenever your need to access it’s properties.
February 16th, 2010 / 2 Comments » / by Andrei Toplician
For the last few weeks I’ve been working with a friend of mine, Nistor Andrei on a CG short film. We first intended to make clip for the Infomatrix 2010 contest but later we decided to push it further and try to develop something we can be both proud of and serve as a cg portfolio.
We started working on a short trailer-like that would be submitted for the qualification stage of Infomatrix 2010. The deadline was 15th of February so here’s the first draft that we submitted.
This draft has its flaws because it was done in a very short period of time (involving learning and trial and error) due to the deadline constraint. For example all the editing, sound mixing and post processing of the rendered shots has been done in just 2 days.
We have the story that we want to tell and now that we finished this first draft and we have a general idea of a the workflow involved, we’ll start working on the final film.
January 22nd, 2010 / 1 Comment » / by Andrei Toplician
I’m currently working on a cg short-film with a friend of mine for a competition and we’ve been doing some nice progress lately. I’ve invested quite some time into this during the last 2 weeks so I’d like to post a few test render stills I did last night. There’s nothing fancy yet since we just started but we’ll get there.
January 11th, 2010 / 8 Comments » / by Andrei Toplician
This is a quick post. I’ve just updated my previous class diagram for Robotlegs.
The updated version includes both color and layout update as well as more content.
(click on the image to display in browser or right-click and “save as” to download)
PS: I plan on re-doing it in Illustrator as vector graphics if there is demand. That way it will be more printer friendly and easy to scale to any sizes without getting ugly pixels.
January 9th, 2010 / 13 Comments » / by Andrei Toplician
As I mentioned in a previous post I’m a big robotlegs enthusiast. Robotlegs is a pure AS3 MVCS framework that makes use of automated metadata based dependency injection. It promoted loose coupling, removes boilerplate code and helps you write testable code.
Here I made a pretty basic demo of setting up a Flex project using the robotlegs MVCS implementation , which connects to a PHP backend.
To call the methods in the PHP classes I’m using ZendAMF which is a component from the Zend Framework that uses the AMF protocol.There are a lot of articles on the web about Zend and how to install it so I won’t get into that right now.
I want to mention that I currently don’t have a microphone so there’s no audio. I might add voice narration later on.
The demo is pretty easy and straight forward but if you find it interesting enough I’m planning on expanding the idea and go into further detail (and also add audio features). For the sake of time and because this was planned as a robotlegs tutorial , I only go trough coding the Flex frontend, but I’m providing the source codes (including the .php classes and the services-config.xml file ) for download.
Also please keep in mind that this is just a quick demo, it’s not intended as a best practice example.
January 5th, 2010 / 4 Comments » / by Andrei Toplician
I recently found out about as3dmod, a modifier library for AS3. It’s a very handy library for creating 3d modifiers and animate them. It has support for all major 3D libraries in AS3.
The api itself is very simple to use and comes with a demo for all the 4 supported engines (papervision3d, away3d, alternativa3d and sandy) and class documentation.
Here I build a very simple audio visualizer.
The code is pretty simple and quite self-explanatory. I also provided the .as file for download.Note that you will need to grab as3dmod and papervision3d.
You also need to setup you 3d scene and create the object/material. In the example I’m using papervision3d and I created a simple Plane object with a WireframeMaterial added to it.
For as3dMod to work you need to create a new ModifierStack , a modifier and add it to the stack.
privatefunction initAS3Mod():void {
modStack = new ModifierStack(new LibraryPv3d(),plane);
perlin = new Perlin(2);
perlin.setFalloff(0,0);
modStack.addModifier(perlin); }
Finally in an Event.ENTER_FRAME event you need to output the sound wave into a ByteArray.
Then we loop through the 512 values in the ByteArray ( ByteArray contains 512 floating point values, 256 for each channel ) and assign the values to the modifier’s force property. Note here that we’re using the readFloat() method of the ByteArray that returns a 32 bit floating point number. Also remember to call the apply() method on the ModifierStack to update the modifier.
January 5th, 2010 / 8 Comments » / by Andrei Toplician
Since I’m a big enthusiast for robotlegs I though I could make something useful for the community. I made this Class Diagram to help people get a better understanding of the framework and it’s API.
The diagram contains all robotlegs classes and interfaces complete with all the properties and methods as well as a visual map of the class inheritance . I’ve uploaded both .jpg and .pdf versions.
January 4th, 2010 / No Comments » / by Andrei Toplician
As it is a tradition that when you start learning a new programming language (or an API, framework etc., you name it) , you usually start with the famous HelloWorld application.
Therefore I’m starting this blog and along with it my blogging experience with a welcoming HelloWorld post.