Thursday, June 18, 2009

One way to control shader parameters

The basic idea is making a shader with which you can control the surface's reflection characteristics by editing its BRDF in the GUI. Simple BRDF has two parameters. By mapping the two parameters to the angle components theta, phi of a polar coordinate, and mapping the reflectance ratio (so not BRDF, strictly speaking. I just used the term BRDF for explanation) to the r components of the polar coordinate, you can make a 3D shape that represents a BRDF (not BRDF strictly ...)

I made a test shader looooong time ago. The shader is assigned to the sphere. By changing the shape of the cobra like surface you can you can control the reflection characteristics of the test shader. It's a just a test so I shot rays from the origin to get r (length from the origin to the hit point) in side the surface shader, still you can edit the reflection characteristics interactively and animate them if you like. The test shader uses surface color too. It'll be better to be able to store the shape data to the file so that we can separate reflection editing and using it.

The usage is limited of course. It is rather a simple reflection, it can control only parameters which are mapped to the surface but it's more intuitive, the user doesn't need to write a code.

No comments: