Variable parsing within DEFINE_SHADER

timbottimbot Global Mapper UserPosts: 7
Hi,
I need to change a shader range based on a variable, something like this:

DEFINE_SHADER SHADER_NAME="Shader" BLEND_COLORS=NO STRETCH_TO_RANGE=NO SHADE_SLOPES=NO
 %AD_ELEV_METRES%,RGB(0,0,0)
 %AD_ELEV_METRES%+150.0,RGB(248,219,200)
 %AD_ELEV_METRES%+300.0,RGB(244,178,131)
 %AD_ELEV_METRES%+450.0,RGB(240,151,85)
 %AD_ELEV_METRES%+600.0,RGB(255,128,0)
END_DEFINE_SHADER

Is there any way to have a variable passed in within a DEFINE_SHADER block?
Thanks
Tim

Best Answer

  • bmg_bobbmg_bob Global Mapper Programmer Posts: 1,682
    Answer ✓
    Hello,

    This the ability to use variables to define the shader range in a script has been implemented. The new function will be available in GM 18.1 daily builds dated May 5, 2017 or later.  Simply download the appropriate installer and run it to install the latest build.

    Note that you will not be able to specify variables as you have done in your sample.  Inside the DEFINE_SHADER command, you can specify a variable name, but not an expression.  Here is a sample of how you can use variables to do something similar to what you want:
    DEFINE_VAR NAME="ELEV" VALUE="100"
    DEFINE_VAR NAME="ELEV_100" FORMULA="%ELEV% + 100"
    DEFINE_VAR NAME="ELEV_200" FORMULA="%ELEV% + 200"
    DEFINE_SHADER SHADER_NAME="Shader" BLEND_COLORS=NO STRETCH_TO_RANGE=NO SHADE_SLOPES=NO OVERWRITE_EXISTING=YES
     %ELEV%,RGB(0,0,0)
     %ELEV_100%,RGB(248,219,200)
     %ELEV_200%,RGB(244,178,131)
    END_DEFINE_SHADER
    Cheers,
    Bob

Answers

  • bmg_bobbmg_bob Global Mapper Programmer Posts: 1,682
    Hello Tim,

    At the moment, Global Mapper does not allow variables inside a DEFINE_SHADER command.  I have added item #21468 to our task list so we can evaluate adding variable substitution to DEFINE_SHADER.  We will post a message on this thread when its status changes.

    Cheers,
    Bob
  • timbottimbot Global Mapper User Posts: 7
    Thanks Bob, appreciate that.
    Tim
Sign In or Register to comment.