SimonDev 2 years ago
parent
commit
796be806ad
3 changed files with 10 additions and 18 deletions
  1. 9 11
      shaders/fragment-shader.glsl
  2. 1 1
      shaders/header.glsl
  3. 0 6
      shaders/sdf-generator-shader.glsl

+ 9 - 11
shaders/fragment-shader.glsl

@@ -67,7 +67,7 @@ float SampleLowResolutionCloudMap(vec3 p) {
 float SampleHighResolutionCloudDetail(float cloudSDF, vec3 worldPos, vec3 cameraOrigin, float curTime) {
   float cloud = circularOut(linearstep(0.0, -CLOUD_FALLOFF, cloudSDF)) * 0.85;
 
-  if(cloud > 0.0){
+  if(cloud > 0.0) {
     vec3 samplePos = worldPos + vec3(-2.0 * curTime, 0.0, curTime) * 1.5;
 
     float shapeSize = 0.4;
@@ -76,7 +76,7 @@ float SampleHighResolutionCloudDetail(float cloudSDF, vec3 worldPos, vec3 camera
     float shapeStrength = CLOUD_BASE_STRENGTH;
     cloud = saturate(remap(cloud, shapeStrength * perlinWorleySample.x, 1.0, 0.0, 1.0));
 
-    if(cloud > 0.0){
+    if(cloud > 0.0) {
       float distToSample = distance(cameraOrigin, worldPos);
       float t_detailDropout = smoothstep(1000.0, 800.0, distToSample);
 
@@ -110,14 +110,14 @@ vec3 MultipleOctaveScattering(float density, float mu) {
   vec3 luminance = vec3(0.0);
 
   for (float i = 0.0; i < scatteringOctaves; i++) {
-      float phaseFunction = PhaseFunction(0.3 * c, mu);
-      vec3 beers = exp(-density * EXTINCTION_MULT * a);
+    float phaseFunction = PhaseFunction(0.3 * c, mu);
+    vec3 beers = exp(-density * EXTINCTION_MULT * a);
 
-      luminance += b * phaseFunction * beers;
+    luminance += b * phaseFunction * beers;
 
-      a *= attenuation;
-      b *= contribution;
-      c *= (1.0 - phaseAttenuation);
+    a *= attenuation;
+    b *= contribution;
+    c *= (1.0 - phaseAttenuation);
   }
   return luminance;
 }
@@ -209,12 +209,10 @@ ScatteringTransmittance CloudMarch(vec2 pixelCoords, vec3 cameraOrigin, vec3 cam
     float cloudMapSDFSample = SampleLowResolutionCloudMap(samplePos);
 
     float currentStepLength = cloudMapSDFSample;
-    // float currentStepLength = lqStepLength;
 
     if (hqMarcherCountdown <= 0) {
       if (cloudMapSDFSample < hqStepLength) {
         // Hit some clouds, step back
-        // distTravelled = (distTravelled - currentStepLength) + hqStepLength;
         hqMarcherCountdown = NUM_COUNT;
 
         distTravelled += hqStepLength * blueNoiseSample;
@@ -260,7 +258,7 @@ ScatteringTransmittance CloudMarch(vec2 pixelCoords, vec3 cameraOrigin, vec3 cam
 }
 
 
-float RenderGlow(float dist, float radius, float intensity){
+float RenderGlow(float dist, float radius, float intensity) {
   dist = max(dist, 1e-6);
 	return (1.0 - exp(-25.0 * (radius / dist))) * 0.1 + (1.0 - exp(-0.05 * (radius / dist) * (radius / dist))) * 2.0;
 }

+ 1 - 1
shaders/header.glsl

@@ -9,8 +9,8 @@ varying vec2 vUvs;
 uniform vec2 resolution;
 uniform float time;
 uniform int frame;
-uniform sampler2D blueNoise;
 
+uniform sampler2D blueNoise;
 uniform sampler3D perlinWorley;
 
 

+ 0 - 6
shaders/sdf-generator-shader.glsl

@@ -12,7 +12,6 @@ float GenerateGridClouds(vec3 coords, float seed, float CELL_WIDTH) {
   vec3 cloudPosition = vec3(0.0);
 
   cloudPosition.xy += cellHashValue.xy;
-  // cloudPosition.z += cellHashValue.z * 0.1;
 
   return sdfSphere(cellCoords - cloudPosition, radius);
 }
@@ -125,11 +124,6 @@ void main() {
   float v2 = smoothstep(0.5, 0.3, abs(vUvs.y - 0.5));
   float v3 = smoothstep(16.0, 12.0, abs(zLevel - 16.0));
   float v = v1 * v2 * v3;
-  // v = pow(v, 2.0);
-  // res *= v;
-
-// float mult = 7.0;
-// res =  1.0 - voronoiSlow(vec3(pos.xy, 0.0) * mult, 0.5, mult, 1.0, 0.0, -1.0);
 
   gl_FragColor = vec4(res);
 }