|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
hi,
can someone please point me to a color_map example which provides a
smooth blend/gradient from (ideally) blue at 0 to red at 1 in 254
increments? I'd prefer a solution which does not require (an array of)
named colours.
thank you, jr.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
jr <cre### [at] gmailcom> wrote:
>
> can someone please point me to a color_map example which provides a
> smooth blend/gradient from (ideally) blue at 0 to red at 1 in 254
> increments? I'd prefer a solution which does not require (an array of)
> named colours.
>
> thank you, jr.
Thinking ahead here: You are welcome!
You will probably get the idea from my fast example. Funny thing, still took me
half hour to write and edit again and again! I wanted it to do stepped colors
too, and comment on parts.
Bob
P.S. you can ignore the "by bob", no need to keep that. :)
/* SIMPLE SPECIFIC NUMBER OF COLORS FOR A GRADIENT PATTERN by bob */
#declare BeginColorCount=1; // or zero and < EndColorCount
#declare EndColorCount=254; // or > BeginColorCount
#declare StepsCount=12; // number to increment by (1 is good too)
box { // apply to this shape
0.00001,0.99999 // unequalize surface and color map
pigment {
gradient x // choose a directional axis
//ramp_wave // default
color_map {
#for (It,BeginColorCount,EndColorCount,StepsCount)
[
It/EndColorCount, (It+StepsCount)/EndColorCount
color rgb <(EndColorCount-It)/EndColorCount,0,It/EndColorCount>
color rgb <(EndColorCount-It)/EndColorCount,0,It/EndColorCount>
]
#end
}
}
finish {
ambient 1 emission 0 diffuse 0 // see it without light
}
translate -0.5 // center on origin vector
scale 2 // double unit size
rotate <30,30,30> // change orientation
translate <0,0,4> // move location
}
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"omniverse" <omn### [at] charternet> wrote:
> jr <cre### [at] gmailcom> wrote:
> >
> > can someone please point me to a color_map example which provides a
> > smooth blend/gradient from (ideally) blue at 0 to red at 1 in 254
> > increments?
Sorry, I blame my awful speed reading. I put the red first and blue last, not
the way you said there.
And guess I should have asked why "254" instead of the usual 0 to 255. Won't
matter really, you only need to change the numbers to what you want.
Below is the blue to red way, obviously only a switch around of the rgb elements
to do that. And complete 256 color gradation, of course, just to show that.
Hopefully I did this example correctly, since I am known for flawing the
simplist things... and fouling up complexities for sure.
:D
Bob
#declare BeginColorCount=0; // or zero and < EndColorCount
#declare EndColorCount=255; // or > BeginColorCount
#declare StepsCount=1; // number to increment by (1 is good too)
box { // apply to this shape
0.00001,0.99999 // unequalize surface and color map
pigment {
gradient x // choose a directional axis
//ramp_wave // default
color_map {
#for (It,BeginColorCount,EndColorCount,StepsCount)
[
It/EndColorCount, (It+StepsCount)/EndColorCount
color rgb <It/EndColorCount,0,(EndColorCount-It)/EndColorCount>
color rgb <It/EndColorCount,0,(EndColorCount-It)/EndColorCount>
]
#end
}
}
finish {
ambient 1 emission 0 diffuse 0 // see it without light
}
translate -0.5 // center on origin vector
scale 2 // double unit size
rotate <30,30,30> // change orientation
translate <0,0,4> // move location
}
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Am 22.07.2017 um 00:28 schrieb jr:
> hi,
>
> can someone please point me to a color_map example which provides a
> smooth blend/gradient from (ideally) blue at 0 to red at 1 in 254
> increments? I'd prefer a solution which does not require (an array of)
> named colours.
>
> thank you, jr.
For a smooth gradient, all you need are the two color_map entries at 0
and 1:
pigment {
gradient x
color_map {
[0, <0,0,1>]
[1, <1,0,0>]
}
}
This will give the exact same gradient as omniverse's suggestion. If it
is not to your liking, you'll have to specify additional constraints for
the gradient.
If you're unhappy with the above gradient and feel that its brightness
appears non-linear, try the `blend_mode` parameter, and maybe also
`blend_gamma`. For aesthetically pleasing results, `blend_mode 3` is
currently the best choice; it interpolates chromaticity and brightness
separately, using non-linear interpolation for the latter:
global_settings { assumed_gamma 1.0 }
...
pigment {
gradient x
color_map {
blend_mode 3
blend_gamma 2.5 // default
[0, <0,0,1>]
[1, <1,0,0>]
}
}
If you're actually interested in the numerical values, you can use the
`eval_pigment` function.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Am 22.07.2017 um 09:31 schrieb clipka:
> This will give the exact same gradient as omniverse's suggestion.
Hm... no, actually not. Reading omniverse's suggestion again, he seems
to be using steps, i.e. not a smooth gradient at all.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Am 22.07.2017 um 06:26 schrieb omniverse:
> #for (It,BeginColorCount,EndColorCount,StepsCount)
> [
> It/EndColorCount, (It+StepsCount)/EndColorCount
> color rgb <(EndColorCount-It)/EndColorCount,0,It/EndColorCount>
> color rgb <(EndColorCount-It)/EndColorCount,0,It/EndColorCount>
> ]
> #end
That syntax is obsolete, and should be avoided. Instead, use the
following for exactly the same effect:
#for (It,BeginColorCount,EndColorCount,StepsCount)
[
It/EndColorCount,
color rgb <(EndColorCount-It)/EndColorCount,0,It/EndColorCount>
]
[
(It+StepsCount)/EndColorCount,
color rgb <(EndColorCount-It)/EndColorCount,0,It/EndColorCount>
]
#end
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
hi,
thank you for the quick replies, Omniverse & Clipka.
On 22/07/2017 06:16, omniverse wrote:
> And guess I should have asked why "254" instead of the usual 0 to 255.
> Won't matter really, you only need to change the numbers to what you
> want.
simple memory fault :-( I thought I'd read 254 being the max # entries
but, checking, the doc does say "from 2 to 256 entries".
On 22/07/2017 08:31, clipka wrote:
> If you're unhappy with the above gradient and feel that its brightness
> appears non-linear, try the `blend_mode` parameter, and maybe also
> `blend_gamma`. For aesthetically pleasing results, `blend_mode 3` is
> currently the best choice; it interpolates chromaticity and brightness
> separately, using non-linear interpolation for the latter:
>
> global_settings { assumed_gamma 1.0 }
> ...
>
> pigment {
> gradient x
> color_map {
> blend_mode 3
> blend_gamma 2.5 // default
> [0, <0,0,1>]
> [1, <1,0,0>]
> }
> }
I just tried this and get good-ish results (a little too homogeneous
perhaps (the color_map is used to visualise data in a DF3)), but there's
no mention of the blend_* constraints in the installed (v 3.7.1a)
documentation. I'll have a look in the online docs later.
again, many thanks.
jr.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Am 22.07.2017 um 11:04 schrieb jr:
> On 22/07/2017 06:16, omniverse wrote:
>> And guess I should have asked why "254" instead of the usual 0 to 255.
>> Won't matter really, you only need to change the numbers to what you
>> want.
>
> simple memory fault :-( I thought I'd read 254 being the max # entries
> but, checking, the doc does say "from 2 to 256 entries".
... and, as a matter of fact, that's no longer valid for current
versions anyway ;)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Le 22/07/2017 à 00:28, jr a écrit :
> hi,
>
> can someone please point me to a color_map example which provides a
> smooth blend/gradient from (ideally) blue at 0 to red at 1 in 254
> increments? I'd prefer a solution which does not require (an array of)
> named colours.
>
> thank you, jr.
>
You can try this :
// --- build colors map ---------------------------------
#declare colorStart = <1.00, 0.00, 0.00>; // Red
#declare colorEnd = <0.00, 0.00, 1.00>; // Blue
#declare colorDelta = colorEnd - colorStart;
#declare nStep = 64; // or others values
#declare colorStep = colorDelta/(nStep);
#declare myMap = color_map {
#declare index = 0;
#while (index <= nStep)
#declare c = colorStart + index*colorStep;
#declare s = index/nStep;
[ s rgb c]
#declare index=index+1;
#end
}
// --- use colors map --------------------------------
box {
<0, 0, 0>,< 5, 5, 100>
pigment {
gradient z
color_map { myMap }
scale <1,1,100>
}
}
--
Kurtz le pirate
Compagnie de la Banquise
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Le 22/07/2017 à 00:28, jr a écrit :
> hi,
>
> can someone please point me to a color_map example which provides a
> smooth blend/gradient from (ideally) blue at 0 to red at 1 in 254
> increments? I'd prefer a solution which does not require (an array of)
> named colours.
From Blue to Red... in which colorspace would the transition be ?
The naive might expects a change in Hue, in HSV or HSL colorspace, with
a vibrant magenta at 0.5 (or going the other way on the circle, blue,
cyan, green, yellow, red ?)
You might want to have a look at the CHSL2RGB macro from colors.inc and
use it in the code provided in the other posts of this thread.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|