mirror of
https://github.com/patriciogonzalezvivo/thebookofshaders
synced 2024-11-19 15:25:41 +00:00
fixing random stuff
This commit is contained in:
parent
57aed32093
commit
b3a4d66171
@ -10,15 +10,15 @@ precision mediump float;
|
|||||||
uniform vec2 u_resolution;
|
uniform vec2 u_resolution;
|
||||||
uniform float u_time;
|
uniform float u_time;
|
||||||
|
|
||||||
float shape(vec2 st, int N){
|
float shape(vec2 st, float N){
|
||||||
st = st*2.-1.;
|
st = st*2.-1.;
|
||||||
float a = atan(st.x,st.y)+PI;
|
float a = atan(st.x,st.y)+PI;
|
||||||
float r = TWO_PI/float(N);
|
float r = TWO_PI/N;
|
||||||
return cos(floor(.5+a/r)*r-a)*length(st);
|
return abs(cos(floor(.5+a/r)*r-a)*length(st));
|
||||||
}
|
}
|
||||||
|
|
||||||
float box(vec2 st, vec2 size){
|
float box(vec2 st, vec2 size){
|
||||||
return shape(st*size,4);
|
return shape(st*size,4.);
|
||||||
}
|
}
|
||||||
|
|
||||||
float rect(vec2 _st, vec2 _size){
|
float rect(vec2 _st, vec2 _size){
|
||||||
@ -28,7 +28,7 @@ float rect(vec2 _st, vec2 _size){
|
|||||||
return uv.x*uv.y;
|
return uv.x*uv.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
float hex(vec2 st, bool a, bool b, bool c, bool d, bool e, bool f){
|
float hex(vec2 st, float a, float b, float c, float d, float e, float f){
|
||||||
st = st*vec2(2.,6.);
|
st = st*vec2(2.,6.);
|
||||||
|
|
||||||
vec2 fpos = fract(st);
|
vec2 fpos = fract(st);
|
||||||
@ -36,26 +36,27 @@ float hex(vec2 st, bool a, bool b, bool c, bool d, bool e, bool f){
|
|||||||
|
|
||||||
if (ipos.x == 1.0) fpos.x = 1.-fpos.x;
|
if (ipos.x == 1.0) fpos.x = 1.-fpos.x;
|
||||||
if (ipos.y < 1.0){
|
if (ipos.y < 1.0){
|
||||||
return a? box(fpos-vec2(0.03,0.), vec2(1.)) : box(fpos, vec2(0.84,1.));
|
return mix(box(fpos, vec2(0.84,1.)),box(fpos-vec2(0.03,0.),vec2(1.)),a);
|
||||||
} else if (ipos.y < 2.0){
|
} else if (ipos.y < 2.0){
|
||||||
return b? box(fpos-vec2(0.03,0.), vec2(1.)) : box(fpos, vec2(0.84,1.));
|
return mix(box(fpos, vec2(0.84,1.)),box(fpos-vec2(0.03,0.),vec2(1.)),b);
|
||||||
} else if (ipos.y < 3.0){
|
} else if (ipos.y < 3.0){
|
||||||
return c? box(fpos-vec2(0.03,0.), vec2(1.)) : box(fpos, vec2(0.84,1.));
|
return mix(box(fpos, vec2(0.84,1.)),box(fpos-vec2(0.03,0.),vec2(1.)),c);
|
||||||
} else if (ipos.y < 4.0){
|
} else if (ipos.y < 4.0){
|
||||||
return d? box(fpos-vec2(0.03,0.), vec2(1.)) : box(fpos, vec2(0.84,1.));
|
return mix(box(fpos, vec2(0.84,1.)),box(fpos-vec2(0.03,0.),vec2(1.)),d);
|
||||||
} else if (ipos.y < 5.0){
|
} else if (ipos.y < 5.0){
|
||||||
return e? box(fpos-vec2(0.03,0.), vec2(1.)) : box(fpos, vec2(0.84,1.));
|
return mix(box(fpos, vec2(0.84,1.)),box(fpos-vec2(0.03,0.),vec2(1.)),e);
|
||||||
} else if (ipos.y < 6.0){
|
} else if (ipos.y < 6.0){
|
||||||
return f? box(fpos-vec2(0.03,0.), vec2(1.)) : box(fpos, vec2(0.84,1.));
|
return mix(box(fpos, vec2(0.84,1.)),box(fpos-vec2(0.03,0.),vec2(1.)),f);
|
||||||
}
|
}
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float hex(vec2 st, float N){
|
float hex(vec2 st, float N){
|
||||||
bool b[6];
|
float b[6];
|
||||||
float remain = floor(mod(N,64.));
|
float remain = floor(mod(N,64.));
|
||||||
for(int i = 0; i < 6; i++){
|
for(int i = 0; i < 6; i++){
|
||||||
b[i] = mod(remain,2.)==1.?true:false;
|
b[i] = 0.0;
|
||||||
|
b[i] = step(1.0,mod(remain,2.));
|
||||||
remain = ceil(remain/2.);
|
remain = ceil(remain/2.);
|
||||||
}
|
}
|
||||||
return hex(st,b[0],b[1],b[2],b[3],b[4],b[5]);
|
return hex(st,b[0],b[1],b[2],b[3],b[4],b[5]);
|
||||||
|
@ -70,7 +70,7 @@ This is a gentle step-by-step guide through the abstract and complex universe of
|
|||||||
|
|
||||||
Patricio studied and practiced psychotherapy and expressive art therapy. He holds an MFA in Design & Technology from Parsons The New School, where he now teaches. Currently he works as a Graphic Engineer at Mapzen making openSource mapping tools.
|
Patricio studied and practiced psychotherapy and expressive art therapy. He holds an MFA in Design & Technology from Parsons The New School, where he now teaches. Currently he works as a Graphic Engineer at Mapzen making openSource mapping tools.
|
||||||
|
|
||||||
<p class="header"><a href="http://twitter.com/patriciogv" target="_blank">Twitter</a> - <a href="https://github.com/patriciogonzalezvivo" target="_blank">GitHub</a> - <a href="https://vimeo.com/patriciogv" target="_blank">Vimeo</a> - <a href="https://www.flickr.com/photos/106950246@N06/" target="_blank"> Flickr</a></div>
|
<div class="header"><a href="https://twitter.com/patriciogv" target="_blank">Twitter</a> - <a href="https://github.com/patriciogonzalezvivo" target="_blank">GitHub</a> - <a href="https://vimeo.com/patriciogv" target="_blank">Vimeo</a> - <a href="https://www.flickr.com/photos/106950246@N06/" target="_blank"> Flickr</a></div>
|
||||||
|
|
||||||
## Acknowledgements
|
## Acknowledgements
|
||||||
|
|
||||||
@ -82,6 +82,8 @@ Thanks [Karim Naaji](http://karim.naaji.fr/) for contributing with support, good
|
|||||||
|
|
||||||
Thanks to everyone who has believed in this project and contributed with fixes or donations.
|
Thanks to everyone who has believed in this project and contributed with fixes or donations.
|
||||||
|
|
||||||
## Subscribe for new chapters
|
## Get new chapters
|
||||||
|
|
||||||
|
Sign up for the news letter or [follow it on Twitter](https://twitter.com/bookofshaders)
|
||||||
|
|
||||||
<form style="border:1px solid #ccc;padding:3px;text-align:center;" action="https://tinyletter.com/thebookofshaders" method="post" target="popupwindow" onsubmit="window.open('https://tinyletter.com/thebookofshaders', 'popupwindow', 'scrollbars=yes,width=800,height=600');return true"><a href="https://tinyletter.com/thebookofshaders"><p><label for="tlemail">Enter your email address</label></p></a><p><input type="text" style="width:140px" name="email" id="tlemail" /></p><input type="hidden" value="1" name="embed"/><input type="submit" value="Subscribe" /><p><a href="https://tinyletter.com" target="_blank"></a></p></form>
|
<form style="border:1px solid #ccc;padding:3px;text-align:center;" action="https://tinyletter.com/thebookofshaders" method="post" target="popupwindow" onsubmit="window.open('https://tinyletter.com/thebookofshaders', 'popupwindow', 'scrollbars=yes,width=800,height=600');return true"><a href="https://tinyletter.com/thebookofshaders"><p><label for="tlemail">Enter your email address</label></p></a><p><input type="text" style="width:140px" name="email" id="tlemail" /></p><input type="hidden" value="1" name="embed"/><input type="submit" value="Subscribe" /><p><a href="https://tinyletter.com" target="_blank"></a></p></form>
|
||||||
|
11
edit.html
11
edit.html
@ -203,16 +203,17 @@ void main(){\n\
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function render() {
|
|
||||||
billboard.setMouse(mouse)
|
|
||||||
billboard.render()
|
|
||||||
window.requestAnimFrame(render);
|
|
||||||
}
|
|
||||||
window.onload = function () {
|
window.onload = function () {
|
||||||
loadTag();
|
loadTag();
|
||||||
render();
|
render();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function render() {
|
||||||
|
billboard.setMouse(mouse)
|
||||||
|
billboard.render()
|
||||||
|
window.requestAnimFrame(render);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
42
src/codemirror/mode/clike.js
vendored
42
src/codemirror/mode/clike.js
vendored
@ -407,8 +407,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||||||
keywords: words("float int bool void " +
|
keywords: words("float int bool void " +
|
||||||
"vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 " +
|
"vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 " +
|
||||||
"mat2 mat3 mat4 " +
|
"mat2 mat3 mat4 " +
|
||||||
"sampler1D sampler2D sampler3D samplerCube " +
|
"sampler2D samplerCube " +
|
||||||
"sampler1DShadow sampler2DShadow " +
|
|
||||||
"const attribute uniform varying " +
|
"const attribute uniform varying " +
|
||||||
"break continue discard return " +
|
"break continue discard return " +
|
||||||
"for while do if else struct " +
|
"for while do if else struct " +
|
||||||
@ -417,45 +416,14 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||||||
builtin: words("radians degrees sin cos tan asin acos atan " +
|
builtin: words("radians degrees sin cos tan asin acos atan " +
|
||||||
"pow exp log exp2 sqrt inversesqrt " +
|
"pow exp log exp2 sqrt inversesqrt " +
|
||||||
"abs sign floor ceil fract mod min max clamp mix step smoothstep " +
|
"abs sign floor ceil fract mod min max clamp mix step smoothstep " +
|
||||||
"length distance dot cross normalize ftransform faceforward " +
|
"length distance dot cross normalize faceforward " +
|
||||||
"reflect refract matrixCompMult " +
|
"reflect refract matrixCompMult " +
|
||||||
"lessThan lessThanEqual greaterThan greaterThanEqual " +
|
"lessThan lessThanEqual greaterThan greaterThanEqual " +
|
||||||
"equal notEqual any all not " +
|
"equal notEqual any all not " +
|
||||||
"texture1D texture1DProj texture1DLod texture1DProjLod " +
|
"texture2D textureCube"),
|
||||||
"texture2D texture2DProj texture2DLod texture2DProjLod " +
|
|
||||||
"texture3D texture3DProj texture3DLod texture3DProjLod " +
|
|
||||||
"textureCube textureCubeLod " +
|
|
||||||
"shadow1D shadow2D shadow1DProj shadow2DProj " +
|
|
||||||
"shadow1DLod shadow2DLod shadow1DProjLod shadow2DProjLod " +
|
|
||||||
"dFdx dFdy fwidth " +
|
|
||||||
"noise1 noise2 noise3 noise4"),
|
|
||||||
atoms: words("true false " +
|
atoms: words("true false " +
|
||||||
"gl_FragColor gl_SecondaryColor gl_Normal gl_Vertex " +
|
"u_time u_resolution u_mouse " +
|
||||||
"gl_MultiTexCoord0 gl_MultiTexCoord1 gl_MultiTexCoord2 gl_MultiTexCoord3 " +
|
"gl_FragColor gl_Position gl_PointSize gl_FragCoord "),
|
||||||
"gl_MultiTexCoord4 gl_MultiTexCoord5 gl_MultiTexCoord6 gl_MultiTexCoord7 " +
|
|
||||||
"gl_FogCoord gl_PointCoord " +
|
|
||||||
"gl_Position gl_PointSize gl_ClipVertex " +
|
|
||||||
"gl_FrontColor gl_BackColor gl_FrontSecondaryColor gl_BackSecondaryColor " +
|
|
||||||
"gl_TexCoord gl_FogFragCoord " +
|
|
||||||
"gl_FragCoord gl_FrontFacing " +
|
|
||||||
"gl_FragData gl_FragDepth " +
|
|
||||||
"gl_ModelViewMatrix gl_ProjectionMatrix gl_ModelViewProjectionMatrix " +
|
|
||||||
"gl_TextureMatrix gl_NormalMatrix gl_ModelViewMatrixInverse " +
|
|
||||||
"gl_ProjectionMatrixInverse gl_ModelViewProjectionMatrixInverse " +
|
|
||||||
"gl_TexureMatrixTranspose gl_ModelViewMatrixInverseTranspose " +
|
|
||||||
"gl_ProjectionMatrixInverseTranspose " +
|
|
||||||
"gl_ModelViewProjectionMatrixInverseTranspose " +
|
|
||||||
"gl_TextureMatrixInverseTranspose " +
|
|
||||||
"gl_NormalScale gl_DepthRange gl_ClipPlane " +
|
|
||||||
"gl_Point gl_FrontMaterial gl_BackMaterial gl_LightSource gl_LightModel " +
|
|
||||||
"gl_FrontLightModelProduct gl_BackLightModelProduct " +
|
|
||||||
"gl_TextureColor gl_EyePlaneS gl_EyePlaneT gl_EyePlaneR gl_EyePlaneQ " +
|
|
||||||
"gl_FogParameters " +
|
|
||||||
"gl_MaxLights gl_MaxClipPlanes gl_MaxTextureUnits gl_MaxTextureCoords " +
|
|
||||||
"gl_MaxVertexAttribs gl_MaxVertexUniformComponents gl_MaxVaryingFloats " +
|
|
||||||
"gl_MaxVertexTextureImageUnits gl_MaxTextureImageUnits " +
|
|
||||||
"gl_MaxFragmentUniformComponents gl_MaxCombineTextureImageUnits " +
|
|
||||||
"gl_MaxDrawBuffers"),
|
|
||||||
hooks: {"#": cppHook},
|
hooks: {"#": cppHook},
|
||||||
modeProps: {fold: ["brace", "include"]}
|
modeProps: {fold: ["brace", "include"]}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user