Passing data to material shaders

Hi everyone, here’s a resource that can pass data from Python to material shaders. Quite simple to setup, just modify the data of a texture, or alternatively use lamp parameters to pass in floating point values.

I personally prefer using textures, as it’s encapsulated and doesn’t run into trouble with the light limit.

Both examples are implemented, and can be switched between in the material nodes window.

settings.blend (630 KB)

Cool, looks interesting.

But… I’m having trouble understanding the concept.

I don’t use nodes much, but when I did (circa Blender 2.49b) and wanted to pass info to them I used object color, or vertex colors.
Object color was pretty limited as it only amounted to rbga values, while vertex colors allowed more fine control at the expense of speed. I mostly used it for texture splatting

It seems like this method has a result similar to passing the object color, as I can only change the overall a,b and c values (no alpha, so one less input than using object color). Or am I missing something, can I edit the texture pixel by pixel as an array? (I notice the texture is a single 1x1 pixel generated image right now) That’s something I would be very interested in, as it would allow things like drawing up a pixel based mini map or radar, or an animated LED type wall screen using procedural animations (like sinewave generated ripples or wave type distortion) or texture splatting for terrain.

The main benefit of the texture technique is that you can use multiple textures per object. Whilst this might introduce some overhead as this grows to a large list, at present it’s more scalable, as you may encode 3 (technically 4) floats per texture, and the number of textures is relatively unbounded (save by memory).

You can, however, edit the texture as an array. I am editing a single pixel, but that number is not bounded. Once it is used by the material nodes, there is no simple way to extract individual values that are used globally in the material, unless you create a mask and shift it for individual pixels (which I am not sure is possible).

Ah! I get you. Object color can be used only once, but these textures can be added as many times as needed (4 textures would give me 12 float inputs). I’m sure I can find a use for this, thanks. :slight_smile: