d3155992-9e96-4995-a8de-773321d58b36.rogueMaterial 3.7 KB

1
  1. {"metadata":{"version":4.5,"type":"Object","generator":"Object3D.toJSON"},"geometries":[{"uuid":"f4a9d2b9-23d0-4ab3-8a58-2c4fe26cee8d","type":"BufferGeometry","data":{"attributes":{}}}],"materials":[{"uuid":"d3155992-9e96-4995-a8de-773321d58b36","type":"ShaderMaterial","name":"StarsShaderMaterial","blending":2,"side":2,"depthFunc":3,"depthTest":true,"depthWrite":true,"colorWrite":true,"stencilWrite":false,"stencilWriteMask":255,"stencilFunc":519,"stencilRef":0,"stencilFuncMask":255,"stencilFail":7680,"stencilZFail":7680,"stencilZPass":7680,"fog":false,"userData":{"__ASSET__":"d3155992-9e96-4995-a8de-773321d58b36"},"glslVersion":null,"uniforms":{"uTime":{"value":1.013999999999999}},"vertexShader":"#define GLSLIFY 1\n varying vec3 vPosition;\n varying vec3 vNormal;\n varying vec2 vUv;\n \n void main() {\n // Save the varyings\n vPosition = position;\n vNormal = normalize(normalMatrix * normal);\n vUv = uv;\n \n // Vertex shader output\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n","fragmentShader":"#define GLSLIFY 1\n varying vec3 vPosition;\n varying vec3 vNormal;\n varying vec2 vUv;\n\nuniform float uTime;\n\n// 3D Gradient noise from: https://www.shadertoy.com/view/Xsl3Dl\nvec3 hash( vec3 p ) // replace this by something better\n{\n\tp = vec3( dot(p,vec3(127.1,311.7, 74.7)),\n\t\t\t dot(p,vec3(269.5,183.3,246.1)),\n\t\t\t dot(p,vec3(113.5,271.9,124.6)));\n\n\treturn -1.0 + 2.0*fract(sin(p)*43758.5453123);\n}\n\nfloat noise( in vec3 p )\n{\n vec3 i = floor( p );\n vec3 f = fract( p );\n\t\n\tvec3 u = f*f*(3.0-2.0*f);\n\n return mix( mix( mix( dot( hash( i + vec3(0.0,0.0,0.0) ), f - vec3(0.0,0.0,0.0) ), \n dot( hash( i + vec3(1.0,0.0,0.0) ), f - vec3(1.0,0.0,0.0) ), u.x),\n mix( dot( hash( i + vec3(0.0,1.0,0.0) ), f - vec3(0.0,1.0,0.0) ), \n dot( hash( i + vec3(1.0,1.0,0.0) ), f - vec3(1.0,1.0,0.0) ), u.x), u.y),\n mix( mix( dot( hash( i + vec3(0.0,0.0,1.0) ), f - vec3(0.0,0.0,1.0) ), \n dot( hash( i + vec3(1.0,0.0,1.0) ), f - vec3(1.0,0.0,1.0) ), u.x),\n mix( dot( hash( i + vec3(0.0,1.0,1.0) ), f - vec3(0.0,1.0,1.0) ), \n dot( hash( i + vec3(1.0,1.0,1.0) ), f - vec3(1.0,1.0,1.0) ), u.x), u.y), u.z );\n}\n\nvoid main()\n{\n // Stars computation:\n vec3 stars_direction = normalize(vec3(vUv, 1.0f)); // could be view vector for example\n\tfloat stars_threshold = 8.0f; // modifies the number of stars that are visible\n\tfloat stars_exposure = 200.0f; // modifies the overall strength of the stars\n\tfloat stars = pow(clamp(noise(stars_direction * 200.0f), 0.0f, 1.0f), stars_threshold) * stars_exposure;\n\tstars *= mix(0.4, 1.4, noise(stars_direction * 100.0f + vec3(uTime))); // time based flickering\n\t\n gl_FragColor = vec4(vec3(stars), 1.0);\n}\n\n","isMaterial":true,"vertexColors":false,"opacity":1,"transparent":false,"blendSrc":204,"blendDst":205,"blendEquation":100,"clipIntersection":false,"clipShadows":false,"precision":"highp","polygonOffset":false,"polygonOffsetFactor":0,"polygonOffsetUnits":0,"dithering":false,"alphaToCoverage":false,"premultipliedAlpha":false,"visible":true,"toneMapped":true,"version":35,"_alphaTest":0,"isShaderMaterial":true,"linewidth":1,"wireframe":false,"wireframeLinewidth":1,"lights":false,"clipping":false,"uniformsNeedUpdate":false,"morphNormals":false,"flatShading":false}],"object":{"uuid":"3b1fa8cb-11bc-4e12-924e-0a90dec18a6d","type":"Mesh","userData":{"__IS_MATERIAL__":true},"layers":1,"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"f4a9d2b9-23d0-4ab3-8a58-2c4fe26cee8d","material":"d3155992-9e96-4995-a8de-773321d58b36"},"images":[]}