スポットライト
以下のブログに作成記録を参照。
vec3 o,a=vec3(0,1,.5);void f(vec3 d,vec2 c,vec2 v){float t=cos(t)*.3,l=cos(t),m=sin(t);o+=d*pow(dot(c/length(c),mat2(l,-m,m,l)*v/length(v)),9.);}void main(){vec2 p=gl_FragCoord.xy/r;f(a.yxx,p,a.yy);f(a.xyx,p-a.yx,a.xy-a.yx);f(a.xxy,p-a.zy,-a.xy);gl_FragColor.xyz=o;} #つぶやきGLSL pic.twitter.com/6bd5T2QU1j
— Narumium (@Nr_Narumium) September 16, 2020
整形コード
vec3 o,a=vec3(0,1,.5);
void f(vec3 d,vec2 c,vec2 v){
float t=cos(t)*.3,l=cos(t),m=sin(t);
o+=d*pow(dot(c/length(c),mat2(l,-m,m,l)*v/length(v)),9.);
}
void main(){
vec2 p=gl_FragCoord.xy/r;
f(a.yxx,p,a.yy);
f(a.xyx,p-a.yx,a.xy-a.yx);
f(a.xxy,p-a.zy,-a.xy);
gl_FragColor.xyz=o;
}