(评论)
(comments)
原始链接: https://news.ycombinator.com/item?id=38463832
````
// 更新版本具有彩虹和绽放效果
精密中型浮子;
常量 int TIMES = 100; // 动画持续时间
浮动时间 = (gl_FragCoord.x / 分辨率.x > 0.5) ? (时间 * 2.) : 时间;
统一 vec3 viewPos;
统一 vec3 camDir;
均匀浮动光强度;
均匀浮动光距离;
改变 vec2 uvRect;
改变 vec3 法线[TIMES];
vec3 位置;
vec3 眼睛位置;
vec3 光位置;
vec4 照明(在 vec3 位置、在 vec3 lightDirection 中、在 vec3 eyeDirection 中){
浮动theta =点((position.xtx2.0-position.yz)/ lightDistance,cross(position.xtx2.0-eyePos.xtx2.0,normalize(cross(eyePos.xtx2.0,viewPos))))%360.0 ;
vec3 V = 标准化((lightDirection - eyeDirection) * lightIntensity);
浮动 D = 距离(位置,eyePos);
浮动衰减 = 1./(D / lightDistance) * (1.0 - exp((D - lightDistance) / 50.0));
浮动K = 0.4; // 从中心软下降
vec4 颜色 = mix(mix(mix(vec4(1.0), vec4(0.5, 0.25, 0.0), 0.5), vec4(0.0, 0.0, 0.0, 0.0), 0.5), vec4(0.5, 0.25, 0.0, 0.0) , 夹((时间 + 1.) / 时间, 0.0, 1.0));
颜色 *= (1.0 - 0.8 * pow(衰减, 5.) + 0.2);
颜色 *= vec4(clamp(pow(sin(16.0 * θ), 4.), 1.0), 夹(pow(cos(16.0 * θ)
I tried adjusting the UV so we could see the top of the sphere, but I gave up. For what it's worth, the threejs uniforms "projectionMatrix" and "modelViewMatrix" can be referenced in the GLSL as long as you declare them up top.
reply