shadertoy-star
来源:互联网 发布:淘宝怎么一键铺货 编辑:程序博客网 时间:2024/04/30 00:41
点击打开链接
float rand(vec2 co){ return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);}float dir(vec2 a, vec2 b, vec2 c){return (a.x - c.x) * (b.y - c.y) - (b.x - c.x) * (a.y - c.y);}bool insideTri(vec2 p, vec2 a, vec2 b, vec2 c){bool b1 = dir(p, a, b) < 0.0;bool b2 = dir(p, b, c) < 0.0;bool b3 = dir(p, c, a) < 0.0; return ((b1 == b2) && (b2 == b3));}void applyColor(vec3 paint, inout vec3 col, vec2 p, vec2 a, vec2 b, vec2 c){if (insideTri(p, a, b, c)) col = mix(col, paint, 0.4);}void rotate(inout vec2 point, float r) { point = vec2(point.x*sin(r) +point.y*cos(r), point.x*cos(r)- point.y*sin(r));}float PI = 3.14159265358979323846264;void drawTri(vec2 offset1, vec2 offset2, float size, float rotation, vec3 triColour, inout vec3 col, vec2 pos) { float oneThirdPhase = PI*2.0/3.0; float twoThirdPhase = PI*4.0/3.0; vec2 triTop = vec2(0, 1) * size + offset1; vec2 triBL = vec2(sin(oneThirdPhase),cos(oneThirdPhase)) * size + offset1; vec2 triBR = vec2(sin(twoThirdPhase),cos(twoThirdPhase)) * size + offset1; rotate(triTop, rotation); rotate(triBL, rotation); rotate(triBR, rotation); applyColor(triColour, col, pos, triTop + offset2, triBL+offset2, triBR+ offset2);}void drawStar(vec2 offset, float size, float rotation, vec3 triColour, inout vec3 col, vec2 pos) { vec2 topTriOff = offset; vec2 bottomTriOff = offset; float topTriRot = PI + rotation; float bottomTriRot = rotation; drawTri(vec2(0), topTriOff, size, topTriRot, triColour, col, pos); drawTri(vec2(0), bottomTriOff, size, bottomTriRot, triColour, col, pos);}vec3 hsv2rgb(vec3 c){ vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);}void drawCircle(vec2 offset, float rad2, vec3 circColour, inout vec3 col, vec2 pos) { if (length(offset-pos)<rad2) { col = mix(col, circColour, 0.52); }}void mainImage( out vec4 fragColor, in vec2 fragCoord ){vec2 uv = fragCoord.xy / iResolution.xy; fragColor.rgb = vec3(0.75,0.8,1.0); vec3 starColourHSV = vec3(0,1,1); float starheight = 0.0; for (int i=0; i<100; ++i) { starheight = rand(vec2(float(i),5.0)); starColourHSV.x = 0.9-starheight; drawStar(vec2(0.1+mod((float(i)+iGlobalTime)/12.0,0.8), 0.1+starheight/8.0+sin(uv.x*PI)/4.0), 0.03, iGlobalTime+rand(vec2(float(i),3)), hsv2rgb(starColourHSV),fragColor.rgb, fragCoord.xy/iResolution.x); } for (int i = 0; i < 10; ++i) { vec2 cloudOffset = vec2(0.1+rand(vec2(float(i),8))/12.0, 0.2+rand(vec2(float(i), 9))/12.0); drawCircle(cloudOffset,0.05, vec3(1.0), fragColor.rgb, fragCoord.xy/iResolution.x); } for (int i = 0; i < 10; ++i) { vec2 cloudOffset = vec2(0.85+rand(vec2(float(i),8))/12.0, 0.19+rand(vec2(float(i), 9))/12.0); drawCircle(cloudOffset,0.05, vec3(1.0), fragColor.rgb, fragCoord.xy/iResolution.x); }}
0 0
- shadertoy-star
- shadertoy
- ShaderToy
- ShaderToy
- Star
- Star
- Star
- star
- star
- 【ShaderToy】开篇
- 【ShaderToy】水彩画
- ShaderToy Seascape
- 【ShaderToy】开篇
- 【ShaderToy】水彩画
- ShaderToy 水彩画
- Shadertoy-MagicSea
- Shadertoy-Seascape
- 【ShaderToy】跳动的心
- ES 优化
- Binder工作机制详解(应用层)
- (21)Spring Boot过滤器、监听器【从零开始学Spring Boot】
- 【Inno Setup】修改安装分割线前面的文字并自定义风格(颜色、字体大小等等)
- 典型的网络接口安全机制,AES和RSA混合加密
- shadertoy-star
- [Linux命令]--ls
- Android开发者的混淆使用手册
- iOS常用的第三方及实例
- jdk环境配置
- RocketMQ 入门使用详解
- CSS学习笔记2:CSS基础选择器
- Java String 源码浅析【byGavin】
- Python使用pip安装包命令