Last active
September 11, 2017 11:33
-
-
Save MartinRGB/1d1f1e4d40c9f240c654087ecd1b59a4 to your computer and use it in GitHub Desktop.
threejs_test.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
collection head |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": 1665, | |
"name": "perfrag_light", | |
"fragment": "/**\n* Example Fragment Shader\n* Sets the color and alpha of the pixel by setting gl_FragColor\n*/\n\n// Set the precision for data types used in this shader\nprecision highp float;\nprecision highp int;\n\n// Default THREE.js uniforms available to both fragment and vertex shader\nuniform mat4 modelMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\n\n// Default uniforms provided by ShaderFrog.\nuniform vec3 cameraPosition;\nuniform float time;\n\n// A uniform unique to this shader. You can modify it to the using the form\n// below the shader preview. Any uniform you add is automatically given a form\nuniform vec3 lightPosition;\n//uniform sampler2D u_texture;\n\n// Example varyings passed from the vertex shader\nvarying vec3 vPosition;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec2 vUv2;\n\nvoid main() {\n\n // Calculate the real position of this pixel in 3d space, taking into account\n // the rotation and scale of the model. It's a useful formula for some effects.\n // This could also be done in the vertex shader\n vec3 worldPosition = ( modelMatrix * vec4( vPosition, 1.0 )).xyz;\n\n // Calculate the normal including the model rotation and scale\n vec3 worldNormal = normalize( vec3( modelMatrix * vec4( vNormal, 0.0 ) ) );\n\n vec3 lightVector = normalize( lightPosition + vec3(cos(time*4.)*2.,0.,sin(time*4.)*2.) - worldPosition );\n\n // An example simple lighting effect, taking the dot product of the normal\n // (which way this pixel is pointing) and a user generated light position\n float brightness = dot( worldNormal, lightVector );\n\n // Fragment shaders set the gl_FragColor, which is a vector4 of\n // ( red, green, blue, alpha ).\n gl_FragColor = vec4( vec3(1.) * brightness, 1.0 );\n\n}", | |
"vertex": "/**\n* Example Vertex Shader\n* Sets the position of the vertex by setting gl_Position\n*/\n\n// Set the precision for data types used in this shader\nprecision highp float;\nprecision highp int;\n\n// Default THREE.js uniforms available to both fragment and vertex shader\nuniform mat4 modelMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\n\n// Default uniforms provided by ShaderFrog.\nuniform float time;\n\n// Default attributes provided by THREE.js. Attributes are only available in the\n// vertex shader. You can pass them to the fragment shader using varyings\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n\n// Examples of variables passed from vertex to fragment shader\nvarying vec3 vPosition;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec2 vUv2;\n\nvoid main() {\n\n // To pass variables to the fragment shader, you assign them here in the\n // main function. Traditionally you name the varying with vAttributeName\n vNormal = normal;\n vUv = uv;\n vUv2 = uv2;\n vPosition = position;\n\n // This sets the position of the vertex in 3d space. The correct math is\n // provided below to take into account camera and object data.\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n}", | |
"uniforms": { | |
"cameraPosition": { | |
"name": "cameraPosition", | |
"displayName": null, | |
"type": "v3", | |
"glslType": "vec3", | |
"useGridHelper": false, | |
"useRange": false, | |
"range": null, | |
"isRandom": false, | |
"randomRange": null, | |
"useToggle": false, | |
"toggle": null, | |
"description": "" | |
}, | |
"time": { | |
"name": "time", | |
"displayName": null, | |
"type": "f", | |
"glslType": "float", | |
"useGridHelper": false, | |
"useRange": false, | |
"range": null, | |
"isRandom": false, | |
"randomRange": null, | |
"useToggle": false, | |
"toggle": null, | |
"description": "" | |
}, | |
"lightPosition": { | |
"name": "lightPosition", | |
"displayName": null, | |
"type": "v3", | |
"glslType": "vec3", | |
"useGridHelper": false, | |
"useRange": false, | |
"range": null, | |
"isRandom": false, | |
"randomRange": null, | |
"useToggle": false, | |
"toggle": null, | |
"description": "" | |
"runtime": { | |
"texture": null | |
}, | |
"value": { | |
"x": 0, | |
"y": 0, | |
"z": 1 | |
} | |
} | |
}, | |
"url": "http://shaderfrog.com/app/view/1665", | |
"user": { | |
"username": "MartinRGB", | |
"url": "http://shaderfrog.com/app/profile/andrewray" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment