OPTIM: shader optimization

This commit is contained in:
2025-12-26 14:29:59 +09:00
parent d6216b20fc
commit cead54c32e
12 changed files with 196 additions and 109 deletions

View File

@@ -17,7 +17,12 @@ float NoisyStarField( in vec2 vSamplePos, float fThreshhold )
{
float StarVal = Noise2d( vSamplePos );
if ( StarVal >= fThreshhold )
StarVal = pow( (StarVal - fThreshhold)/(1.0 - fThreshhold), 6.0 );
{
float t = (StarVal - fThreshhold) / (1.0 - fThreshhold);
float t2 = t * t;
float t4 = t2 * t2;
StarVal = t4 * t2;
}
else
StarVal = 0.0;
return StarVal;
@@ -57,7 +62,7 @@ void mainImage( out vec4 fragColor, in vec2 fragCoord )
// Stars with a slow crawl.
float xRate = 0.2;
float yRate = -0.06;
vec2 vSamplePos = fragCoord.xy + vec2( xRate * float( 1 ), yRate * float( 1 ) );
vec2 vSamplePos = fragCoord.xy + vec2( xRate, yRate );
float StarVal = StableStarField( vSamplePos, StarFieldThreshhold );
vColor += vec3( StarVal );
@@ -80,4 +85,3 @@ void main()
imageStore(image, texelCoord, color);
}
}