PDA

View Full Version : Scripting Question


XThejon
09-28-2007, 09:39 PM
I am new to XSI and am exploring ways to make nice lighting rigs. I have played around with Image Based Lighting, but I would like to have more control over the colors in the ambient lighting. To remedy this, I thought about making a sphere of lights that point toward the subject. By adjusting the light colors I would have complete control over the colors in the ambient lighting. Unfortunately, I am not satisfied with the way the lights blend together. You can see visible "lines" form where the lights overlap...
http://img231.imageshack.us/img231/7843/badlightingexampleep4.th.png (http://img231.imageshack.us/my.php?image=badlightingexampleep4.png)
(I boosted the contrast of the render in this sample so that the "lines" would be more obvious)

My new idea is to use a low poly sphere coupled with vertex coloring...
http://img250.imageshack.us/img250/7354/lightingsphereil4.th.png (http://img250.imageshack.us/my.php?image=lightingsphereil4.png)
...and treat it like an Image Based Lighting Sphere. Final Gathering would then take care of the ambient lighting with the exact colors I want...
http://img250.imageshack.us/img250/3246/litexampledg3.th.png (http://img250.imageshack.us/my.php?image=litexampledg3.png)
...I like the result - there are no ugly lines cast onto the subject, and I have complete control over the ambient color of the lighting all the way around the sphere.

Here is where I would like some help - when using this as a Light Rig, it is nice to be able to fine tune the colors of the individual points. However, I don't see any kind of interface that will show the current color of the selected vertex and allow me to adjust it - as if I were adjusting the current color of a light for example. Since I will have a fixed number of points, I thought it would be nice to write a script that could store the color information for the vertexes and allow me to edit it in an interface like this mockup I made...
http://img250.imageshack.us/img250/1586/controlpanelcl7.th.png (http://img250.imageshack.us/my.php?image=controlpanelcl7.png)

I need help understanding how to script something like this. I have not been able to find any documentation on ways to include color choosers in custom toolbars, and I have tried looking at the way that the commands are logged to learn what to program, but I don't know how to interpret the results. For example, while coloring one of the vertex points on the sphere I saw this command...

Application.PaintVertexColors("sphere", [27, 25, 18, 22], [2031615, 2031615, 2031615, 2031615], 1, "")

The command name is understandable, and the first two parameters I am guessing are the name of the object, and then in brackets the four selected vertices (since the one selected point touched four polygons). I am guessing the next brackets represent the colors to apply to the vertices, but I have no idea how the number "2031615" relates to color values.

Can anyone help get me started on this?

Thanks!

withanar
09-29-2007, 06:57 AM
There is documentation in the SPDL area of the SDK docs that should help you figure out how to build color widgets into your Property Pages.

If you have a pointer to your Custom Property, you can access the PPGLayout object, which allows you to start messing around with the format. You can convert 3 double params into a single RGB widget, or 4 doubles into an RGBA widget.

That area of scripting in XSI might take a bit of time to figure out, simply because it's less often touched by your more casual scripters and hackers. Thus, there are fewer examples of how to get it working.

If I have a chance this weekend, I'll see if I can work up a simple sample for you.

XThejon
10-01-2007, 04:52 PM
Thanks for pointing me in the right direction withanar. I finally got it working! You can see the final result here (with source code).

http://forums.cgsociety.org/showthread.php?f=24&t=545965

CGTalk Moderation
10-01-2007, 04:52 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.