| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 
 | float StarfieldLayer(float2 uv, float layerSeed, float time){
 float starValue = 0.0;
 
 float layerDensity = _StarDensity * LayerVariation(layerSeed, 1.0, 0.5);
 float layerBrightness = _StarBrightness * LayerVariation(layerSeed + 1.0, 1.0, 0.6);
 float layerSize = _StarSize * LayerVariation(layerSeed + 2.0, 1.0, 0.4);
 
 float2 gridOffset = float2(
 SmoothRandom(layerSeed + 50.0),
 SmoothRandom(layerSeed + 51.0)
 ) * 0.5;
 
 float2 grid1 = (uv + gridOffset) * layerDensity * LayerVariation(layerSeed + 20.0, 15.0, 8.0);
 float2 id1 = floor(grid1);
 float2 gv1 = frac(grid1) - 0.5;
 
 float threshold1 = 0.85 + 0.1 * SmoothRandom(layerSeed + 30.0);
 float rand1 = SmoothHash(id1 + layerSeed);
 if (rand1 > threshold1)
 {
 float2 offset1 = (SmoothHash(id1 + layerSeed + 1.0) - 0.5) * LayerVariation(layerSeed + 40.0, 0.6, 0.3);
 float starBrightness1 = SmoothHash(id1 + layerSeed + 2.0) * layerBrightness;
 starValue += CreateStar(gv1, offset1, layerSize * 1.2, starBrightness1, time + layerSeed);
 }
 
 float gridScale2 = LayerVariation(layerSeed + 60.0, 30.0, 15.0);
 float2 grid2 = (uv + gridOffset * 0.7) * layerDensity * gridScale2;
 float2 id2 = floor(grid2);
 float2 gv2 = frac(grid2) - 0.5;
 
 float threshold2 = 0.8 + 0.15 * SmoothRandom(layerSeed + 70.0);
 float rand2 = SmoothHash(id2 + layerSeed + 10.0);
 if (rand2 > threshold2)
 {
 float2 offset2 = (SmoothHash(id2 + layerSeed + 11.0) - 0.5) * LayerVariation(layerSeed + 80.0, 0.6, 0.4);
 float starBrightness2 = SmoothHash(id2 + layerSeed + 12.0) * layerBrightness * 0.8;
 starValue += CreateStar(gv2, offset2, layerSize * 1.0, starBrightness2, time + layerSeed * 0.7);
 }
 
 if (SmoothRandom(layerSeed + 90.0) > 0.3)
 {
 float gridScale3 = LayerVariation(layerSeed + 100.0, 50.0, 25.0);
 float2 grid3 = (uv + gridOffset * 1.3) * layerDensity * gridScale3;
 float2 id3 = floor(grid3);
 float2 gv3 = frac(grid3) - 0.5;
 
 float threshold3 = 0.88 + 0.1 * SmoothRandom(layerSeed + 110.0);
 float rand3 = SmoothHash(id3 + layerSeed + 20.0);
 if (rand3 > threshold3)
 {
 float2 offset3 = (SmoothHash(id3 + layerSeed + 21.0) - 0.5) * 0.4;
 float starBrightness3 = SmoothHash(id3 + layerSeed + 22.0) * layerBrightness * 0.5;
 starValue += CreateStar(gv3, offset3, layerSize * 0.7, starBrightness3, time + layerSeed * 1.3);
 }
 }
 
 return min(starValue, _MaxBrightness);
 }
 
 |