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.

Friday, December 31, 2010

Blurred environment reflection

Here is a shader that is intended for real time usage. It takes advantage of passing custom derivatives to the texture lookup function. This is quite useful to produce blurred environment lookups. This enables you to produce more realistic looking surfaces because it allows you to mimic real-world surfaces in a much better way.

Since it is the 31st of December and I am about to dive into the next new year's party I will keep this post short... ;)

Idea:
Create an shader for real time usage that blurs the reflection based on the incident viewing direction.

Different Blurs of the reflection:
  • From inner to outer 
  • from outer to inner 
  • controlled by another texture

Observation:

  • If you take a look at a blurry surface, the reflection gets crisper when you look at it from a grazing angle. I observated this in detail a couple of years ago when I was working at a post production company and we were doing a promotion video for a big steel industry company.
    My colleagues back then told me that I was too meticulous. Maybe I was, but when your passion is building shader graphs its the observation and implementation of these small details that give the extra punch to your shader.
  • Also, reflections appear to have less saturation which, depending on the surface is not true. However, I added a control to the shader that allows you to drive the saturation of the lookup.


Other features:

  • The environment blur can be inverted
  • A constant blur can be applied too
  • Amount of the incident blur can be controlled

Tip:

  • Use the constant blur to shift the incident blur
Find the shader code on the mental images forum

Increasing the intensity of the constant blur (controlled by a texture) can yield
stunning looking corrosion effects. Also the reflection saturation has been
reduced for these screenshots.

Happy New Year Everyone!

Thursday, December 30, 2010

Uncharted 2 Art Direction

As shader artist, you have to work closely with other designers, modelers, art directors all of which have a different view of their profession. When it comes to creating big game titles, I am in awe how good these groups can work together to produce these marvelous wonderlands that take us to new places that don't even exist in the real world.
A friend of mine forwarded me this link that gives insight in the art direction of the game "Uncharted 2". Though I haven't played the game, the document is very interesting and can give you some insight and good inspiration. Take a look.

Art Direction in Uncharted 2

Tuesday, December 14, 2010

The beauty of aliasing

It does not happen too often, but occasionally there is beauty in things that you don't want. What I am talking about is aliasing. I guess that lies in the nature of those who like playing around with visuals. I have to admit that I am one of those persons who get inspiration from things that go 'wrong', but especially in visual arts there is sometimes no real wrong or right. Some people might say 'oh, that looks great' while others will comment that this is the most useless thing that they have seen.
Visuals are a bit like music, taste is also so different. So while I have been testing the shader pack that will be released today or tomorrow on the mental mill forum, I started cranking up some parameters. All of a sudden,  aliasing patterns appeared and that looked quite beautiful actually.
The beauty of aliasing

And talking about visual arts. My very first blog entry featured a fractal shader. I discovered this amazing 10 minute fractal zoom that features some tech-house sound. It might not be everybody's taste. Beauty is in the eye of the beholder.

Fractal Zoom (HD) to 6.066 e228 (2^760) Mandelbrot - (Last Lights On)
http://www.youtube.com/watch?v=foxD6ZQlnlU

Quote from the video description:

For the record, 1 to 6e228 is like expanding a proton to 7000000000000000000000000000000000000000­0000000000000000000000000000000000000000­0000000000000000000000000000000000000000­0000000000000000000000000000000000000000­000000000000000000000000000 times the size of the visible universe. [...]
(Proton has 1 femtometer diameter, universe has 93 billion light year diameter)
If you were actually traveling into the fractal, you would be moving faster than the speed of light.

Friday, December 10, 2010

Web 2.0 shader

The idea
Seeing all those fashionable buttons and icons on every web page, smart phone etc. I though it was about time to create a shader that can just do this for us: Generate shiny icons. So here is the result:

This is probably one of the most pointless shaders that I have made so far ;) Nevertheless it was great fun to work on. If you have read my previous blog entries you will see that this shader reuses the ideas presented in these blog entries. It is a mixture between rendering a square and circles.

Features:
The shader outputs the color map of the icon, a bump map and a black/white mask for the icon.
A large number of input parameters give you control over the shader: Roundness of the icon, position, size, highlight intensity and highlight color, bump map intensity, just to mention a few. Just play around with it and see for yourself.



The MetaSL code
If you can call yourself a mental mill owner, I recommend to step with the visual debugger though the source code and see what it happening in each step. I tried to make the code as clear as possible and it is full of comments. Nevertheless sometimes looking at the debugger and 'seeing' is far much easier than reading comments and source code.

Here are some variations of the shader. I plugged the bump map into an Illumination_phong node to obtain some crisp highlights that I added on top.

You can download the shader along with the test-icon and a mental mill project from the mental images forum:
Web 2.0 Shader Source
Feel free to modify the shader for your own needs and let me know your feedback or any questions.

Further improvements
As almost everything in life, this shader can be improved by adding a few more features to it. I will leave it as it is right now. Experienced users might want to implement the ideas mentioned below:

  • Make a softer transition for the bump map. The edges are quite hard which leads to aliasing artifacts. It would be better to ramp the normal gently.  
  • The highlight overlay could be tweaked to look nicer. Right now a simple blend between the icon color and the highlight color is performed. Trying some other blend modes might yield a more realistic looking reflection overlay.