Thursday, January 28, 2010

building a zdepth shader tree

ingredients, 1. sampler info 2. set range 3. blender 1. connect point camera Z of sampler info to value x of set range. 2. set min/max to 0 and 1, and set old min to distance between camera and furthest point in scene. for example -1000. 3. connect out value x to blender.blender output the color.

Tuesday, January 19, 2010


find the luminance, by separating out the components first, multiply each of the component with luma coefficients(ITUR Rec. 709 ) for RGB respectively. Add them up and mix original image with desaturated image with a matte, in this case a float. float red = comp(v1,0); float green = comp(v1,0); float blue = comp(v1,0); float luma = .2125*comp(v1, 0) + .7154*comp(v1, 1) + .0721*comp(v1, 2); result = mix(color(luma),v1,1-v2);

Monday, January 18, 2010

Faking Parallax

Faking parallax is one trick i've learned in videogame texturing, its applicable in non-videogame surfacing as long as it is used in the mid to far background. The bulb inside this headlight is created using the above technique, as we turn and look from the side, the bulb will become occluded, achieving a small sense of depth. The basic concept is to take the camera normal and use it to offset the UV normal Ns = normalize(transform("camera", N)); float x = xcomp(Ns); float y = ycomp(Ns); float z = zcomp(Ns); result = x; the above code is like facing direction, but only in the x direction, make another one for y. Invert y, set a new min/max with remap. The input min/max should be -1 to 1 and the new min/max should be something less than +/-0.25, depends on your texture and how much shift you want. Connect to a manifold slbox with the following snippet, float ss = s+v3; float tt = t+v4; result_Q = point(ss,tt,0); result_dQu = (0,0,0); result_dQv = (0,0,0); where v3 and v4 are the x and y from above. and then connect to your textures/shapes ST. You can do this in maya as well, just connect the camera normal from sampler info to uv offset of a place2d node. With a setrange in between, something like that, out of the top of my head.

Monday, January 4, 2010

Using packages in SLIM to create an RGB splitter

This create a small package that splits colors to RGB or just three outputs with some simple contrast controls. 1. Import a gammaimage 2. create 3 color slbox and add a color v1 to each of them and add the following code color red = comp(v1,0); result = red; duplicate the code to green and blue substituting 0 with 1 and 2 respectively. 3. create a float spline, and rename the first knot to low, and last knot to high. 4. duplicate the spline and rename the spline to each color. ie red_spline 5. shift select the SLBOX nodes in order of R then G then B. and select the splines in order as well. 6. Right click and click on package. 7. open the package, select red_spline, publish basis, low, p0, high, p1. Do the same for GB. 8. close the package. This package takes three inputs and has simple contrast controls, it would be great if someone can add the float spline GUI inside the package.