Skip to main content
Tweeted twitter.com/StackGameDev/status/1045417898943148036
Post Reopened by eclmist, Vaillancourt
Removed the call-for-opinions parts. ; edited tags
Source Link
Vaillancourt
  • 16.4k
  • 17
  • 56
  • 61

Why do so many graphics programmers adopt Are there technical reasons to use short and cryptic coding stylesvariable names in shader code?

I have been reading and writing both GLSL and CG for the past few years, and have noticed a trend. In programming, we are generally advised to be as meaningful and concise as possible with variable names, but I see this rule to be brokensuggestion being ignored almost every time I look at shaders.

Here is a random example I grabbed off of Shadertoy:

vec3 tex_wmcs(vec2 p)
{
    float s=mix(0.2,1.2,sqrt(smoothNoise2(p*3.0)));
    vec3 col=mix(vec3(0.15,0.2,0.2)*0.4,vec3(0.2,0.15,0.11)*0.7*s,sqrt(max(0.0,sm...
    vec2 p2=p*vec2(4.0,10.0)+vec2(smoothNoise2(p*24.0),smoothNoise2...
    p2.x+=floor(p2.y)*0.5;
    float bh=pow(0.5+0.5*cos(floor(p2.y)*14.0)*cos(floor(p2.x)*1.0),2.0);
    float brick=brickt(p2);
    vec3 bn=normalize(vec3(brickt(p2+vec2(1e-3,0.0))-brick,b...
    ...
}

Why doIs there a practical reason so many graphics programmers like to minify their code to thesuch a point that it is no longer comprehensible by someone else at first glance? I have not worked in a production environment so I can't say that this is how every graphics programmer codes, but it is an observation.

Is there a downsidetechnical downside to spelling out brickNormal instead of lazily leaving it as bn? And, or using brick_tangent or brickTexture instead of brickt? Brick tangent? Brick texture?

Are there any practical or technical reasons today as for why this is done?

Why do so many graphics programmers adopt short and cryptic coding styles?

I have been reading and writing both GLSL and CG for the past few years, and have noticed a trend. In programming, we are generally advised to be as concise as possible with variable names, but I see this rule to be broken almost every time I look at shaders.

Here is a random example I grabbed off of Shadertoy:

vec3 tex_wmcs(vec2 p)
{
    float s=mix(0.2,1.2,sqrt(smoothNoise2(p*3.0)));
    vec3 col=mix(vec3(0.15,0.2,0.2)*0.4,vec3(0.2,0.15,0.11)*0.7*s,sqrt(max(0.0,sm...
    vec2 p2=p*vec2(4.0,10.0)+vec2(smoothNoise2(p*24.0),smoothNoise2...
    p2.x+=floor(p2.y)*0.5;
    float bh=pow(0.5+0.5*cos(floor(p2.y)*14.0)*cos(floor(p2.x)*1.0),2.0);
    float brick=brickt(p2);
    vec3 bn=normalize(vec3(brickt(p2+vec2(1e-3,0.0))-brick,b...
    ...
}

Why do so many graphics programmers like to minify their code to the point that it is no longer comprehensible by someone else at first glance? I have not worked in a production environment so I can't say that this is how every graphics programmer codes, but it is an observation.

Is there a downside to spelling out brickNormal instead of lazily leaving it as bn? And brickt? Brick tangent? Brick texture?

Are there any practical or technical reasons today as for why this is done?

Are there technical reasons to use short variable names in shader code?

I have been reading and writing both GLSL and CG for the past few years, and have noticed a trend. In programming, we are generally advised to be as meaningful and concise as possible with variable names, but I see this suggestion being ignored almost every time I look at shaders.

Here is a random example I grabbed off of Shadertoy:

vec3 tex_wmcs(vec2 p)
{
    float s=mix(0.2,1.2,sqrt(smoothNoise2(p*3.0)));
    vec3 col=mix(vec3(0.15,0.2,0.2)*0.4,vec3(0.2,0.15,0.11)*0.7*s,sqrt(max(0.0,sm...
    vec2 p2=p*vec2(4.0,10.0)+vec2(smoothNoise2(p*24.0),smoothNoise2...
    p2.x+=floor(p2.y)*0.5;
    float bh=pow(0.5+0.5*cos(floor(p2.y)*14.0)*cos(floor(p2.x)*1.0),2.0);
    float brick=brickt(p2);
    vec3 bn=normalize(vec3(brickt(p2+vec2(1e-3,0.0))-brick,b...
    ...
}

Is there a practical reason so many graphics programmers minify their code to such a point?

Is there a technical downside to spelling out brickNormal instead of leaving it as bn, or using brick_tangent or brickTexture instead of brickt?

Made question request for a less subjective answer
Source Link
eclmist
  • 1.1k
  • 10
  • 29

I have been reading and writing both GLSL and CG for the past few years, and have noticed a trend. In programming, we are generally advised to be as concise as possible with variable names, but I see this rule to be broken almost every time I look at shaders.

Here is a random example I grabbed off of Shadertoy:

vec3 tex_wmcs(vec2 p)
{
    float s=mix(0.2,1.2,sqrt(smoothNoise2(p*3.0)));
    vec3 col=mix(vec3(0.15,0.2,0.2)*0.4,vec3(0.2,0.15,0.11)*0.7*s,sqrt(max(0.0,sm...
    vec2 p2=p*vec2(4.0,10.0)+vec2(smoothNoise2(p*24.0),smoothNoise2...
    p2.x+=floor(p2.y)*0.5;
    float bh=pow(0.5+0.5*cos(floor(p2.y)*14.0)*cos(floor(p2.x)*1.0),2.0);
    float brick=brickt(p2);
    vec3 bn=normalize(vec3(brickt(p2+vec2(1e-3,0.0))-brick,b...
    ...
}

Why do so many graphics programmers like to minify their code to the point that it is no longer comprehensible by someone else at first glance? I have not worked in a production environment so I can't say that this is how every graphics programmer codes, but it is an observation.

Is there a downside to spelling out brickNormal instead of lazily leaving it as bn? And brickt? Brick tangent? Brick texture?

Are there any good reasons (or excuses) for leaving it that way? Is this just a habit that some programmer has due to the lack of the abundance of storage back in the days? Is this acceptable in a modern, production setting?Are there any practical or technical reasons today as for why this is done?

I have been reading and writing both GLSL and CG for the past few years, and have noticed a trend. In programming, we are generally advised to be as concise as possible with variable names, but I see this rule to be broken almost every time I look at shaders.

Here is a random example I grabbed off of Shadertoy:

vec3 tex_wmcs(vec2 p)
{
    float s=mix(0.2,1.2,sqrt(smoothNoise2(p*3.0)));
    vec3 col=mix(vec3(0.15,0.2,0.2)*0.4,vec3(0.2,0.15,0.11)*0.7*s,sqrt(max(0.0,sm...
    vec2 p2=p*vec2(4.0,10.0)+vec2(smoothNoise2(p*24.0),smoothNoise2...
    p2.x+=floor(p2.y)*0.5;
    float bh=pow(0.5+0.5*cos(floor(p2.y)*14.0)*cos(floor(p2.x)*1.0),2.0);
    float brick=brickt(p2);
    vec3 bn=normalize(vec3(brickt(p2+vec2(1e-3,0.0))-brick,b...
    ...
}

Why do so many graphics programmers like to minify their code to the point that it is no longer comprehensible by someone else at first glance? I have not worked in a production environment so I can't say that this is how every graphics programmer codes, but it is an observation.

Is there a downside to spelling out brickNormal instead of lazily leaving it as bn? And brickt? Brick tangent? Brick texture?

Are there any good reasons (or excuses) for leaving it that way? Is this just a habit that some programmer has due to the lack of the abundance of storage back in the days? Is this acceptable in a modern, production setting?

I have been reading and writing both GLSL and CG for the past few years, and have noticed a trend. In programming, we are generally advised to be as concise as possible with variable names, but I see this rule to be broken almost every time I look at shaders.

Here is a random example I grabbed off of Shadertoy:

vec3 tex_wmcs(vec2 p)
{
    float s=mix(0.2,1.2,sqrt(smoothNoise2(p*3.0)));
    vec3 col=mix(vec3(0.15,0.2,0.2)*0.4,vec3(0.2,0.15,0.11)*0.7*s,sqrt(max(0.0,sm...
    vec2 p2=p*vec2(4.0,10.0)+vec2(smoothNoise2(p*24.0),smoothNoise2...
    p2.x+=floor(p2.y)*0.5;
    float bh=pow(0.5+0.5*cos(floor(p2.y)*14.0)*cos(floor(p2.x)*1.0),2.0);
    float brick=brickt(p2);
    vec3 bn=normalize(vec3(brickt(p2+vec2(1e-3,0.0))-brick,b...
    ...
}

Why do so many graphics programmers like to minify their code to the point that it is no longer comprehensible by someone else at first glance? I have not worked in a production environment so I can't say that this is how every graphics programmer codes, but it is an observation.

Is there a downside to spelling out brickNormal instead of lazily leaving it as bn? And brickt? Brick tangent? Brick texture?

Are there any practical or technical reasons today as for why this is done?

Post Closed as "Opinion-based" by Vaillancourt
Source Link
eclmist
  • 1.1k
  • 10
  • 29

Why do so many graphics programmers adopt short and cryptic coding styles?

I have been reading and writing both GLSL and CG for the past few years, and have noticed a trend. In programming, we are generally advised to be as concise as possible with variable names, but I see this rule to be broken almost every time I look at shaders.

Here is a random example I grabbed off of Shadertoy:

vec3 tex_wmcs(vec2 p)
{
    float s=mix(0.2,1.2,sqrt(smoothNoise2(p*3.0)));
    vec3 col=mix(vec3(0.15,0.2,0.2)*0.4,vec3(0.2,0.15,0.11)*0.7*s,sqrt(max(0.0,sm...
    vec2 p2=p*vec2(4.0,10.0)+vec2(smoothNoise2(p*24.0),smoothNoise2...
    p2.x+=floor(p2.y)*0.5;
    float bh=pow(0.5+0.5*cos(floor(p2.y)*14.0)*cos(floor(p2.x)*1.0),2.0);
    float brick=brickt(p2);
    vec3 bn=normalize(vec3(brickt(p2+vec2(1e-3,0.0))-brick,b...
    ...
}

Why do so many graphics programmers like to minify their code to the point that it is no longer comprehensible by someone else at first glance? I have not worked in a production environment so I can't say that this is how every graphics programmer codes, but it is an observation.

Is there a downside to spelling out brickNormal instead of lazily leaving it as bn? And brickt? Brick tangent? Brick texture?

Are there any good reasons (or excuses) for leaving it that way? Is this just a habit that some programmer has due to the lack of the abundance of storage back in the days? Is this acceptable in a modern, production setting?