四处移动的发光球 shader

本文展示了一段使用 GLSL (图形着色语言) 编写的实时图形效果代码。通过改变时间变量,图形会呈现出随时间变化而变化的效果。代码中运用了多种 GLSL 语法特性,包括条件编译指令、精度声明、扩展启用等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

转载自: http://glslsandbox.com/e#44931.0




#ifdef GL_ES
precision mediump float;
#endif


#extension GL_OES_standard_derivatives : enable


uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;


void main( void ) {
vec2 position = (gl_FragCoord.xy * 2.0 -resolution) / min(resolution.x,resolution.y); //座標を正規化- (-1,1)
position.x += sin(time)+cos(time*2.0)+sin(time*3.0);
position.y += sin(time * 0.5);
float l = 0.1 * (abs(sin(time))+.27) / length(position);

float r = 0.8;
float g = 0.8;
float b = 0.8;
gl_FragColor = vec4(vec3(l),1.0);
}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值