Friday, April 24, 2009

What is shader?

Shader is one of the important component of mental ray. Let me tell about it a bit.

A shader is a program code fragment that computes how light interacts with objects. This was the original concept of shader in early computer graphics time and nowadays the role of shader and its meaning are expanded. In one of the common scenario in computer graphics, objects are usually represented as polygons. First, the intensity of each vertex is computed, then inside the polygon is filled by an interpolation method. This becomes more complex as the computer graphics technology developed. There were two shader development directions. One is a hardware rendering that concentrates rendering speed and interactivity. The other is a software rendering that concentrates the image quality.

Nowadays graphics hardware is called GPU (Graphics Processing Unit). The early stage GPU has fixed functionalities. Because fixed functionality can be achieved more performance in practice. The implementation was based on deep pipeline processing which gives us good throughput of pixel generation. However, as the semiconductor technology evolved and hardware had more computational power, GPU also started to consider high quality rendering. GPU becomes programmable. The initial shader programs were written in assembler like language, then shader language for GPU was established, e.g., Cg. Now there are CUDA and OpenCL (2009), these languages are no longer for only shaders, but also for general purpose programming.

On the other hand, mental ray shader started with the purpose to generate high quality rendering results. The main role of shader is to simulate light and object interaction, some of are based on physics and some are based on a good heuristics. GPU is good at if the light and object interaction is local, since parallel processing works better with high local computation. Especially, pixel parallelism works quite well in early days. But the real world problem is global. Any far away object can cast a shadow to other objects. One single object can affects whole scene. Mental ray is designed for this global illumination simulation. Mental ray's each shader still could compute a local interaction between light and objects, but this effect is propagated by ray tracing algorithm to compute global illumination effect.

Recently, these two shader directions are coming to merge. There are several GPU ray tracers. mental images produces a product called mental mill (, that employs general shader language MetaSL. mental mill compiles MetaSL and exports several GPU based languages (e.g., Cg) and also mental ray shaders.

I think GPU shaders still largely take care of speed because of game industry. Software rendering still has some advantages for the quality of image.

(mental images was taken over by NVidia at November, 2007. NVidia is one of the leading company of GPU industory.

Tuesday, April 21, 2009

About this blog

This blog is about mental ray, a rendering software.

What is mental ray?

Mental ray is a rendering software produced by a German company (a subsidiary company of NVidia. (2009)) mental images, GmbH. Several DCC (Digital Contents Creation) software, e.g., Maya, 3dsMax, Softimage XSI, employ mental ray as one of a renderer. Mental ray is also used in some CAD software, like Solidworks. The famous usage is special effect of some movies, such as StarWars, Matrix II/III, recently one is The Curious Case of Benjamin

The main sales point of mental ray is a lot of features and you can do a lot of things. But on the other hand, we can do everything means sometimes we can do nothing. It is complex and thus difficult. Especially the customization ability of shaders is flexible, but it is a bit hard for me. However, usually it is suffice to use the provided shaders. One of my Italian friend said, ``mental ray is Ferrari. If you do not know how to drive it, you even can not move. But, if you know that, you can make Matrix.'' As a one user of mental ray, I hope the future direction is simpler.

Many of the mental ray information is in English, I would try to write this in Japanese (see Japanese version pages).