tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

shared.html (4515B)


      1 <!--
      2 Copyright (c) 2019 The Khronos Group Inc.
      3 Use of this source code is governed by an MIT-style license that can be
      4 found in the LICENSE.txt file.
      5 -->
      6 
      7 <!DOCTYPE html>
      8 <html>
      9 <head>
     10 <meta charset="utf-8">
     11 <title>WebGL GLSL Conformance Tests</title>
     12 <link rel="stylesheet" href="../../../resources/js-test-style.css"/>
     13 <link rel="stylesheet" href="../../../resources/glsl-feature-tests.css"/>
     14 <script src="../../../js/js-test-pre.js"></script>
     15 <script src="../../../js/webgl-test-utils.js"></script>
     16 <script src="../../../js/glsl-conformance-test.js"></script>
     17 </head>
     18 <body>
     19 <div id="description"></div>
     20 <div id="console"></div>
     21 <script id="sharedVertexShader" type="text/something-not-javascript">
     22 // shared vertex shader should succeed.
     23 uniform mat4 viewProjection;
     24 uniform vec3 worldPosition;
     25 uniform vec3 nextPosition;
     26 uniform float fishLength;
     27 uniform float fishWaveLength;
     28 uniform float fishBendAmount;
     29 attribute vec4 position;
     30 attribute vec2 texCoord;
     31 varying vec4 v_position;
     32 varying vec2 v_texCoord;
     33 varying vec3 v_surfaceToLight;
     34 void main() {
     35  vec3 vz = normalize(worldPosition - nextPosition);
     36  vec3 vx = normalize(cross(vec3(0,1,0), vz));
     37  vec3 vy = cross(vz, vx);
     38  mat4 orientMat = mat4(
     39    vec4(vx, 0),
     40    vec4(vy, 0),
     41    vec4(vz, 0),
     42    vec4(worldPosition, 1));
     43  mat4 world = orientMat;
     44  mat4 worldViewProjection = viewProjection * world;
     45  mat4 worldInverseTranspose = world;
     46 
     47  v_texCoord = texCoord;
     48  // NOTE:If you change this you need to change the laser code to match!
     49  float mult = position.z > 0.0 ?
     50      (position.z / fishLength) :
     51      (-position.z / fishLength * 2.0);
     52  float s = sin(mult * fishWaveLength);
     53  float a = sign(s);
     54  float offset = pow(mult, 2.0) * s * fishBendAmount;
     55  v_position = (
     56      worldViewProjection *
     57      (position +
     58       vec4(offset, 0, 0, 0)));
     59  v_surfaceToLight = (world * position).xyz;
     60  gl_Position = v_position;
     61 }
     62 </script>
     63 <script id="fragmentShaderA" type="text/something-not-javascript">
     64 // shared fragment shader should succeed.
     65 precision mediump float;
     66 uniform vec4 lightColor;
     67 varying vec4 v_position;
     68 varying vec2 v_texCoord;
     69 varying vec3 v_surfaceToLight;
     70 
     71 uniform vec4 ambient;
     72 uniform sampler2D diffuse;
     73 uniform vec4 specular;
     74 uniform float shininess;
     75 uniform float specularFactor;
     76 // #fogUniforms
     77 
     78 vec4 lit(float l ,float h, float m) {
     79  return vec4(1.0,
     80              max(l, 0.0),
     81              (l > 0.0) ? pow(max(0.0, h), m) : 0.0,
     82              1.0);
     83 }
     84 void main() {
     85  vec4 diffuseColor = texture2D(diffuse, v_texCoord);
     86  vec4 normalSpec = vec4(0,0,0,0);  // #noNormalMap
     87  vec3 surfaceToLight = normalize(v_surfaceToLight);
     88  vec3 halfVector = normalize(surfaceToLight);
     89  vec4 litR = lit(1.0, 1.0, shininess);
     90  vec4 outColor = vec4(
     91    (lightColor * (diffuseColor * litR.y + diffuseColor * ambient +
     92                  specular * litR.z * specularFactor * normalSpec.a)).rgb,
     93      diffuseColor.a);
     94  // #fogCode
     95  gl_FragColor = outColor;
     96 }
     97 </script>
     98 <script id="fragmentShaderB" type="text/something-not-javascript">
     99 // shared fragment shader should succeed.
    100 precision mediump float;
    101 varying vec4 v_position;
    102 varying vec2 v_texCoord;
    103 varying vec3 v_surfaceToLight;
    104 
    105 // #fogUniforms
    106 
    107 vec4 lit(float l ,float h, float m) {
    108  return vec4(1.0,
    109              max(l, 0.0),
    110              (l > 0.0) ? pow(max(0.0, h), m) : 0.0,
    111              1.0);
    112 }
    113 void main() {
    114  vec4 normalSpec = vec4(0,0,0,0);  // #noNormalMap
    115  vec4 reflection = vec4(0,0,0,0);  // #noReflection
    116  vec3 surfaceToLight = normalize(v_surfaceToLight);
    117  vec4 skyColor = vec4(0.5,0.5,1,1);  // #noReflection
    118 
    119  vec3 halfVector = normalize(surfaceToLight);
    120  vec4 litR = lit(1.0, 1.0, 10.0);
    121  vec4 outColor = vec4(mix(
    122      skyColor,
    123      vec4(1,2,3,4) * (litR.y + litR.z * normalSpec.a),
    124      1.0 - reflection.r).rgb,
    125      1.0);
    126  // #fogCode
    127  gl_FragColor = outColor;
    128 }
    129 </script>
    130 <script>
    131 "use strict";
    132 GLSLConformanceTester.runTests([
    133  { vShaderSource: document.getElementById("sharedVertexShader").text,
    134    vShaderSuccess: true,
    135    fShaderSource: document.getElementById("fragmentShaderA").text,
    136    fShaderSuccess: true,
    137    linkSuccess: true,
    138    passMsg: 'shared fragment shader should succeed',
    139  },
    140  { vShaderSource: document.getElementById("sharedVertexShader").text,
    141    vShaderSuccess: true,
    142    fShaderSource: document.getElementById("fragmentShaderB").text,
    143    fShaderSuccess: true,
    144    linkSuccess: true,
    145    passMsg: 'shared fragment shader should succeed',
    146  }
    147 ]);
    148 var successfullyParsed = true;
    149 </script>
    150 </body>
    151 </html>