Skip to content

Commit

Permalink
Examples: Fixed webgl2 examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Jul 20, 2020
1 parent a4df678 commit b05b4b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
12 changes: 5 additions & 7 deletions examples/webgl2_buffergeometry_attributes_integer.html
Expand Up @@ -11,7 +11,7 @@
<div id="container"></div>
<div id="info"><a href="https://threejs.org" target="_blank" rel="noopener">three.js</a> WebGL 2 - buffergeometry - integer attributes</div>

<script id="vertexShader" type="x-shader/x-vertex">#version 300 es
<script id="vertexShader" type="x-shader/x-vertex">
in int textureIndex;

flat out int vIndex; // "flat" indicates that the value will not be interpolated (required for integer attributes)
Expand All @@ -27,19 +27,17 @@
}
</script>

<script id="fragmentShader" type="x-shader/x-fragment">#version 300 es
<script id="fragmentShader" type="x-shader/x-fragment">
flat in int vIndex;
in vec2 vUv;

uniform sampler2D uTextures[ 3 ];

out vec4 outColor;

void main() {

if ( vIndex == 0 ) outColor = texture( uTextures[ 0 ], vUv );
else if ( vIndex == 1 ) outColor = texture( uTextures[ 1 ], vUv );
else if ( vIndex == 2 ) outColor = texture( uTextures[ 2 ], vUv );
if ( vIndex == 0 ) gl_FragColor = texture( uTextures[ 0 ], vUv );
else if ( vIndex == 1 ) gl_FragColor = texture( uTextures[ 1 ], vUv );
else if ( vIndex == 2 ) gl_FragColor = texture( uTextures[ 2 ], vUv );

}
</script>
Expand Down
7 changes: 1 addition & 6 deletions examples/webgl2_materials_texture2darray.html
Expand Up @@ -7,8 +7,6 @@
<link type="text/css" rel="stylesheet" href="main.css">
</head>
<script id="vs" type="x-shader/x-vertex">
#version 300 es

uniform vec2 size;
out vec2 vUv;

Expand All @@ -25,23 +23,20 @@
</script>

<script id="fs" type="x-shader/x-fragment">
#version 300 es

precision highp float;
precision highp int;
precision highp sampler2DArray;

uniform sampler2DArray diffuse;
in vec2 vUv;
uniform int depth;
out vec4 out_FragColor;

void main() {

vec4 color = texture( diffuse, vec3( vUv, depth ) );

// lighten a bit
out_FragColor = vec4( color.rrr * 1.5, 1.0 );
gl_FragColor = vec4( color.rrr * 1.5, 1.0 );

}
</script>
Expand Down

0 comments on commit b05b4b9

Please sign in to comment.