{“vs_code”:”/*MY_VERTEX_SHADER*/\n/* #version 330 core */\n varying vec2 vUv;\n void main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n vUv = uv;\n}”,”fs_code”:”/*MY_FRAGMENT_SHADER*/\n\n// Screen/Window resolution (width and height of window)\nuniform vec2 u_resolution;\nuniform float u_time;\n\nvoid main() {\n vec2 uv = gl_FragCoord.xy/u_resolution.xy;\n vec3 red = vec3(1.0,0.0,0.0);\n vec3 green = vec3(0.0,1.0,0.0);\n \n vec4 finalColor = vec4(0.0,0.0,0.0,1.0);\n // Calculate sin movement.\n float movement = sin(u_time * 1.0) * 0.5;\n // Modify uv coordinate based on the movement. Here we are not actually moving the object but moving/modifying the coordinate itself.\n uv.x += movement;\n if(uv.x >= 0.45 && uv.x <= 0.55 && uv.y >= 0.4 && uv.y <= 0.6)\n { \n finalColor=vec4(green, 1.0);\n }\n \n gl_FragColor=finalColor;\n }\n","uniforms":{"u_time":{"type":"f","value":0,"editable":false},"u_resolution":{"type":"v2","value":{"x":814,"y":398},"editable":false},"u_mouse":{"type":"v2","value":{"x":0.004086881070523648,"y":0.3182175219358511},"editable":false}},"description":"Info about your shader.","threeJsSettings":{"showFloor":false,"ambientLight":true,"directionalLight":true,"selected3DObject":"Plane"},"attributes":{"isPublic":true,"defaultIndex":1,"categoryId":31}}
Tut Basic Shape 3
Written by
in