Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example of a transforming color effect is needed #13

Closed
dandaka opened this issue Dec 6, 2015 · 5 comments
Closed

Example of a transforming color effect is needed #13

dandaka opened this issue Dec 6, 2015 · 5 comments
Labels

Comments

@dandaka
Copy link
Contributor

dandaka commented Dec 6, 2015

https://github.com/brunchboy/afterglow/blob/master/doc/effects.adoc#layering-effects

I use colors from default example. Like this:

(global-color-cue "red" 0 0 :include-color-wheels? true)

I want to create a simple transformation, based on already active effect (red color on all fixtures). For example, change hue to +50 (or lightness to -50). I guess I should add another effect with :priority, so they will start to work with each other. Can't find any example with 2+ effects working at the same time.

Going after build-saturation-transformation source is not returning any results in 2+ hours :)

@brunchboy
Copy link
Member

I think you are on the right track. Hopefully my answer in #12 will get you moving again. Otherwise, the fade tests and chase tests are additional examples of cues layering on top of each other. You will be best served by coming up with some very simple ones that work with your lights and seeing what happens when you combine them. Using cues with a controller can be helpful in experimenting, and a fade that lets you turn the overlay cue intensity up and down by moving a fader or turning an encoder is informative too.

@brunchboy
Copy link
Member

As you seem to have discovered, transform-colors is precisely an example of doing this. You just need to get the effect running at the same time, and with a higher priority than another effect that is creating a color. The easiest way to experiment with layering effects, and turning them on and off, is to set up cues, and then just use the web interface to interact with the cue grid, since you probably don’t have an Ableton Push to play with. Have you tried that at all?

@dandaka
Copy link
Contributor Author

dandaka commented Dec 7, 2015

Thank you for your help. transform-colors is working, but function is super complicated to get any idea, how it is working right now.

Can I ask you to give any example of two simple effects, that work together, while modifying results of each other? Like global-color-effect with other simple effect, like hue rotation or lightness oscillator?

I will help to understand, how do they work.

I am guessing following, which has no effect:

(show/add-effect! :color
  (afterglow.effects/scene "Green color with hue rotate"
    (afterglow.effects.color/color-effect "Plain green" (create-color "green") (show/all-fixtures))
        (afterglow.effects.color/color-effect "Hue rotate" (afterglow.effects.params/build-color-param :adjust-hue 90) (show/all-fixtures))))

@brunchboy
Copy link
Member

You’re right, that approach won’t work. I’m afraid transform-colors might be almost as simple as it gets, because for an effect to modify another effect, it needs to work as part of the rendering pipeline, which is the deepest, most performance-critical part of Afterglow, and there are a number of protocols (the Clojure equivalent of Java interfaces) involved. I will try to see if I can come up with any more hints or pointers (as well as responding to your other questions and pull requests) but need to focus on the day job for a while at the moment.

In the mean time, the Effect Lifecycle documentation is where I try to explain how this works. I think it may make more sense to you now than the first few times that you may have looked at it, because you are now trying to implement something that fits into it. And the overall description of how that lifecycle is used to render DMX values is explained in the Rendering Loop documentation. When an effect is running, it creates Assigners, which are the things that produce DMX values. The assigners get a chance to look at the value that any other, earlier effect has produced for the channel, color, rotation, or whatever it is they are supposed to assign, and can either use it, modify it, or replace it.

Perhaps by looking over those pages, and seeing how the transform-colors code fits into them will help before I have time to write more examples. I think that copying transform-color and changing it to rotate the hue is an excellent exercise to try. Most of the code will be the same, and hopefully the documentation pages will help explain what it is for.

The part of transform-colors that you will want to change is… wait! I just looked at the code, and realized that I had written it in a way to make it easily extensible. You can reuse my existing code, and just supply a different transformation function. My code will do all the work of living in the rendering loop, and finding any previous color value that was going to be assigned, giving you a chance to manipulate it. All you need to do is write your own version of build-saturation-transformation that rotates the hue instead of playing with the saturation, and then pass it to transform-colors something like this (assuming you called your function build-hue-transformation):

(transform-colors (show/all-fixtures) :transform-fn (build-hue-transformation))

That would create an effect that would shift the hues of any colors being sent to all the fixtures in the show, once you add it to the show (and with a higher priority than the effects that you want it to adjust). , Of course you can pass arguments to your hue transformation function if you want.

And after looking at it, I agree that transform-colors is more complicated than it needs to be, because it has this flexibility built into it to make it easier to use with other kinds of color transformations, and it also has support for working with Pangolin Beyond laser shows, which has nothing to do with what you are trying to do. So a simpler example that does just one kind of transformation would be useful. But hopefully this series of explanations can get you further for a while.

@brunchboy
Copy link
Member

Here is another example! The virtual dimmers that you wanted in #43 are implemented as a transforming color effect with simpler code than the above discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants