POV-Ray : Newsgroups : povray.binaries.scene-files : Dakota Red Granite macro - beta #1 : Re: Dakota Red Granite macro - beta #1.1 Server Time
18 Apr 2024 21:05:50 EDT (-0400)
  Re: Dakota Red Granite macro - beta #1.1  
From: Bald Eagle
Date: 16 May 2021 18:05:00
Message: <web.60a195ef581f2f681f9dae3025979125@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:

> I am thinking that we could consolidate the color_map code by using a macro, so
> you can select which macro to run, rather than which full color map to parse.
>
> In that line of thinking, we could also perhaps make the color map itself a lot
> smaller using and array and a loop.

For your consideration:

#macro Convert (Csc, SatBoost, BrightBoost, Color)
 #switch (Csc)
 #case (1)
  #local MyColour   = srgb Color;
 #break
 #case (2)
  #local sRGB_Gamma = function(C) {select(C-0.0031308, C*12.92, 1.055*pow(C,
1/2.4)-0.055)}

  #local SB         = SatBoost; // Saturation boost
  #local VB         = BrightBoost; // Brightness ("volume") boost
  #local RawColour  = srgb <sRGB_Gamma(Color.red), sRGB_Gamma(Color.green),
sRGB_Gamma(Color.blue)>;
  #local SatColour  = RawColour-SB;
  #local MyColour   = SatColour*(1+VB)*RawColour.gray/SatColour.gray;
 #break
 #else
  #local MyColour   = Color;
 #end

 MyColour

#end

#declare CSC = 1;

 #local CM = array {
    <0.00, not_0, not_0, not_0>,
    <0.25, 0.059, 0.059, 0.059>,

    <0.25, 0.086, 0.027, 0.059>,
    <0.35, 0.086, 0.027, 0.059>,

    <0.35, 0.118, 0.118, 0.078>,
    <0.45, 0.118, 0.118, 0.078>,

    <0.45, 0.200, 0.137, 0.110>,
    <0.50, 0.150, 0.087, 0.060>,
    <0.57, 0.200, 0.137, 0.110>,

    <0.57, 0.400, 0.337, 0.310>,
    <0.60, 0.350, 0.287, 0.260>,
    <0.63, 0.400, 0.337, 0.310>,

    <0.63, 0.769, 0.329, 0.298>,
    <0.70, 0.669, 0.229, 0.198>,
    <0.75, 0.769, 0.329, 0.298>,

    <0.75, 0.600, 0.600, 0.600>,
    <0.85, 0.550, 0.550, 0.550>,
    <1.00, 0.650, 0.650, 0.650>
 }

#local C_gr21_DakotaRed_map1 = //the granite colour_map proper
color_map {
  #if (version >= 3.8)
    blend_mode 2
  #end
  #local Entries = dimension_size (CM, 1)-1;
  #for (E, 0, Entries)
  [CM[E].x rgb <CM[E].y, CM[E].z, CM[E].filter>]
  #end
}


Post a reply to this message

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