Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static String CinaCity = "\r\n" +
- "// Fixed by FlyedCode\r\n" +
- "#ifdef GL_ES\r\n" +
- "precision mediump float;\r\n" +
- "#endif\r\n" +
- "\r\n" +
- "#extension GL_OES_standard_derivatives : enable\r\n" +
- "\r\n" +
- "uniform float time;\r\n" +
- "uniform vec2 resolution;\r\n" +
- "vec3 iResolution;\r\n" +
- "float iTime;\r\n" +
- "//#define FAST_DESCENT\r\n" +
- "\r\n" +
- "#ifdef FAST_DESCENT\r\n" +
- "const vec3 cameraDir = normalize(vec3(-2.0, -1.0, -4.0));\r\n" +
- "const float cameraDist = 5.0;\r\n" +
- "const float speed = 3.0;\r\n" +
- "const float zoom = 2.5;\r\n" +
- "\r\n" +
- "const vec3 windowColorA = vec3(0.0, 0.0, 1.5);\r\n" +
- "const vec3 windowColorB = vec3(0.5, 1.5, 2.0);\r\n" +
- "\r\n" +
- "const float fogOffset = 2.5;\r\n" +
- "const float fogDensity = 0.6;\r\n" +
- "const vec3 fogColor = vec3(0.25, 0.0, 0.3);\r\n" +
- "\r\n" +
- "const float lightHeight = 0.5;\r\n" +
- "const float lightSpeed = 0.2;\r\n" +
- "const vec3 lightColorA = vec3(0.7, 0.3, 0.1);\r\n" +
- "const vec3 lightColorB = vec3(1.0, 0.6, 0.3);\r\n" +
- "\r\n" +
- "const vec3 signColorA = vec3(0.0, 0.0, 1.5);\r\n" +
- "const vec3 signColorB = vec3(3.0, 3.0, 3.0);\r\n" +
- "#else\r\n" +
- "const vec3 cameraDir = normalize(vec3(-2.0, -1.0, -2.0));\r\n" +
- "const float cameraDist = 9.0;\r\n" +
- "const float speed = 1.0;\r\n" +
- "const float zoom = 3.5;\r\n" +
- "\r\n" +
- "const vec3 windowColorA = vec3(0.0, 0.0, 1.5);\r\n" +
- "const vec3 windowColorB = vec3(0.5, 1.5, 2.0);\r\n" +
- "\r\n" +
- "const float fogOffset = 7.0;\r\n" +
- "const float fogDensity = 0.7;\r\n" +
- "const vec3 fogColor = vec3(0.25, 0.0, 0.3);\r\n" +
- "\r\n" +
- "const float lightHeight = 0.0;\r\n" +
- "const float lightSpeed = 0.15;\r\n" +
- "const vec3 lightColorA = vec3(0.7, 0.3, 0.1);\r\n" +
- "const vec3 lightColorB = vec3(1.0, 0.6, 0.3);\r\n" +
- "\r\n" +
- "const vec3 signColorA = vec3(0.0, 0.0, 1.5);\r\n" +
- "const vec3 signColorB = vec3(3.0, 3.0, 3.0);\r\n" +
- "#endif\r\n" +
- "\r\n" +
- "const float tau = 6.283185;\r\n" +
- "\r\n" +
- "\r\n" +
- "float hash1(float p) {\r\n" +
- " vec3 p3 = fract(p * vec3(5.3983, 5.4427, 6.9371));\r\n" +
- " p3 += dot(p3, p3.yzx + 19.19);\r\n" +
- " return fract((p3.x + p3.y) * p3.z);\r\n" +
- "}\r\n" +
- "\r\n" +
- "float hash1(vec2 p2) {\r\n" +
- " p2 = fract(p2 * vec2(5.3983, 5.4427));\r\n" +
- " p2 += dot(p2.yx, p2.xy + vec2(21.5351, 14.3137));\r\n" +
- " return fract(p2.x * p2.y * 95.4337);\r\n" +
- "}\r\n" +
- "\r\n" +
- "float hash1(vec2 p2, float p) {\r\n" +
- " vec3 p3 = fract(vec3(5.3983 * p2.x, 5.4427 * p2.y, 6.9371 * p));\r\n" +
- " p3 += dot(p3, p3.yzx + 19.19);\r\n" +
- " return fract((p3.x + p3.y) * p3.z);\r\n" +
- "}\r\n" +
- "\r\n" +
- "vec2 hash2(vec2 p2, float p) {\r\n" +
- " vec3 p3 = fract(vec3(5.3983 * p2.x, 5.4427 * p2.y, 6.9371 * p));\r\n" +
- " p3 += dot(p3, p3.yzx + 19.19);\r\n" +
- " return fract((p3.xx + p3.yz) * p3.zy);\r\n" +
- "}\r\n" +
- "\r\n" +
- "vec3 hash3(vec2 p2) {\r\n" +
- " vec3 p3 = fract(vec3(p2.xyx) * vec3(5.3983, 5.4427, 6.9371));\r\n" +
- " p3 += dot(p3, p3.yxz + 19.19);\r\n" +
- " return fract((p3.xxy + p3.yzz) * p3.zyx);\r\n" +
- "}\r\n" +
- "\r\n" +
- "vec4 hash4(vec2 p2) {\r\n" +
- " vec4 p4 = fract(p2.xyxy * vec4(5.3983, 5.4427, 6.9371, 7.1283));\r\n" +
- " p4 += dot(p4, p4.yxwz + 19.19);\r\n" +
- " return fract((p4.xxxy + p4.yyzz + p4.zwww) * p4.wzyx);\r\n" +
- "}\r\n" +
- "\r\n" +
- "float noise(vec2 p) {\r\n" +
- " vec2 i = floor(p);\r\n" +
- " vec2 f = fract(p);\r\n" +
- " vec2 u = f * f * (3.0 - 2.0 * f);\r\n" +
- " return mix(mix(hash1(i + vec2(0.0, 0.0)),\r\n" +
- " hash1(i + vec2(1.0, 0.0)), u.x),\r\n" +
- " mix(hash1(i + vec2(0.0, 1.0)),\r\n" +
- " hash1(i + vec2(1.0, 1.0)), u.x), u.y);\r\n" +
- "}\r\n" +
- "\r\n" +
- "vec4 castRay(vec3 eye, vec3 ray, vec2 center) {\r\n" +
- " vec2 block = floor(eye.xy);\r\n" +
- " vec3 ri = 1.0 / ray;\r\n" +
- " vec3 rs = sign(ray);\r\n" +
- " vec3 side = 0.5 + 0.5 * rs;\r\n" +
- " vec2 ris = ri.xy * rs.xy;\r\n" +
- " vec2 dis = (block - eye.xy + 0.5 + rs.xy * 0.5) * ri.xy;\r\n" +
- "\r\n" +
- " for (int i = 0; i < 16; ++i) {\r\n" +
- " float d = dot(block - center, cameraDir.xy);\r\n" +
- " float height = 3.0 * hash1(block) - 1.0 + 1.5 * d - 0.1 * d * d;\r\n" +
- "\r\n" +
- " vec2 lo0 = vec2(block);\r\n" +
- " vec2 loX = vec2(0.45, 0.45);\r\n" +
- " vec2 hi0 = vec2(block + 0.55);\r\n" +
- " vec2 hiX = vec2(0.45, 0.45);\r\n" +
- "\r\n" +
- " float dist = 500.0;\r\n" +
- " float face = 0.0;\r\n" +
- "\r\n" +
- " {\r\n" +
- " vec4 signHash = hash4(block);\r\n" +
- " vec2 center = vec2(0.2, -0.4) + vec2(0.6, -0.8) * signHash.xy;\r\n" +
- " float width = 0.06 + 0.1 * signHash.w;\r\n" +
- "\r\n" +
- " vec3 lo = vec3(center.x - width, 0.55, -100.0);\r\n" +
- " vec3 hi = vec3(center.x + width, 0.99, center.y + width + height);\r\n" +
- "\r\n" +
- " float s = step(0.5, signHash.z);\r\n" +
- " lo = vec3(block, 0.0) + mix(lo, lo.yxz, s);\r\n" +
- " hi = vec3(block, 0.0) + mix(hi, hi.yxz, s);\r\n" +
- "\r\n" +
- " vec3 wall = mix(hi, lo, side);\r\n" +
- " vec3 t = (wall - eye) * ri;\r\n" +
- "\r\n" +
- " vec3 dim = step(t.zxy, t) * step(t.yzx, t);\r\n" +
- " float maxT = dot(dim, t);\r\n" +
- " float maxFace = dim.x - dim.y;\r\n" +
- "\r\n" +
- " vec3 p = eye + maxT * ray;\r\n" +
- " dim += step(lo, p) * step(p, hi);\r\n" +
- "\r\n" +
- " if (dim.x * dim.y * dim.z > 0.5) {\r\n" +
- " dist = maxT;\r\n" +
- " face = maxFace;\r\n" +
- " }\r\n" +
- " }\r\n" +
- "\r\n" +
- " for (int j = 0; j < 5; ++j) {\r\n" +
- " float top = height - 0.4 * float(j);\r\n" +
- " vec3 lo = vec3(lo0 + loX * hash2(block, float(j)), -100.0);\r\n" +
- " vec3 hi = vec3(hi0 + hiX * hash2(block, float(j) + 0.5), top);\r\n" +
- "\r\n" +
- " vec3 wall = mix(hi, lo, side);\r\n" +
- " vec3 t = (wall - eye) * ri;\r\n" +
- "\r\n" +
- " vec3 dim = step(t.zxy, t) * step(t.yzx, t);\r\n" +
- " float maxT = dot(dim, t);\r\n" +
- " float maxFace = dim.x - dim.y;\r\n" +
- "\r\n" +
- " vec3 p = eye + maxT * ray;\r\n" +
- " dim += step(lo, p) * step(p, hi);\r\n" +
- "\r\n" +
- " if (dim.x * dim.y * dim.z > 0.5 && maxT < dist) {\r\n" +
- " dist = maxT;\r\n" +
- " face = maxFace;\r\n" +
- " }\r\n" +
- " }\r\n" +
- "\r\n" +
- " if (dist < 400.0) {\r\n" +
- " return vec4(dist, height, face, 1.0);\r\n" +
- " }\r\n" +
- "\r\n" +
- " float t = eye.z * ri.z;\r\n" +
- " vec3 p = eye - t * ray;\r\n" +
- " vec2 g = p.xy - block;\r\n" +
- "\r\n" +
- " vec2 dim = step(dis.xy, dis.yx);\r\n" +
- " dis += dim * ris;\r\n" +
- " block += dim * rs.xy;\r\n" +
- " }\r\n" +
- "\r\n" +
- " return vec4(100.0, 0.0, 0.0, 1.0);\r\n" +
- "}\r\n" +
- "\r\n" +
- "vec3 window(float z, vec2 pos, vec2 id) {\r\n" +
- " float windowSize = 0.03 + 0.12 * hash1(id + 0.1);\r\n" +
- " float windowProb = 0.3 + 0.8 * hash1(id + 0.2);\r\n" +
- " float depth = z / windowSize;\r\n" +
- " float level = floor(depth);\r\n" +
- " vec3 colorA = mix(windowColorA, windowColorB, hash3(id));\r\n" +
- " vec3 colorB = mix(windowColorA, windowColorB, hash3(id + 0.1));\r\n" +
- " vec3 color = mix(colorA, colorB, hash1(id, level));\r\n" +
- " color *= 0.3 + 0.7 * smoothstep(0.1, 0.5, noise(20.0 * pos + 100.0 * hash1(level)));\r\n" +
- " color *= smoothstep(windowProb - 0.2, windowProb + 0.2, hash1(id, level + 0.1));\r\n" +
- " return color * (0.5 - 0.5 * cos(tau * depth));\r\n" +
- "}\r\n" +
- "\r\n" +
- "vec3 addLight(vec3 eye, vec3 ray, float res, float time, float height) {\r\n" +
- " vec2 q = eye.xy + ((height - eye.z) / ray.z) * ray.xy;\r\n" +
- "\r\n" +
- " float row = floor(q.x + 0.5);\r\n" +
- " time += hash1(row);\r\n" +
- " float col = floor(0.125 * q.y - time);\r\n" +
- "\r\n" +
- " float pos = 0.4 + 0.4 * cos(time + tau * hash1(vec2(row, col)));\r\n" +
- " vec3 lightPos = vec3(row, 8.0 * (col + time + pos), height);\r\n" +
- " vec3 lightDir = vec3(0.0, 1.0, 0.0);\r\n" +
- "\r\n" +
- " // http://geomalgorithms.com/a07-_distance.html\r\n" +
- " vec3 w = eye - lightPos;\r\n" +
- " float a = dot(ray, ray);\r\n" +
- " float b = dot(ray, lightDir);\r\n" +
- " float c = dot(lightDir, lightDir);\r\n" +
- " float d = dot(ray, w);\r\n" +
- " float e = dot(lightDir, w);\r\n" +
- " float D = a * c - b * b;\r\n" +
- " float s = (b*e - c*d) / D;\r\n" +
- " float t = (a*e - b*d) / D;\r\n" +
- "\r\n" +
- " t = max(t, 0.0);\r\n" +
- " float dist = distance(eye + s * ray, lightPos + t * lightDir);\r\n" +
- "\r\n" +
- " float mask = smoothstep(res + 0.1, res, s);\r\n" +
- " float light = min(0.005 / (dist * dist / t + 0.1 * t * t), 2.0);\r\n" +
- " float fog = exp(-fogDensity * max(s - fogOffset, 0.0));\r\n" +
- " vec3 color = mix(lightColorA, lightColorB, hash3(vec2(row, col)));\r\n" +
- " return mask * light * fog * color;\r\n" +
- "}\r\n" +
- "\r\n" +
- "vec3 addSign(vec3 color, vec3 pos, float side, vec2 id) {\r\n" +
- " vec4 signHash = hash4(id);\r\n" +
- " float s = step(0.5, signHash.z);\r\n" +
- " if ((s - 0.5) * side < 0.1)\r\n" +
- " return color;\r\n" +
- "\r\n" +
- " vec2 center = vec2(0.2, -0.4) + vec2(0.6, -0.8) * signHash.xy;\r\n" +
- " vec2 p = mix(pos.xz, pos.yz, s);\r\n" +
- " float halfWidth = 0.04 + 0.06 * signHash.w;\r\n" +
- "\r\n" +
- " float charCount = floor(1.0 + 8.0 * hash1(id + 0.5));\r\n" +
- " if (center.y - p.y > 2.0 * halfWidth * (charCount + 1.0)) {\r\n" +
- " center.y -= 2.0 * halfWidth * (charCount + 1.5 + 5.0 * hash1(id + 0.6));\r\n" +
- " charCount = floor(2.0 + 12.0 * hash1(id + 0.7));\r\n" +
- " id += 0.05;\r\n" +
- " }\r\n" +
- "\r\n" +
- " vec3 signColor = mix(signColorA, signColorB, hash3(id + 0.5));\r\n" +
- " vec3 outlineColor = mix(signColorA, signColorB, hash3(id + 0.6));\r\n" +
- " float flash = 6.0 - 24.0 * hash1(id + 0.8);\r\n" +
- " flash *= step(3.0, flash);\r\n" +
- " flash = smoothstep(0.1, 0.5, 0.5 + 0.5 * cos(flash * iTime));\r\n" +
- "\r\n" +
- " vec2 halfSize = vec2(halfWidth, halfWidth * charCount);\r\n" +
- " center.y -= halfSize.y;\r\n" +
- " float outline = length(max(abs(p - center) - halfSize, 0.0)) / halfWidth;\r\n" +
- " color *= smoothstep(0.1, 0.4, outline);\r\n" +
- "\r\n" +
- " vec2 charPos = 0.5 * (p - center + halfSize) / halfWidth;\r\n" +
- " vec2 charId = id + 0.05 + 0.1 * floor(charPos);\r\n" +
- " float flicker = hash1(charId);\r\n" +
- " flicker = step(0.93, flicker);\r\n" +
- " flicker = 1.0 - flicker * step(0.96, hash1(charId, iTime));\r\n" +
- "\r\n" +
- " float char_1 = -3.5 + 8.0 * noise(id + 6.0 * charPos);\r\n" +
- " charPos = fract(charPos);\r\n" +
- " char_1 *= smoothstep(0.0, 0.4, charPos.x) * smoothstep(1.0, 0.6, charPos.x);\r\n" +
- " char_1 *= smoothstep(0.0, 0.4, charPos.y) * smoothstep(1.0, 0.6, charPos.y);\r\n" +
- " color = mix(color, signColor, flash * flicker * step(outline, 0.01) * clamp(char_1, 0.0, 1.0));\r\n" +
- "\r\n" +
- " outline = smoothstep(0.0, 0.2, outline) * smoothstep(0.5, 0.3, outline);\r\n" +
- " return mix(color, outlineColor, flash * outline);\r\n" +
- "}\r\n" +
- "\r\n" +
- "void mainImage(out vec4 fragColor, in vec2 fragCoord) {\r\n" +
- " vec2 center = -speed * iTime * cameraDir.xy;\r\n" +
- " vec3 eye = vec3(center, 0.0) - cameraDist * cameraDir;\r\n" +
- "\r\n" +
- " vec3 forward = normalize(cameraDir);\r\n" +
- " vec3 right = normalize(cross(forward, vec3(0.0, 0.0, 1.0)));\r\n" +
- " vec3 up = cross(right, forward);\r\n" +
- " vec2 xy = 2.0 * fragCoord - iResolution.xy;\r\n" +
- " vec3 ray = normalize(xy.x * right + xy.y * up + zoom * forward * iResolution.y);\r\n" +
- "\r\n" +
- " vec4 res = castRay(eye, ray, center);\r\n" +
- " vec3 p = eye + res.x * ray;\r\n" +
- "\r\n" +
- " vec2 block = floor(p.xy);\r\n" +
- " vec3 color = window(p.z - res.y, p.xy, block);\r\n" +
- "\r\n" +
- " color = addSign(color, vec3(p.xy - block, p.z - res.y), res.z, block);\r\n" +
- " color = mix(vec3(0.0), color, abs(res.z));\r\n" +
- "\r\n" +
- " float fog = exp(-fogDensity * max(res.x - fogOffset, 0.0));\r\n" +
- " color = mix(fogColor, color, fog);\r\n" +
- "\r\n" +
- " float time = lightSpeed * iTime;\r\n" +
- " color += addLight(eye.xyz, ray.xyz, res.x, time, lightHeight - 0.6);\r\n" +
- " color += addLight(eye.yxz, ray.yxz, res.x, time, lightHeight - 0.4);\r\n" +
- " color += addLight(vec3(-eye.xy, eye.z), vec3(-ray.xy, ray.z), res.x, time, lightHeight - 0.2);\r\n" +
- " color += addLight(vec3(-eye.yx, eye.z), vec3(-ray.yx, ray.z), res.x, time, lightHeight);\r\n" +
- "\r\n" +
- " fragColor = vec4(color, 1.0);\r\n" +
- "}\r\n" +
- "#undef time\r\n" +
- "#undef resolution\r\n" +
- "\r\n" +
- "void main(void)\r\n" +
- "{\r\n" +
- " iResolution = vec3(resolution, 0.0);\r\n" +
- " iTime = time;\r\n" +
- "\r\n" +
- " mainImage(gl_FragColor, gl_FragCoord.xy);\r\n" +
- "}\r\n" +
- "\r\n" +
- "";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement