Notifications
Clear all

[Closed] Light color from objects bitmap

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 5×5 pixel area instead of a single pixel and then average them together)?
2 Replies
  1. I think there might be – see scriptspot.com . 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.

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.

-Eric