skybrush-io / studio-blender

Skybrush Studio for Blender - a Blender addon for designing and validating drone shows
https://skybrush.io
GNU General Public License v3.0
43 stars 30 forks source link

Light effects custom functions #12

Closed thomas-advantitge closed 6 months ago

thomas-advantitge commented 6 months ago

This PR adds support for color functions in two ways:

  1. In the Type dropdown next to "Color ramp" and "Image". The function should return an RGBA tuple.
  2. The "Custom expression" output which was already there as a placeholder. The function should return a number between 0 and 1 which will be used to get the color of the color ramp or the pixel in the color image.

Example of how it can be used to add color animations in a bit more dynamic way than creating 2D images for the Image type:

# note: `if` conditions for readability, could be optimized in 1 line of math
def fade_sorted(frame, time_fraction, drone_index, formation_index, position, drone_count):
    factor = min(max(drone_count * (1.1 * time_fraction - formation_index / drone_count), 0.0), 1.0)
    if formation_index >= 112:
        return factor * 1.0
    if formation_index % 2 == 0:
        return 0.66 * factor
    return 0.33 * factor

https://github.com/skybrush-io/studio-blender/assets/66438062/9e5caf9a-d264-48f4-8bdc-e833644e0329

CLAassistant commented 6 months ago

CLA assistant check
All committers have signed the CLA.

ntamas commented 6 months ago

This looks awesome, thanks a lot! I'm going through the PR soon, stay tuned.