POV-Ray : Newsgroups : povray.general : Interpolating between textures using clock? Server Time
25 May 2022 05:59:42 EDT (-0400)
  Interpolating between textures using clock? (Message 1 to 9 of 9)  
From: tutki
Subject: Interpolating between textures using clock?
Date: 2 Feb 2022 19:30:00
Message: <web.61fb20c368c053805c8e85ceb98f01db@news.povray.org>
I have an object that simulates a generic computer screen using the `cells`
texture to generate a grid of random-colored pixelated blocks.  I'd like to make
an animation of this where the "screen pixels" gradually change in color based
on the `clock` variable. Is there a simple way to do this?

My current idea is to somehow interpolate between two `cells` textures (by
displacing them relative to each other by some random integral offset) and doing
the equivalent of pigment1*clock + pigment2*(1-clock). So basically interpolate
between two random cells patterns according to the value of clock (or some other
such derived variable). But I can't figure out how to express this in SDL?  Can
anyone help?


Post a reply to this message

From: Bald Eagle
Subject: Re: Interpolating between textures using clock?
Date: 2 Feb 2022 20:35:00
Message: <web.61fb310e7de8ac01f9dae3025979125@news.povray.org>
"tutki" <nomail@nomail> wrote:
> I have an object that simulates a generic computer screen using the `cells`
> texture to generate a grid of random-colored pixelated blocks.  I'd like to make
> an animation of this where the "screen pixels" gradually change in color based
> on the `clock` variable. Is there a simple way to do this?
>
> My current idea is to somehow interpolate between two `cells` textures (by
> displacing them relative to each other by some random integral offset) and doing
> the equivalent of pigment1*clock + pigment2*(1-clock). So basically interpolate
> between two random cells patterns according to the value of clock (or some other
> such derived variable). But I can't figure out how to express this in SDL?  Can
> anyone help?

Hmmm.

Assuming that your cells pattern has a pigment_map associated with it ...

Why don't you change the definition of the pigments in the map by interpolating
between two rgb values per map entry?

Probably best to do this around the HSV wheel, rather than directly in
rgb-space, otherwise you usually cross through a gray-region....


Post a reply to this message

From: Josh English
Subject: Re: Interpolating between textures using clock?
Date: 3 Feb 2022 00:32:06
Message: <61fb68d6$1@news.povray.org>
On 2/2/2022 4:25 PM, tutki wrote:
> I have an object that simulates a generic computer screen using the `cells`
> texture to generate a grid of random-colored pixelated blocks.  I'd like to make
> an animation of this where the "screen pixels" gradually change in color based
> on the `clock` variable. Is there a simple way to do this?
> 
> My current idea is to somehow interpolate between two `cells` textures (by
> displacing them relative to each other by some random integral offset) and doing
> the equivalent of pigment1*clock + pigment2*(1-clock). So basically interpolate
> between two random cells patterns according to the value of clock (or some other
> such derived variable). But I can't figure out how to express this in SDL?  Can
> anyone help?
> 
> 
The cells pattern can be updated with the phase keyword. Use a color map 
that doesn't blend colors and you can simulate blinking of colors.

Uncle Josh


Post a reply to this message

From: tutki
Subject: Re: Interpolating between textures using clock?
Date: 3 Feb 2022 13:00:00
Message: <web.61fc17fb7de8ac05c8e85ceb98f01db@news.povray.org>
Josh English <Jos### [at] joshuarenglishcom> wrote:
> On 2/2/2022 4:25 PM, tutki wrote:
> > I have an object that simulates a generic computer screen using the `cells`
> > texture to generate a grid of random-colored pixelated blocks.  I'd like to make
> > an animation of this where the "screen pixels" gradually change in color based
> > on the `clock` variable. Is there a simple way to do this?
> >
> > My current idea is to somehow interpolate between two `cells` textures (by
> > displacing them relative to each other by some random integral offset) and doing
> > the equivalent of pigment1*clock + pigment2*(1-clock). So basically interpolate
> > between two random cells patterns according to the value of clock (or some other
> > such derived variable). But I can't figure out how to express this in SDL?  Can
> > anyone help?
> >
> >
> The cells pattern can be updated with the phase keyword. Use a color map
> that doesn't blend colors and you can simulate blinking of colors.
[...]

Oh nice, I didn't know `phase` works with `cells`.

But it doesn't solve my problem though: it doesn't smoothly interpolate between
colors, it just jumps around randomly. What I want is a way to smoothly
interpolate between one cells state and another.  Perhaps some kind of shifting
color_map?


Post a reply to this message

From: tutki
Subject: Re: Interpolating between textures using clock?
Date: 3 Feb 2022 13:05:00
Message: <web.61fc19187de8ac05c8e85ceb98f01db@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
[...]
> Assuming that your cells pattern has a pigment_map associated with it ...
>
> Why don't you change the definition of the pigments in the map by interpolating
> between two rgb values per map entry?
>
> Probably best to do this around the HSV wheel, rather than directly in
> rgb-space, otherwise you usually cross through a gray-region....

Yes, I have a pigment_map, mainly to convert the greyscale (well, scalar) values
of `cells` to some colors. Currently I have:

------
                color_map {
                        [0.00 color Red]
                        [0.17 color Yellow]
                        [0.33 color Green]
                        [0.50 color Cyan]
                        [0.66 color Blue]
                        [0.83 color Magenta]
                        [1.00 color Red]
                }
------

Problem though, is how to vary the color_map entries by `clock`?

P.S. Oh nevermind, just realized povray allows the color part of each entry to
be variable. So I could do something like Red + Green*clock, Green + Blue*clock,
etc., to get what I want.

Thanks for the idea!


Post a reply to this message

From: Bald Eagle
Subject: Re: Interpolating between textures using clock?
Date: 3 Feb 2022 13:35:00
Message: <web.61fc1f787de8ac01f9dae3025979125@news.povray.org>
"tutki" <nomail@nomail> wrote:

> P.S. Oh nevermind, just realized povray allows the color part of each entry to
> be variable. So I could do something like Red + Green*clock, Green + Blue*clock,
> etc., to get what I want.
>
> Thanks for the idea!

Yes, you've got the idea.   :)

You _might_ also think about using the same static pigments in the map, but vary
the map indices using the clock value...

colors.inc has a macro called CHSV2RGB in case the direct rgb variation doesn't
provide what you want.

https://wiki.povray.org/content/Reference:Colors.inc


Post a reply to this message

From: tutki
Subject: Re: Interpolating between textures using clock?
Date: 3 Feb 2022 14:50:00
Message: <web.61fc30c07de8ac05c8e85ceb98f01db@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "tutki" <nomail@nomail> wrote:
>
> > P.S. Oh nevermind, just realized povray allows the color part of each entry to
> > be variable. So I could do something like Red + Green*clock, Green + Blue*clock,
> > etc., to get what I want.
> >
> > Thanks for the idea!
>
> Yes, you've got the idea.   :)
>
> You _might_ also think about using the same static pigments in the map, but vary
> the map indices using the clock value...

Huh, the map indices are allowed to be variable too?? Wow my grasp of SDL is a
lot weaker than I thought. :-D


> colors.inc has a macro called CHSV2RGB in case the direct rgb variation doesn't
> provide what you want.
>
> https://wiki.povray.org/content/Reference:Colors.inc

Ohh, that looks very useful, thanks!


Post a reply to this message

From: Bald Eagle
Subject: Re: Interpolating between textures using clock?
Date: 3 Feb 2022 18:45:00
Message: <web.61fc68307de8ac01f9dae3025979125@news.povray.org>
"tutki" <nomail@nomail> wrote:

> Huh, the map indices are allowed to be variable too?? Wow my grasp of SDL is a
> lot weaker than I thought. :-D

Sure - they are just "values".  You can use a variable name, or an equation for
the index.

I will often do things with "lines" or bands of color that I want to control the
spread of across the color map, and I'll define a half-width (hw) of that
region, and then use n-hw and n+hw as index entries.


> > colors.inc has a macro called CHSV2RGB in case the direct rgb variation doesn't
> > provide what you want.
> >
> > https://wiki.povray.org/content/Reference:Colors.inc
>
> Ohh, that looks very useful, thanks!

Sure - color interpolation has been discussed at some length a few times in the
past.   I find the HSV space to be useful since it is continuous in "colors" and
doesn't dip down into the grayscale regions.


Post a reply to this message

From: Kenneth
Subject: Re: Interpolating between textures using clock?
Date: 7 Feb 2022 12:50:00
Message: <web.62015b887de8ac04cef624e6e066e29@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:

>
> Probably best to do this around the HSV wheel, rather than directly in
> rgb-space, otherwise you usually cross through a gray-region....
>
> colors.inc has a macro called CHSV2RGB in case the direct rgb
> variation doesn't provide what you want.
>
>  https://wiki.povray.org/content/Reference:Colors.inc
>
> ...color interpolation has been discussed at some length a few times in the
> past.   I find the HSV space to be useful since it is continuous in "colors" and
> doesn't dip down into the grayscale regions.

I didn't know this either. Will investigate!
Thanks.


Post a reply to this message

Copyright 2003-2021 Persistence of Vision Raytracer Pty. Ltd.