Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.20 KB | None | 0 0
  1. public static String CinaCity = "\r\n" +
  2. "// Fixed by FlyedCode\r\n" +
  3. "#ifdef GL_ES\r\n" +
  4. "precision mediump float;\r\n" +
  5. "#endif\r\n" +
  6. "\r\n" +
  7. "#extension GL_OES_standard_derivatives : enable\r\n" +
  8. "\r\n" +
  9. "uniform float time;\r\n" +
  10. "uniform vec2 resolution;\r\n" +
  11. "vec3 iResolution;\r\n" +
  12. "float iTime;\r\n" +
  13. "//#define FAST_DESCENT\r\n" +
  14. "\r\n" +
  15. "#ifdef FAST_DESCENT\r\n" +
  16. "const vec3 cameraDir = normalize(vec3(-2.0, -1.0, -4.0));\r\n" +
  17. "const float cameraDist = 5.0;\r\n" +
  18. "const float speed = 3.0;\r\n" +
  19. "const float zoom = 2.5;\r\n" +
  20. "\r\n" +
  21. "const vec3 windowColorA = vec3(0.0, 0.0, 1.5);\r\n" +
  22. "const vec3 windowColorB = vec3(0.5, 1.5, 2.0);\r\n" +
  23. "\r\n" +
  24. "const float fogOffset = 2.5;\r\n" +
  25. "const float fogDensity = 0.6;\r\n" +
  26. "const vec3 fogColor = vec3(0.25, 0.0, 0.3);\r\n" +
  27. "\r\n" +
  28. "const float lightHeight = 0.5;\r\n" +
  29. "const float lightSpeed = 0.2;\r\n" +
  30. "const vec3 lightColorA = vec3(0.7, 0.3, 0.1);\r\n" +
  31. "const vec3 lightColorB = vec3(1.0, 0.6, 0.3);\r\n" +
  32. "\r\n" +
  33. "const vec3 signColorA = vec3(0.0, 0.0, 1.5);\r\n" +
  34. "const vec3 signColorB = vec3(3.0, 3.0, 3.0);\r\n" +
  35. "#else\r\n" +
  36. "const vec3 cameraDir = normalize(vec3(-2.0, -1.0, -2.0));\r\n" +
  37. "const float cameraDist = 9.0;\r\n" +
  38. "const float speed = 1.0;\r\n" +
  39. "const float zoom = 3.5;\r\n" +
  40. "\r\n" +
  41. "const vec3 windowColorA = vec3(0.0, 0.0, 1.5);\r\n" +
  42. "const vec3 windowColorB = vec3(0.5, 1.5, 2.0);\r\n" +
  43. "\r\n" +
  44. "const float fogOffset = 7.0;\r\n" +
  45. "const float fogDensity = 0.7;\r\n" +
  46. "const vec3 fogColor = vec3(0.25, 0.0, 0.3);\r\n" +
  47. "\r\n" +
  48. "const float lightHeight = 0.0;\r\n" +
  49. "const float lightSpeed = 0.15;\r\n" +
  50. "const vec3 lightColorA = vec3(0.7, 0.3, 0.1);\r\n" +
  51. "const vec3 lightColorB = vec3(1.0, 0.6, 0.3);\r\n" +
  52. "\r\n" +
  53. "const vec3 signColorA = vec3(0.0, 0.0, 1.5);\r\n" +
  54. "const vec3 signColorB = vec3(3.0, 3.0, 3.0);\r\n" +
  55. "#endif\r\n" +
  56. "\r\n" +
  57. "const float tau = 6.283185;\r\n" +
  58. "\r\n" +
  59. "\r\n" +
  60. "float hash1(float p) {\r\n" +
  61. " vec3 p3 = fract(p * vec3(5.3983, 5.4427, 6.9371));\r\n" +
  62. " p3 += dot(p3, p3.yzx + 19.19);\r\n" +
  63. " return fract((p3.x + p3.y) * p3.z);\r\n" +
  64. "}\r\n" +
  65. "\r\n" +
  66. "float hash1(vec2 p2) {\r\n" +
  67. " p2 = fract(p2 * vec2(5.3983, 5.4427));\r\n" +
  68. " p2 += dot(p2.yx, p2.xy + vec2(21.5351, 14.3137));\r\n" +
  69. " return fract(p2.x * p2.y * 95.4337);\r\n" +
  70. "}\r\n" +
  71. "\r\n" +
  72. "float hash1(vec2 p2, float p) {\r\n" +
  73. " vec3 p3 = fract(vec3(5.3983 * p2.x, 5.4427 * p2.y, 6.9371 * p));\r\n" +
  74. " p3 += dot(p3, p3.yzx + 19.19);\r\n" +
  75. " return fract((p3.x + p3.y) * p3.z);\r\n" +
  76. "}\r\n" +
  77. "\r\n" +
  78. "vec2 hash2(vec2 p2, float p) {\r\n" +
  79. " vec3 p3 = fract(vec3(5.3983 * p2.x, 5.4427 * p2.y, 6.9371 * p));\r\n" +
  80. " p3 += dot(p3, p3.yzx + 19.19);\r\n" +
  81. " return fract((p3.xx + p3.yz) * p3.zy);\r\n" +
  82. "}\r\n" +
  83. "\r\n" +
  84. "vec3 hash3(vec2 p2) {\r\n" +
  85. " vec3 p3 = fract(vec3(p2.xyx) * vec3(5.3983, 5.4427, 6.9371));\r\n" +
  86. " p3 += dot(p3, p3.yxz + 19.19);\r\n" +
  87. " return fract((p3.xxy + p3.yzz) * p3.zyx);\r\n" +
  88. "}\r\n" +
  89. "\r\n" +
  90. "vec4 hash4(vec2 p2) {\r\n" +
  91. " vec4 p4 = fract(p2.xyxy * vec4(5.3983, 5.4427, 6.9371, 7.1283));\r\n" +
  92. " p4 += dot(p4, p4.yxwz + 19.19);\r\n" +
  93. " return fract((p4.xxxy + p4.yyzz + p4.zwww) * p4.wzyx);\r\n" +
  94. "}\r\n" +
  95. "\r\n" +
  96. "float noise(vec2 p) {\r\n" +
  97. " vec2 i = floor(p);\r\n" +
  98. " vec2 f = fract(p);\r\n" +
  99. " vec2 u = f * f * (3.0 - 2.0 * f);\r\n" +
  100. " return mix(mix(hash1(i + vec2(0.0, 0.0)),\r\n" +
  101. " hash1(i + vec2(1.0, 0.0)), u.x),\r\n" +
  102. " mix(hash1(i + vec2(0.0, 1.0)),\r\n" +
  103. " hash1(i + vec2(1.0, 1.0)), u.x), u.y);\r\n" +
  104. "}\r\n" +
  105. "\r\n" +
  106. "vec4 castRay(vec3 eye, vec3 ray, vec2 center) {\r\n" +
  107. " vec2 block = floor(eye.xy);\r\n" +
  108. " vec3 ri = 1.0 / ray;\r\n" +
  109. " vec3 rs = sign(ray);\r\n" +
  110. " vec3 side = 0.5 + 0.5 * rs;\r\n" +
  111. " vec2 ris = ri.xy * rs.xy;\r\n" +
  112. " vec2 dis = (block - eye.xy + 0.5 + rs.xy * 0.5) * ri.xy;\r\n" +
  113. "\r\n" +
  114. " for (int i = 0; i < 16; ++i) {\r\n" +
  115. " float d = dot(block - center, cameraDir.xy);\r\n" +
  116. " float height = 3.0 * hash1(block) - 1.0 + 1.5 * d - 0.1 * d * d;\r\n" +
  117. "\r\n" +
  118. " vec2 lo0 = vec2(block);\r\n" +
  119. " vec2 loX = vec2(0.45, 0.45);\r\n" +
  120. " vec2 hi0 = vec2(block + 0.55);\r\n" +
  121. " vec2 hiX = vec2(0.45, 0.45);\r\n" +
  122. "\r\n" +
  123. " float dist = 500.0;\r\n" +
  124. " float face = 0.0;\r\n" +
  125. "\r\n" +
  126. " {\r\n" +
  127. " vec4 signHash = hash4(block);\r\n" +
  128. " vec2 center = vec2(0.2, -0.4) + vec2(0.6, -0.8) * signHash.xy;\r\n" +
  129. " float width = 0.06 + 0.1 * signHash.w;\r\n" +
  130. "\r\n" +
  131. " vec3 lo = vec3(center.x - width, 0.55, -100.0);\r\n" +
  132. " vec3 hi = vec3(center.x + width, 0.99, center.y + width + height);\r\n" +
  133. "\r\n" +
  134. " float s = step(0.5, signHash.z);\r\n" +
  135. " lo = vec3(block, 0.0) + mix(lo, lo.yxz, s);\r\n" +
  136. " hi = vec3(block, 0.0) + mix(hi, hi.yxz, s);\r\n" +
  137. "\r\n" +
  138. " vec3 wall = mix(hi, lo, side);\r\n" +
  139. " vec3 t = (wall - eye) * ri;\r\n" +
  140. "\r\n" +
  141. " vec3 dim = step(t.zxy, t) * step(t.yzx, t);\r\n" +
  142. " float maxT = dot(dim, t);\r\n" +
  143. " float maxFace = dim.x - dim.y;\r\n" +
  144. "\r\n" +
  145. " vec3 p = eye + maxT * ray;\r\n" +
  146. " dim += step(lo, p) * step(p, hi);\r\n" +
  147. "\r\n" +
  148. " if (dim.x * dim.y * dim.z > 0.5) {\r\n" +
  149. " dist = maxT;\r\n" +
  150. " face = maxFace;\r\n" +
  151. " }\r\n" +
  152. " }\r\n" +
  153. "\r\n" +
  154. " for (int j = 0; j < 5; ++j) {\r\n" +
  155. " float top = height - 0.4 * float(j);\r\n" +
  156. " vec3 lo = vec3(lo0 + loX * hash2(block, float(j)), -100.0);\r\n" +
  157. " vec3 hi = vec3(hi0 + hiX * hash2(block, float(j) + 0.5), top);\r\n" +
  158. "\r\n" +
  159. " vec3 wall = mix(hi, lo, side);\r\n" +
  160. " vec3 t = (wall - eye) * ri;\r\n" +
  161. "\r\n" +
  162. " vec3 dim = step(t.zxy, t) * step(t.yzx, t);\r\n" +
  163. " float maxT = dot(dim, t);\r\n" +
  164. " float maxFace = dim.x - dim.y;\r\n" +
  165. "\r\n" +
  166. " vec3 p = eye + maxT * ray;\r\n" +
  167. " dim += step(lo, p) * step(p, hi);\r\n" +
  168. "\r\n" +
  169. " if (dim.x * dim.y * dim.z > 0.5 && maxT < dist) {\r\n" +
  170. " dist = maxT;\r\n" +
  171. " face = maxFace;\r\n" +
  172. " }\r\n" +
  173. " }\r\n" +
  174. "\r\n" +
  175. " if (dist < 400.0) {\r\n" +
  176. " return vec4(dist, height, face, 1.0);\r\n" +
  177. " }\r\n" +
  178. "\r\n" +
  179. " float t = eye.z * ri.z;\r\n" +
  180. " vec3 p = eye - t * ray;\r\n" +
  181. " vec2 g = p.xy - block;\r\n" +
  182. "\r\n" +
  183. " vec2 dim = step(dis.xy, dis.yx);\r\n" +
  184. " dis += dim * ris;\r\n" +
  185. " block += dim * rs.xy;\r\n" +
  186. " }\r\n" +
  187. "\r\n" +
  188. " return vec4(100.0, 0.0, 0.0, 1.0);\r\n" +
  189. "}\r\n" +
  190. "\r\n" +
  191. "vec3 window(float z, vec2 pos, vec2 id) {\r\n" +
  192. " float windowSize = 0.03 + 0.12 * hash1(id + 0.1);\r\n" +
  193. " float windowProb = 0.3 + 0.8 * hash1(id + 0.2);\r\n" +
  194. " float depth = z / windowSize;\r\n" +
  195. " float level = floor(depth);\r\n" +
  196. " vec3 colorA = mix(windowColorA, windowColorB, hash3(id));\r\n" +
  197. " vec3 colorB = mix(windowColorA, windowColorB, hash3(id + 0.1));\r\n" +
  198. " vec3 color = mix(colorA, colorB, hash1(id, level));\r\n" +
  199. " color *= 0.3 + 0.7 * smoothstep(0.1, 0.5, noise(20.0 * pos + 100.0 * hash1(level)));\r\n" +
  200. " color *= smoothstep(windowProb - 0.2, windowProb + 0.2, hash1(id, level + 0.1));\r\n" +
  201. " return color * (0.5 - 0.5 * cos(tau * depth));\r\n" +
  202. "}\r\n" +
  203. "\r\n" +
  204. "vec3 addLight(vec3 eye, vec3 ray, float res, float time, float height) {\r\n" +
  205. " vec2 q = eye.xy + ((height - eye.z) / ray.z) * ray.xy;\r\n" +
  206. "\r\n" +
  207. " float row = floor(q.x + 0.5);\r\n" +
  208. " time += hash1(row);\r\n" +
  209. " float col = floor(0.125 * q.y - time);\r\n" +
  210. "\r\n" +
  211. " float pos = 0.4 + 0.4 * cos(time + tau * hash1(vec2(row, col)));\r\n" +
  212. " vec3 lightPos = vec3(row, 8.0 * (col + time + pos), height);\r\n" +
  213. " vec3 lightDir = vec3(0.0, 1.0, 0.0);\r\n" +
  214. "\r\n" +
  215. " // http://geomalgorithms.com/a07-_distance.html\r\n" +
  216. " vec3 w = eye - lightPos;\r\n" +
  217. " float a = dot(ray, ray);\r\n" +
  218. " float b = dot(ray, lightDir);\r\n" +
  219. " float c = dot(lightDir, lightDir);\r\n" +
  220. " float d = dot(ray, w);\r\n" +
  221. " float e = dot(lightDir, w);\r\n" +
  222. " float D = a * c - b * b;\r\n" +
  223. " float s = (b*e - c*d) / D;\r\n" +
  224. " float t = (a*e - b*d) / D;\r\n" +
  225. "\r\n" +
  226. " t = max(t, 0.0);\r\n" +
  227. " float dist = distance(eye + s * ray, lightPos + t * lightDir);\r\n" +
  228. "\r\n" +
  229. " float mask = smoothstep(res + 0.1, res, s);\r\n" +
  230. " float light = min(0.005 / (dist * dist / t + 0.1 * t * t), 2.0);\r\n" +
  231. " float fog = exp(-fogDensity * max(s - fogOffset, 0.0));\r\n" +
  232. " vec3 color = mix(lightColorA, lightColorB, hash3(vec2(row, col)));\r\n" +
  233. " return mask * light * fog * color;\r\n" +
  234. "}\r\n" +
  235. "\r\n" +
  236. "vec3 addSign(vec3 color, vec3 pos, float side, vec2 id) {\r\n" +
  237. " vec4 signHash = hash4(id);\r\n" +
  238. " float s = step(0.5, signHash.z);\r\n" +
  239. " if ((s - 0.5) * side < 0.1)\r\n" +
  240. " return color;\r\n" +
  241. "\r\n" +
  242. " vec2 center = vec2(0.2, -0.4) + vec2(0.6, -0.8) * signHash.xy;\r\n" +
  243. " vec2 p = mix(pos.xz, pos.yz, s);\r\n" +
  244. " float halfWidth = 0.04 + 0.06 * signHash.w;\r\n" +
  245. "\r\n" +
  246. " float charCount = floor(1.0 + 8.0 * hash1(id + 0.5));\r\n" +
  247. " if (center.y - p.y > 2.0 * halfWidth * (charCount + 1.0)) {\r\n" +
  248. " center.y -= 2.0 * halfWidth * (charCount + 1.5 + 5.0 * hash1(id + 0.6));\r\n" +
  249. " charCount = floor(2.0 + 12.0 * hash1(id + 0.7));\r\n" +
  250. " id += 0.05;\r\n" +
  251. " }\r\n" +
  252. "\r\n" +
  253. " vec3 signColor = mix(signColorA, signColorB, hash3(id + 0.5));\r\n" +
  254. " vec3 outlineColor = mix(signColorA, signColorB, hash3(id + 0.6));\r\n" +
  255. " float flash = 6.0 - 24.0 * hash1(id + 0.8);\r\n" +
  256. " flash *= step(3.0, flash);\r\n" +
  257. " flash = smoothstep(0.1, 0.5, 0.5 + 0.5 * cos(flash * iTime));\r\n" +
  258. "\r\n" +
  259. " vec2 halfSize = vec2(halfWidth, halfWidth * charCount);\r\n" +
  260. " center.y -= halfSize.y;\r\n" +
  261. " float outline = length(max(abs(p - center) - halfSize, 0.0)) / halfWidth;\r\n" +
  262. " color *= smoothstep(0.1, 0.4, outline);\r\n" +
  263. "\r\n" +
  264. " vec2 charPos = 0.5 * (p - center + halfSize) / halfWidth;\r\n" +
  265. " vec2 charId = id + 0.05 + 0.1 * floor(charPos);\r\n" +
  266. " float flicker = hash1(charId);\r\n" +
  267. " flicker = step(0.93, flicker);\r\n" +
  268. " flicker = 1.0 - flicker * step(0.96, hash1(charId, iTime));\r\n" +
  269. "\r\n" +
  270. " float char_1 = -3.5 + 8.0 * noise(id + 6.0 * charPos);\r\n" +
  271. " charPos = fract(charPos);\r\n" +
  272. " char_1 *= smoothstep(0.0, 0.4, charPos.x) * smoothstep(1.0, 0.6, charPos.x);\r\n" +
  273. " char_1 *= smoothstep(0.0, 0.4, charPos.y) * smoothstep(1.0, 0.6, charPos.y);\r\n" +
  274. " color = mix(color, signColor, flash * flicker * step(outline, 0.01) * clamp(char_1, 0.0, 1.0));\r\n" +
  275. "\r\n" +
  276. " outline = smoothstep(0.0, 0.2, outline) * smoothstep(0.5, 0.3, outline);\r\n" +
  277. " return mix(color, outlineColor, flash * outline);\r\n" +
  278. "}\r\n" +
  279. "\r\n" +
  280. "void mainImage(out vec4 fragColor, in vec2 fragCoord) {\r\n" +
  281. " vec2 center = -speed * iTime * cameraDir.xy;\r\n" +
  282. " vec3 eye = vec3(center, 0.0) - cameraDist * cameraDir;\r\n" +
  283. "\r\n" +
  284. " vec3 forward = normalize(cameraDir);\r\n" +
  285. " vec3 right = normalize(cross(forward, vec3(0.0, 0.0, 1.0)));\r\n" +
  286. " vec3 up = cross(right, forward);\r\n" +
  287. " vec2 xy = 2.0 * fragCoord - iResolution.xy;\r\n" +
  288. " vec3 ray = normalize(xy.x * right + xy.y * up + zoom * forward * iResolution.y);\r\n" +
  289. "\r\n" +
  290. " vec4 res = castRay(eye, ray, center);\r\n" +
  291. " vec3 p = eye + res.x * ray;\r\n" +
  292. "\r\n" +
  293. " vec2 block = floor(p.xy);\r\n" +
  294. " vec3 color = window(p.z - res.y, p.xy, block);\r\n" +
  295. "\r\n" +
  296. " color = addSign(color, vec3(p.xy - block, p.z - res.y), res.z, block);\r\n" +
  297. " color = mix(vec3(0.0), color, abs(res.z));\r\n" +
  298. "\r\n" +
  299. " float fog = exp(-fogDensity * max(res.x - fogOffset, 0.0));\r\n" +
  300. " color = mix(fogColor, color, fog);\r\n" +
  301. "\r\n" +
  302. " float time = lightSpeed * iTime;\r\n" +
  303. " color += addLight(eye.xyz, ray.xyz, res.x, time, lightHeight - 0.6);\r\n" +
  304. " color += addLight(eye.yxz, ray.yxz, res.x, time, lightHeight - 0.4);\r\n" +
  305. " color += addLight(vec3(-eye.xy, eye.z), vec3(-ray.xy, ray.z), res.x, time, lightHeight - 0.2);\r\n" +
  306. " color += addLight(vec3(-eye.yx, eye.z), vec3(-ray.yx, ray.z), res.x, time, lightHeight);\r\n" +
  307. "\r\n" +
  308. " fragColor = vec4(color, 1.0);\r\n" +
  309. "}\r\n" +
  310. "#undef time\r\n" +
  311. "#undef resolution\r\n" +
  312. "\r\n" +
  313. "void main(void)\r\n" +
  314. "{\r\n" +
  315. " iResolution = vec3(resolution, 0.0);\r\n" +
  316. " iTime = time;\r\n" +
  317. "\r\n" +
  318. " mainImage(gl_FragColor, gl_FragCoord.xy);\r\n" +
  319. "}\r\n" +
  320. "\r\n" +
  321. "";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement