Welcome, Guest! Log In | Create Account

SourceForge.net: Project ribmosaic

August 14, 2009

First Developer Blog!

Filed under: Release — WHiTeRaBBiT @ 2:01 am

Well after a good bit of work I finally have all the new SourceForge hosted app stuff up and going. As part of this change over I’ve added a MediaWiki (replacing the old wiki homepage and manual), much nicer phpbb forums (replacing the old forums), a test render gallery and of course this wordpress developer blog :) Anyway I intend of blogging here often sharing my ideas for future features as well as showing off test renders of new or experimental stuff.

Along those lines I’ve decided to copy in a forum post of several new features over from the Project Widow forum, this explanation includes several recently added experimental features that I think turned out quite well…

Hey everyone :)

As promised on IRC I’m posting some comments on some of the features just released in MOSAIC. This last update is almost entirely focused on the light shader rewrite however there were also quite a few important bug fixes. Let me start by talking a little about what has changed from the previous built-in shader. Most notably the biggest change is tighter integration with Blender’s lighting system here’s a list of integration highlights:

1 ) This was actually released 2 versions ago but nobody may of noticed, the tool tips over where parameter are edited in the shader editor now show detailed notes on what each does. Since there are so many parameters this makes using them a LOT easier!
2 ) The light types have been tweaked to better match Blender’s. In particular the Hemi light has been changed from the flat ambient RenderMan light to a non-shadowed 180 degree diffusion light. Also some transform problems have been fixed with the area light type which simply creates an array of spot lights within the area. Another change that may cause some problems is I changed point based shadow maps to use appended depth maps for simpler shader code however I learned afterward that only Air supports this, I assumed Aqsis did as it uses appended depth maps for occlusion like AIr :(
3 ) The attenuation model have been reworked to match Blender’s as well the Sphere option.
4 ) The Negative light option was added.
5 ) The No Diffuse option was added.
6 ) The No Specular option was added.
7 ) The raytracing soft shadow Soft Size and Samples were tweaked for a closer match to Blender’s.
8 ) ClipSta and ClipEnd now work for shadow maps.
9 ) Halo now works with the standard __foglight parameter so even non MOSAIC volume shaders will use it.

Also added to the light shader are parameters for tweaking the Soft and Samples factors interpreted by MOSAIC. So for instance if you set Blender’s light Samples to 16 and there’s still not enough samples you can jack up the SamplesFactor to make it higher. There are also a few experimental features added that are controlled from the shader parameters:

1 ) Fake soft shadows!

This technique is a hacked down variation from several papers I found, although what I’ve implemented is not as technically correct as what the papers outline this version should be faster and produce good results with tweaking. The idea behind this technique is very simple, load the shadow map as a texture and look into it backwards from the perspective of the surface point to the light. Then use the depth found in the map to get the distance from the light to the blocker, use this to get the distance from the current surface point to the front of the object casting the shadow. This distance is then used to adjust the blur radius of the shadow map, the greater the distance the blurrier the shadow. One last step is to randomly sample around the current surface point to catch surfaces just outside of the shadow. This technique is critically important as it can be ridiculously fast compared to raytracing when dealing with displaced surfaces, SSS and raymarching with volumes.

To use this simply setup a light for BufShadow and apply a shadow map pass, then in the light shader parameters enable “FakeSoftUse” = 1. The lights Soft control acts like the raytrace Soft Size and the lights Samples will control the samples for the shadow map. For the shader parameters “FakeSoftSamples” controls how many random samples are checked around each surface point and the “FakeSoftRadius” controls how far. Also “FakeSoftMin” and “FakeSoftMax” control the minimum and maximum blur values produced.
So to pull this all together, use Soft to make the shadows softer, FakeSoftMin to sharpen or soften where the shadows come close to objects and FakeSoftMax to control how soft shadows far away will get. Increase Samples to soften the shadow map but if you get speckles in weird places try adding more FakeSoftSamples. And finally if the soft portion of shadows look “cutoff” try increasing the FakeSoftRadius. For performance try keeping FakeSoftSamples as low as possible and if you need your shadows smoother always start with increasing Samples before FakeSoftSamples (its faster to sample shadow maps then surface points). Also keep FakeSoftRadius as small as possible, if its too small it will cut off shadows, if its too large you’ll get speckles in weird places.

A cool effect that’s possible through using fake soft shadows with caustic maps are focused caustics…

This effect can be further enhanced if deep shadows are used and “TraShadaw” is enabled on the Blender material for the transparent object. In MOSAIC if TraShadow is enabled then the fresnel transparency is turned into opacity (Oi) so deep shadows “see” the difference is density in the shadow map. If this is used in a caustic map it will cause the beam projected in the volume to be brighter near its center! Note: Aqsis currently does not support deep shadows but I know its high on their todo list.

2 ) Projectors and fake soft projections.

The image settings for Blender lights are not accessible from Python so this is controlled from the light parameters. To enable a projects simply enable and enter the name of a texture in “ProjMap”. You can use a texture you’ve manually setup of use one loaded in Blender and optimized through MOSAIC. If using one exported by MOSAIC be sure to change the textures extension to “.tx” so for instance if you have a texture called “mytexture.tif” in Blender’s UVImage editor it will be exported as “mytexture.tx” by MOSAIC. Next the “ProjOffX”, “ProjOffY”, “ProjSizeX” and “ProjSizeY” works just like Blender’s material texture settings allowing you to control the size and position of the projection. And finally “ProjBlur” allow you to add blur to the texture, however if the light is using “FakeSoftUse” this blur value is adjusted according to the surfaces distance from the light similar to fake soft shadows. This can produce illuminations that look more emitted then projected.

3 ) The last big change is automatic support for layered shaders with MOSAIC’s shaders. Previously the only way to use layered shading was to modify MOSAIC’s shaders to use them however they now have input and output parameters built right in! These parameters are __surfacein, __surfaceout, __displacein and __displaceout and you’ll notice they are entered by default in the Material tabs layered input outputs. This means that all that’s required to layer blender materials is to create a layer chain by selecting each successive material with the “Next Layer Material” one material at a time down the chain. The blending of each layer can be controlled with MOSAICsurface parameters “LayerBlend” and “LayerFactor”. By default these are set to use “Additive” blending with a factor of 1.0 but can be setup to use any of 15 blending modes. At first glance it may not seem necessary to have layered shading since MOSAICsurface can already blend up to 10 textures in 13 channels in each material already but when dealing with things like skin it is necessary to layer different SSS effects together (something only possible per material). I was planning to demo a realistic skin shader using nothing but an unmodified MOSAICsurface and layers but unfortunately there’s a bug that prevents SSS from working well in Aqsis. As soon as this is resolved I’ll be sure to show how to do this.

There’s other things to talk about but that should be good for now. Next up I’ll be working on rewriting MOSAIC’s volume shader that should hopefully go much quicker since it will not have anything experimental in it. This will basically just be a merger of the existing shader that uses distance and height fog with different attenuation’s with the smoke.sl shader that provides raymarching and 3d volumetric noise :)

Eric Back (WHiTeRaBBiT)

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

Powered by WordPress