The name "A" clashes with variables produced by shader minifier. Results in a compilation error (win 11 nvidia).
#version 460
layout(local_size_x=256,local_size_y=1,local_size_z=1) in;
layout(location = 0) uniform int iFramee;
layout(location = 2) uniform vec2 R;
layout(binding = 7) uniform sampler2D tex_font;
layout(binding = 1) uniform sampler2D iChannel0;
const float pi = acos(-1.);
const float tau = acos(-1.)*2.;
uint seed = 111425u;
uint hash_u(uint _a) {
uint a = _a;
a ^= a >> 16;
a *= 0x7feb352du;
a ^= a >> 15;
a *= 0x846ca68bu;
a ^= a >> 16;
return a;
}
float hash_f_s(uint s){return float(hash_u(s))/float(-1u);}
float hash_f(){return float(seed = hash_u(seed))/float(-1u);}
vec2 hash_v2(){return vec2(hash_f(), hash_f());}
vec3 hash_v3(){return vec3(hash_f(), hash_f(), hash_f());}
float sdxor(float sda, float sdb){
return(min(max(sda,-sdb), max(sdb,-sda)));
}
float sdLine( in vec2 p, in vec2 a, in vec2 b )
{
vec2 pa = p-a, ba = b-a;
float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );
return length( pa - ba*h );
}
mat2 rotate2D( float t ) {
float c = cos( t );
float s = sin( t );
return mat2( c, s, -s, c );
}
mat2 rot(float t){return rotate2D(t);}
mat3 getOrthogonalBasis( vec3 z ) {
z = normalize( z );
vec3 up = abs( z.y ) < 0.99 ? vec3( 0.0, 1.0, 0.0 ) : vec3( 0.0, 0.0, 1.0 );
vec3 x = normalize( cross( up, z ) );
return mat3( x, cross( z, x ), z );
}
vec3 cyclicNoise( vec3 p, float pump ) {
vec4 sum = vec4( 0.0 );
mat3 basis = getOrthogonalBasis( vec3( -1.0, 2.0, -3.0 ) );
for( int i = 0; i < 5; i++ ) {
p *= basis;
p += sin( p.yzx );
sum += vec4(
cross( cos( p ), sin( p.zxy ) ),
1.0
);
sum *= pump;
p *= 2.0;
}
return sum.xyz / sum.w;
}
float sdOrientedBox( in vec2 p, in vec2 a, in vec2 b, float th )
{
float l = length(b-a);
vec2 d = (b-a)/l;
vec2 q = (p-(a+b)*0.5);
q = mat2(d.x,-d.y,d.y,d.x)*q;
q = abs(q)-vec2(l,th)*0.5;
return length(max(q,0.0)) + min(max(q.x,q.y),0.0);
}
float sdBox(vec2 u, vec2 s){
u = abs(u) - s;
return max(u.x, u.y);
}
mat3 m11 = mat3( .41,.54,.05, .21,.68,.11, .09,.28,.63);
mat3 m2 = mat3( .21,.79,0, 1.97,-2.42,.45, .03,.78,-.81);
vec3 srgb_to_oklch( vec3 c ) {
c = pow(c * m11,vec3(1./3.)) * m2;
return vec3(c.x,sqrt((c.y*c.y) + (c.z * c.z)),atan(c.z,c.y));
}
vec3 lch( vec3 c ) {
return clamp(pow(vec3(c.x,c.y*cos(c.z),c.y*sin(c.z)) * inverse(m2),vec3(3.)) * inverse(m11),0.,1.);
}
struct Part{
uint id;
vec2 pos;
float rot;
float part_w;
float rot_dir;
float rot_speed;
bool alive;
};
layout(std430,binding=0) buffer A{Part parts[];};
layout(r32ui,binding=1) uniform coherent uimage2D render_img;
layout(r32ui,binding=2) uniform coherent uimage2D ids_img;
float read(vec2 c){
return float(imageLoad(render_img, ivec2(c)).x)/1000.;
}
void splat(vec2 q, float c){
imageAtomicAdd(render_img, ivec2(q), uint(c*1000.));
//return float(imageLoad(render_img, ivec2(c)).x)/1000.;
}
vec2 sample_circ(){
vec2 X = hash_v2()*vec2(tau,1);
return vec2(sin(X.x),cos(X.x))*sqrt(X.y);
}
vec2 projp(vec2 u){
//u *= 2.;
u.y -= 0.5;
u.x /= R.x/R.y;
u += 1.;
u /= 2;
u *= R;
return u;
}
void main( ){
int iFrame = iFramee - 1;
//seed = uint((((iFrame)*73856093)^int(gl_FragCoord.x)*19349663^int(gl_FragCoord.y)*83492791)%38069);
//vec2 uv = (gl_FragCoord.xy - 0.5* iResolution.xy) / iResolution.y;
//vec2 nuv = (gl_FragCoord.xy) / iResolution.xy;
uint id = gl_GlobalInvocationID.x;
seed = 124124u + id + iFrame * 10000u;
if(id < 1000){
vec2 p = vec2(0);
vec2 dir = vec2(1);
if(hash_f() < 0.5){
dir.x = -dir.x;
}
if(hash_f() < 0.5){
dir.y = -dir.y;
}
float its = 2000.;
float br = 1.;
float brb = 1.;
float start_sgn = sign(dir.x);
for(float i = 0.; i < its; i++){
p += dir * 0.002;
if(i > 1.)
dir += 0.09*cyclicNoise(
2.*vec3(vec2(abs(p.x),p.y + hash_f_s(id)*.05),0.2),
0.2
).xy*0.2/brb;
dir *= rot(-(0.003+ hash_f_s(id)*.001)*start_sgn);
p += 0.001/brb*cyclicNoise(
vec3(1.*vec2(abs(p.x),p.y + hash_f_s(seed)*100.),0.2),
1.
).xy * hash_f_s(id);
if(mod(i + 1.,floor(100. + brb * 0.9)) <0.5){
dir *= rot(start_sgn*sign(hash_f() - 0.4)*0.5);
br *= 1.3;
brb += 0.5;
}
//dir = normalize(dir);
vec2 q = projp(p + sample_circ()*0.00);
//splat(q,1.);
//splat(q,0. + 5.3*pow(i/its,2.));
splat(q,brb*0.2);
}
//cyclicNoise( vec3 p, float pump )
//splat
}
//float sd = vec2();
//fragColor.rgb = col.rgb;
//fragColor.rgb = vec3(1,0,1);
}
Problem
The name "A" clashes with variables produced by shader minifier. Results in a compilation error (win 11 nvidia).
Solution
The buffer name doesn't matter. It serves no purpose in the language. You can't access the buffer using "A".
But it's needed, by glsl spec, to declare a buffer.
Maybe after minification pass, some random name could be chosen?
Full problematic shader (shader minifier 1.5.1):