gm-docs-parser 1.0.0

A collection of typings for GameMaker Studio 2 manual pages
Documentation
<?xml version="1.0" encoding="utf-8" ?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head>

  <script type="text/javascript" language="JavaScript">
    //<![CDATA[
    function reDo() {
      if (innerWidth != origWidth || innerHeight != origHeight)
        location.reload();
    }
    if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == "Netscape")) {
      origWidth = innerWidth;
      origHeight = innerHeight;
      onresize = reDo;
    }
    onerror = null;
  //]]>
  </script>
  <style type="text/css">/*<![CDATA[*/

    < !-- div.WebHelpPopupMenu {
      position: absolute;
      left: 0px;
      top: 0px;
      z-index: 4;
      visibility: hidden;
    }

    p.WebHelpNavBar {
      text-align: right;
    }

    -->
  
/*]]>*/</style>

  <script type="text/javascript">//<![CDATA[

    gRootRelPath = "../../../..";
    gCommonRootRelPath = "../../../..";
    gTopicId = "9.2.2.8.0_16";
  
//]]></script>

  <script type="text/javascript" src="../../../../template/scripts/rh.min.js"></script>
  <script type="text/javascript" src="../../../../template/scripts/common.min.js"></script>
  <script type="text/javascript" src="../../../../template/scripts/topic.min.js"></script>
  <script type="text/javascript" src="../../../../template/scripts/topicwidgets.min.js"></script>
<script type="text/javascript" src="../../../../whxdata/projectsettings.js"></script>
  <link rel="stylesheet" type="text/css" href="../../../../template/styles/topic.min.css"/>
  <link rel="stylesheet" type="text/css" href="../../../../template/Charcoal_Grey/topicheader.css"/>
  <meta name="topic-status" content="Draft"/>

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <title>Shader Constants</title>
  <meta name="generator" content="Adobe RoboHelp 2019"/>
  <link rel="stylesheet" href="../../../../assets/css/default.css" type="text/css"/>
  <meta name="rh-authors" content="Mark Alexander"/>
  <meta name="topic-comment" content="Page outlining the different Shader Constants"/>
  <meta name="rh-index-keywords" content="gm_Matrices,MATRIX_VIEW,MATRIX_PROJECTION,MATRIX_WORLD,MATRIX_WORLD_VIEW,MATRIX_WORLD_VIEW_PROJECTION,MATRIX_MAX,MAX_VS_LIGHTS,gm_BaseTexture,gm_LightingEnabled,gm_FogStart,gm_RcpFogRange,gm_PS_FogEnabled,gm_FogColour,gm_VS_FogEnabled,gm_AlphaTestEnabled,gm_AlphaRefValue"/>
  <meta name="search-keywords" content="Shader Constants,gm_Matrices,MATRIX_VIEW,MATRIX_PROJECTION,MATRIX_WORLD,MATRIX_WORLD_VIEW,MATRIX_WORLD_VIEW_PROJECTION,MATRIX_MAX,MAX_VS_LIGHTS,gm_BaseTexture,gm_LightingEnabled,gm_FogStart,gm_RcpFogRange,gm_PS_FogEnabled,gm_FogColour,gm_VS_FogEnabled,gm_AlphaTestEnabled,gm_AlphaRefValue"/>
</head>

<body>
  <div class="topic-header rh-hide" id="rh-topic-header" onclick="rh._.goToFullLayout()">
    <div class="logo">
    </div>
    <div class="nav">
      <div class="title" title="Shader Constants">
        <span>Shader Constants</span>
      </div>
      <div class="gotohome" title="Click here to see this page in full context">
        <span>Click here to see this page in full context</span>
      </div>
    </div>
  </div>
  <div class="topic-header-shadow rh-hide" id="rh-topic-header-shadow"></div>



  <!--<div class="body-scroll" style="top: 150px;">-->
  <h1>Shader Constants</h1>
  <p>Apart from the shader functions and constants defined in the OpenGL ES Shading Language (GLSL ES) <a href="http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf" target="_blank">Reference Pages</a>, there are also a number
    of shader constants available to you that are unique to GameMaker Studio 2.</p>
  <p>The following display matrix constants can be used as array indices when using the shader array constant <tt>gm_Matrices</tt>:</p>
  <p> </p>
  <table>
    <tbody>
      <tr>
        <th>Constant</th>
        <th>Description</th>
      </tr>
      <tr>
        <td>MATRIX_VIEW</td>
        <td>This array index constant holds the index to the current view matrix. The index returned would be used as an array value when calling the <tt>gm_Matrices</tt> constant within the shader code.</td>
      </tr>
      <tr>
        <td>MATRIX_PROJECTION</td>
        <td>This array index constant holds the index to the current projection matrix. The index returned would be used as an array value when calling the <tt>gm_Matrices</tt> constant within the shader code.</td>
      </tr>
      <tr>
        <td>MATRIX_WORLD</td>
        <td>This array index constant holds the index to the current world matrix. This can be used for things like lighting if you have light information in world-space. The index returned would be used as an array value when calling the <tt>gm_Matrices</tt>          constant within the shader code.</td>
      </tr>
      <tr>
        <td>MATRIX_WORLD_VIEW</td>
        <td>This array index constant holds the index to the result of the world and view matrices multiplied together. This is often used for things like fog. The index returned would be used as an array value when calling the <tt>gm_Matrices</tt> constant
          within the shader code.</td>
      </tr>
      <tr>
        <td>MATRIX_WORLD_VIEW_PROJECTION</td>
        <td>This array index constant holds the index to the result of the world, view and projection matrices multiplied together. This is the normal transformation matrix used for vertex positions. The index returned would be used as an array value when
          calling the <tt>gm_Matrices</tt> constant within the shader code.</td>
      </tr>
      <tr>
        <td>MATRIX_MAX</td>
        <td>This is not an array index, but rather returns the size of the matrix array in the vertex shader.</td>
      </tr>
      <tr>
        <td>MAX_VS_LIGHTS</td>
        <td>This is not an array index, but rather returns the number of the lights in the vertex shader.</td>
      </tr>
    </tbody>
  </table>
  <p> </p>
  <p> </p>
  <p>The following pre-defined matrix uniforms and constants can be used in your shader to access GameMaker Studio 2 specific values:</p>
  <p> </p>
  <table>
    <tbody>
      <tr>
        <th>Constant</th>
        <th>Description</th>
      </tr>
      <tr>
        <td>gm_Matrices[matrix]</td>
        <td>This array constant returns a transform matrix and is one of the available pre-defined uniforms that GameMaker Studio 2 creates for you to use within the shader code editor. The array index is chosen from one of the above listed constants.</td>
      </tr>
      <tr>
        <td>gm_BaseTexture</td>
        <td>This is a 2D sampler constant that returns the texture of the current object, as set by GameMaker Studio 2. So it would be the current sprite, surface or texture that would normally be used when drawing without the shader being called.</td>
      </tr>
      <tr>
        <td>gm_LightingEnabled</td>
        <td>This can be used to get or set the GameMaker Studio 2 lighting when using 3D.</td>
      </tr>
      <tr>
        <td>gm_FogStart</td>
        <td>This can be used to get the distance where polygons start to be blended with the fog colour.</td>
      </tr>
      <tr>
        <td>gm_RcpFogRange</td>
        <td>This can be used to get the distance at which fog is maximal and nothing can be seen anymore.</td>
      </tr>
      <tr>
        <td>gm_PS_FogEnabled</td>
        <td>This will return <tt>true</tt> or <tt>false</tt> if the GPU has pixel fog enabled or not.</td>
      </tr>
      <tr>
        <td>gm_FogColour</td>
        <td>This can be used to get the fog colour used by GameMaker Studio 2.</td>
      </tr>
      <tr>
        <td>gm_VS_FogEnabled</td>
        <td>This will return <tt>true</tt> or <tt>false</tt> if the GPU has vertex fog enabled or not.</td>
      </tr>
      <tr>
        <td>gm_AlphaTestEnabled</td>
        <td>This can be used to get alpha testing in the shader. See <a href="../../Drawing/GPU_Control/gpu_set_alphatestenable.htm"><tt>gpu_set_alphatestenable()</tt></a> for more information on alpha testing.</td>
      </tr>
      <tr>
        <td>gm_AlphaRefValue</td>
        <td>This can be used to get the current alpha testing reference value. See <a href="../../Drawing/GPU_Control/gpu_set_alphatestref.htm"><tt>gpu_set_alphatestref()</tt></a> for more information on the alpha test reference.</td>
      </tr>
    </tbody>
  </table>
  <p> </p>
  <p> </p>
  <p> </p>
  <p> </p>
  <div class="footer">
    <div class="buttons">
      <div class="clear">
        <div style="float:left">Back: <a href="Shaders.htm">Shaders</a></div>
      </div>
    </div>
    <h5>© Copyright YoYo Games Ltd. 2020 All Rights Reserved</h5>
  </div>
  <!-- KEYWORDS
Shader Constants
gm_Matrices
MATRIX_VIEW
MATRIX_PROJECTION
MATRIX_WORLD
MATRIX_WORLD_VIEW
MATRIX_WORLD_VIEW_PROJECTION
MATRIX_MAX
MAX_VS_LIGHTS
gm_Matrices[matrix]
gm_BaseTexture
gm_LightingEnabled
gm_FogStart
gm_RcpFogRange
gm_PS_FogEnabled
gm_FogColour
gm_VS_FogEnabled
gm_AlphaTestEnabled
gm_AlphaRefValue
-->
  <!-- TAGS
shader_constants
-->

</body></html>