Thursday, March 24, 2011

Ray pattern effect using basic mental mill shaders


This time I assembled an example that shows how to create a kind of funky sunbeam-effect using the MetaSL shaders. I won't go too much into the details this time. I tried to make the project quite self-explaining. Just start at the top of the workspace where you can see some nodes connected. This is the basic idea of how the ray pattern is created. Further down in the workspace you can find several Phenomena that extend the ray pattern effect. Later I will show you how you can achieve the same effect much easier using the MetaSL curve shaders.


You can find the mental mill project here.






The texture space is offset so that it ranges from -0.5 to +0.5 (a and b). The u and v components are split (c) and then fed into a Math_float_atan2 (d) node. This returns values that range from -PI to +PI. By multiplying this with an integer (e) (well actually it is a float, i guess you know what I mean) and feeding it into a Math_float_cos node (f) you get a result that ranges from -1 to +1 and creates the ray pattern.


To shape the rays I used a Math_float_smoothstep (g) node. The result of the cosine-node is fed into the 'locaction' input of the Math_float_smoothstep node. For the input parameters 'start' and 'end' use values that are close to each other to get a crisper transition. Applicable ranges are between -1 and +1.


Finally the resulting float value is converted to a color (h) and fed into the mix parameter of a Math_color_mix node (i) that you can use to mix two different colors.


Next I will show you how to use the MetaSL curve shaders to achieve the same effect but faster and in a more versatile way.

Tuesday, March 22, 2011

GDC 2011

Recently we have been at the GDC in San Francisco which has been a really great show. As usual we have been showing off mental mill at the NVidia booth where we were demoing the latest version of mental mill, namely an early version of 1.2.
Unfortunately my pocket camera did not work too well under the lighting conditions on the showfloor, so there are no good images to show, unfortunately. However, I got one shot of David explaining the software to an interested person.

We gave a preview of the new features that have been added to mental mill 1.2 and it was interesting to discuss with the users and hear their feedback. For those who have not been at the GDC, here are some of the highlights that we were showing:


  • scene element nodes: In version 1.2 there are new node types that describe a scene that can be previewed inside mental mill. These include the description of geometry, lights and a camera.
  • Load any number of preview objects and apply different shaders to them
  • View all geometry in one  scene (which is practical if you have a model that is made out of several pieces of geometry that need different shaders)
  • Render previews with iray and mental ray directly inside the camera node on the workspace. No need to launch a separate render window.
  • Shader creation for iray: iray supports a subset of shaders that you can easily wire up in mental mill and render it with iray inside the camera node
  • Project manager: The project manager helps to keep an overview over the shader files and shaders used in your project which helps you to keep an overview over your shader assets.
For our demos we were kindly provided with models by The Game Assembly which has some talented artists that created some cool models. Thanks for their collaboration, I hope to post some images soon. 

Monday, March 21, 2011

MetaSL webpage online

Today the the website www.metasl.org went online. For all those mental mill users who are interested in writing their own shaders, this is a comprehensive resource that helps to quickly get an idea of how to use MetaSL.

Right now the webpage is work in progress. For now you can find the first four chapters which are also available as PDF downloads for reading offline. These are draft versions of chapters and might be changed and updated.
New chapters will be added in the next weeks.

The chapters so far are:


  • Chapter 1: MetaSL — Strategy and scope
  • Chapter 2: Elements of the MetaSL language
  • Chapter 3: Basic surface shaders
  • Chapter 4: Rendering state


MetaSL is a platform independent shading language that can be translated to any existing target shading language. This makes it extremely useful if you need to deploy your shader on multiple platforms. Furthermore, you need to write your shader only once, allowing you to concentrate on the algorithmic aspect of your code rather than porting it manually from one language to another.

For sending feedback, you can take a look at the MetaSL Book open forum where you can leave your message and discuss with others.