Skip to content

Commit 71e67fc

Browse files
committed
add another filter effect to squares.html
1 parent 83b2bfa commit 71e67fc

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

glutil.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,8 @@ function LightSource(position, ambient, diffuse, specular) {
497497
* number is the W component.<ul>
498498
* <li>If W is 0, then X, Y, and Z specify a 3-element vector giving the direction
499499
* of the light; the light will shine everywhere in the given direction.
500-
* <li>If W is 0, then X, Y, and Z specify the position of the light in world
501-
* space; the light will shine brightest at the given position.</p>
500+
* <li>If W is 1, then X, Y, and Z specify the position of the light in world
501+
* space; the light will shine brightest, and in every direction, at the given position.</ul>
502502
* <li><code>ambient</code> - Not used in the default shader program.
503503
* <li><code>diffuse</code> - Diffuse color.
504504
* <li><code>specular</code> - Specular highlight color.

squares.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ <h1>Shader Filters</h1>
1010
<a href="javascript:link4()">Blur</a>,
1111
<a href="javascript:link5()">Pixelate</a>,
1212
<a href="javascript:link6()">Waterpaint</a>,
13+
<a href="javascript:link7()">Mirror</a>,
1314
<a href="javascript:linknone()">No filters</a><br>
1415
<a href="javascript:link1a()">Blinds</a>,
1516
<a href="javascript:link2a()">Platonic solids</a>
@@ -137,6 +138,14 @@ <h1>Shader Filters</h1>
137138
"}"].join("\n"));
138139
}
139140

141+
function makeMirror(context){
142+
return ShaderProgram.makeEffect(context,[
143+
"vec4 textureEffect(sampler2D sampler, vec2 uvCoord, vec2 textureSize){",
144+
" vec4 color=texture2D(sampler,vec2(1.0-uvCoord.x,uvCoord.y));",
145+
" return color;",
146+
"}"].join("\n"));
147+
}
148+
140149
function link1(){
141150
if(scene){
142151
if(currentFilter)currentFilter.dispose();
@@ -198,6 +207,13 @@ <h1>Shader Filters</h1>
198207
scene.useFilter(currentFilter);
199208
}
200209
}
210+
function link7(){
211+
if(scene){
212+
if(currentFilter)currentFilter.dispose();
213+
currentFilter=makeMirror(scene);
214+
scene.useFilter(currentFilter);
215+
}
216+
}
201217
function linknone(){
202218
if(scene){
203219
if(currentFilter)currentFilter.dispose();

0 commit comments

Comments
 (0)