Skip to main content

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 (http://www.mentalimages.com/products/mental-mill.html), 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. http://www.nvidia.com/object/mental_images.html)

Comments

Popular posts from this blog

iray 2: iray in standalone mental ray

Even iray has no customized shaders, iray has a shader. It is mia_material (Arch&Design in 3dsmax) only. Actually, it is a shader that has mia_material interface and the implementation is different from mental ray (only for iray). mental images explains this is for the users who already know the mia_material. Such user doesn't need to learn the iray shader from the scratch. Therefore, some of the physically meaningless parameters of mia_material are disabled. They also said that they will support more physical shaders, like BRDF shaders. Someone  asked about volume shaders support at the confenence, but, unfortunately, iray version 1 doesn't support volume shaders and will be supported in the following versions sometime. As for a DCC software user, the problem of iray is they can use it from 3dsmax/Maya/XSI or not. But NVidia's explanation is 'that is autodesk's decision.' Although, mental ray 3.8+ standalone or NVidia RealityServer support iray. (See ment...

iray 3: iray in standalone mental ray

How to export mi file from 3dsmax. 1. Assign mental ray renderer as Production renderer First open the Render Set Up dialog. Figure export_mi_1 show that opening the rollout of assign renderer and then choosing the mental ray renderer as Production renderer. Figure export_mi_1 2. Export a mi file from 3dmax. Choose Render Set Up --- Processing Tab. First you need to choose a filename as in Figure export_mi_2. Without a file name, the checkbox of 'Export on Render' is disabled. This was difficult for me. I wanted to export a file, but Export on Render is disabled. I wish I could choose the Export on Render and then see a warning message, ''an export file name is not specified.'' Next, push the Render button, then a mi file is exported. Figure export_mi_2 This is also difficult for me. When you ' export ' a file, push the ' render ' button. I wish it was like   When you ' export ' a file, push the ' export ' ...

A note of mental ray/iray camera terminology.

The original mental ray camera is a pinhole camera. Therefore, some of the terminology differs with a normal camera. I will write them down here. aperture: This is the film width size. This has no relationship with lens aperture/opening. mental ray's camera was a pinhole camera, there is no lens aperture. focal: This is the distance from lens to the film (sensor). Pinhole camera always focused, so there is no focal length meaning. But using parameters aperture and focal length, we can compute the horizontal field of view. I think these two parameters exist for this purpose. aspect ratio: This is film(sensor)'s aspect ratio. There is no relationship with pixel resolution and camera geometry.  aspect ratio = film width/film height. Note: If we use aperture, focal, and aspect ratio, we can compute the vertical field of view. mental ray/iray camera model (pinhole camera) without lens shader Current mental ray/iray can have depth of field effect, etc., this termino...