View Full Version : Light color from objects bitmap

01 January 2009, 04:24 PM
Hey folks,

I'm looking to make a script that will generate a bunch of lights for an object, one per vertex, and then color those lights per a bitmap that is assigned to that object.
I'm about to head to work, so I don't really have time to sit and think the entire script through, but I want to see what you guys think of the THEORY behind what I'm about to write.

Step 1) Get a vertex count
Step 2) Get each vertex's UV coordinate.
Step 3) Get the pixel color for each coordinate
Step 4) Generate a light per vertex with the pixel's color, but only if that vertex has a HSV-Value above a certain threshold. The color of the light should by 100% value, but the multiplier be equal to the value times a certain multiplier.

Questions to be had.
- Is there anything that exists like this already?
- Am I heading in the right direction?
- Would anyone find such a thing useful?
- Is there a way to get a sample that isn't just 1 pixel large (say I want to sample a 5x5 pixel area instead of a single pixel and then average them together)?

01 January 2009, 05:23 PM
1. I think there might be - see . There's several plugins - from LightMesh to cebas' old LumaObject - that do similar things (LightMesh creates actual lights, I believe).

2. yes

3. Lots of people find it useful - hence why I think there may be a few already :) Thing is, most of them are not in particularly active development - so if you can do it better / add requested items, I'm sure you'll find it quite popular.

4a. Just getpixels for multiple rows+columns, average together.
4b. Set the bitmap's 'blur' amount a bit higher, rendermap the bitmap, then getpixels from that.
4c. a and b don't work quite 'correctly' for complex UV setups, so c: RTT the bitmap on the actual model, with some slight blurring for the bitmap used in the RTT, grab color values from that.

In most cases, 4a or 4b will be quite sufficient, unless somebody's using crrrrrrrrrrazy UVs on their model.

01 January 2009, 06:30 PM
You could also look at Grant Adam's MapToVColor ( modifier for getting the vertex color which will load the data into vertex color channel and includes ability to blur the map data. That way you don't run into the issue of combining it with data that in unmapped or close proximity to the exisitng uv pixel.


CGTalk Moderation
01 January 2009, 06:30 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.