Sophie

Sophie

distrib > Mageia > 6 > armv7hl > by-pkgid > dabf927d465c36ba2d7621d5cd1fe76f > files > 386

qt3d5-doc-5.9.4-1.mga6.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>water.vert Example File | Qt 3D 5.9</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.9</td><td ><a href="qt3d-index.html">Qt 3D</a></td><td ><a href="qt3d-advancedcustommaterial-example.html">Qt 3D: Advanced custom material QML Example</a></td><td >water.vert Example File</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar"><div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">water.vert Example File</h1>
<span class="subtitle">advancedcustommaterial/shaders/es2/water.vert</span>
<!-- $$$advancedcustommaterial/shaders/es2/water.vert-description -->
<div class="descr"> <a name="details"></a>
<pre class="cpp">

  #define FP highp

  attribute FP vec3 vertexPosition;
  attribute FP vec3 vertexNormal;
  attribute FP vec2 vertexTexCoord;
  attribute FP vec4 vertexTangent;

  varying FP vec3 worldPosition;
  varying FP vec2 texCoord;
  varying FP vec2 movtexCoord;
  varying FP vec2 multexCoord;
  varying FP vec2 waveTexCoord;
  varying FP vec2 skyTexCoord;
  varying FP mat3 tangentMatrix;
  varying FP vec3 vpos;

  uniform FP mat4 modelMatrix;
  uniform FP mat3 modelNormalMatrix;
  uniform FP mat4 mvp;

  uniform FP float offsetx;
  uniform FP float offsety;
  uniform FP float vertYpos;
  uniform FP float texCoordScale;
  uniform FP float waveheight;
  uniform FP float waveRandom;

  void main()
  {
      // Scale texture coordinates for for fragment shader
      texCoord = vertexTexCoord * texCoordScale;
      movtexCoord = vertexTexCoord * texCoordScale;
      multexCoord = vertexTexCoord * (texCoordScale*0.5);
      waveTexCoord = vertexTexCoord * (texCoordScale * 6.0);
      skyTexCoord = vertexTexCoord * (texCoordScale * 0.2);

      // Add Animated x and y Offset to SKY, MOV and MUL texCoords
      movtexCoord = vec2(texCoord.x+offsetx,texCoord.y+offsety);
      multexCoord = vec2(texCoord.x-offsetx,texCoord.y+offsety);
      skyTexCoord = vec2(texCoord.x-(offsetx/2.0),texCoord.y-(offsety/2.0));

      // Transform position, normal, and tangent to world coords
      worldPosition = vec3(modelMatrix * vec4(vertexPosition, 1.0));
      FP vec3 normal = normalize(modelNormalMatrix * vertexNormal);
      FP vec3 tangent = normalize(vec3(modelMatrix * vec4(vertexTangent.xyz, 0.0)));

      // Make the tangent truly orthogonal to the normal by using Gram-Schmidt.
      // This allows to build the tangentMatrix below by simply transposing the
      // tangent -&gt; world space matrix (which would now be orthogonal)
      tangent = normalize(tangent - dot(tangent, normal) * normal);

      // Calculate binormal vector. No &quot;real&quot; need to renormalize it,
      // as built by crossing two normal vectors.
      // To orient the binormal correctly, use the fourth coordinate of the tangent,
      // which is +1 for a right hand system, and -1 for a left hand system.
      FP vec3 binormal = cross(normal, tangent) * vertexTangent.w;

      // Construct matrix to transform from eye coords to tangent space
      tangentMatrix = mat3(
          tangent.x, binormal.x, normal.x,
          tangent.y, binormal.y, normal.y,
          tangent.z, binormal.z, normal.z);

      // Calculate animated vertex positions

      FP float sinPos = (vertexPosition.z)+(vertexPosition.x);
      FP float sinPos2 = (vertexPosition.y/2.0)+(vertexPosition.z);
      FP vec3 vertMod = vec3(vertexPosition.x,vertexPosition.y,vertexPosition.z);

      vertMod = vec3(vertMod.x+=sin(vertYpos*2.2-sinPos2)*waveheight,
                     vertMod.y=sin(vertYpos*2.2+sinPos)*waveheight,
                     vertMod.z-=sin(vertYpos*2.2-cos(sinPos2))*waveheight);

      FP vec3 vertModCom = vec3(vertMod.x+=cos(vertYpos*2.2-cos(sinPos2))*waveheight,
                             vertMod.y=sin(vertYpos*2.2+cos(sinPos))*waveheight,
                             vertMod.z-=cos(vertYpos*2.2-cos(sinPos))*waveheight);

      // Add wave animation only to vertices above world pos.y zero
      if(vertexPosition.y &lt; 0.0){vertModCom = vertexPosition;}
      else{vertModCom = vertModCom;}

      vpos = vertModCom;

      // Calculate vertex position in clip coordinates
      gl_Position = mvp * vec4(vertModCom, 1.0);
  }

</pre>
</div>
<!-- @@@advancedcustommaterial/shaders/es2/water.vert -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2017 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>