47 const Point warp=
Scale({1.5f,-1.1f,.9f},low-.5f);
49 const float localCluster=
Smooth((.65f*broad+.35f*low-.35f)/.3f);
51 const float structure=growth*(.35f+.65f*cluster);
55 return {radial,surface,drift,
weather,low,cluster,structure,top};
118 const auto region=prepared ? *prepared :
Regional(p,params,seed);
119 const float weight=
Weight(params);
120 const float blend=
Smooth((altitude-params.
top+.5f)/.5f)*weight;
122 if(altitude<=region.top && blend>0)
124 const float height=(std::max)(0.f,altitude-params.
top+.65f);
125 const float h=height/(std::max)(.65f,(region.top-params.
top)*(.04f+.96f*region.cluster*region.cluster)+.65f);
126 const Point drift=region.drift;
127 const Point flow=
Flow(region,drift,height);
129 Add(
Scale(region.radial,height*.85f),
Scale(flow,-height*.35f)));
133 Add(
Scale(region.radial,height*.5f),
Scale(flow,-height*.35f)));
134 const float parentA=
Billow(
Scale(parentDomain,.105f));
135 const float parentB=
Billow(
Scale(
Add(domain,{3,7,1}),.155f))*.86f+.09f;
136 const float overlap=
Saturate(.5f+.5f*(parentB-parentA)/.14f);
137 const float parent=
Lerp(parentB,parentA,overlap)-.14f*overlap*(1-overlap);
147 smallField=
Lerp(smallField,(a+2*smallField+b)*.25f,wispy);
150 shoulders=
Lerp(shoulders,(shoulderA+2*shoulders+shoulderB)*.25f,wispy);
153 const float field=.78f-.50f*h*h*h-parent-.38f*shoulders+.12f*smallField+.035f*grain;
155 const float shape=
Smooth(field/(.10f+.12f*wispy))*sheetGrowth;
156 float floorDensity=0;
157 if(altitude<params.
top+1.35f)
160 const Point axis=std::abs(region.radial.z)<.9f ?
Point{0,0,1} :
Point{0,1,0};
163 const auto weatherAt=[&](
Point offset) {
166 const float de=weatherAt(
Scale(east,24))-weatherAt(
Scale(east,-24));
167 const float dn=weatherAt(
Scale(north,24))-weatherAt(
Scale(north,-24));
169 const float magnitude=
Length(gradient),contourWeight=
Saturate(magnitude*32.f);
170 const Point contour=
Scale(
Cross(region.radial,gradient),1.f/std::sqrt(
Dot(gradient,gradient)+.0001f));
173 const auto sheet=[&](
float offset) {
176 const float a=sheet(0),ribbon=(2*a+sheet(-3)+sheet(3))*.25f;
179 const float pattern=
Smooth((region.low-.25f)/.5f);
180 const float broad=
Lerp(a,ribbon,pattern);
181 const float medium=
Perlin(
Add(
Scale(sheetDomain,.70f),{11,5,23}));
183 const float relief=.57f+.50f*(broad-.5f)+.20f*medium+.08f*fine+.04f*(region.low-.5f);
184 const float floorTop=params.
top-.35f+relief*(.28f+.72f*sheetGrowth);
185 floorDensity=
Smooth((floorTop-altitude)/.35f);
187 upper=(std::max)(floorDensity,shape)*
Smooth((region.top-altitude)/.35f)
188 *(.65f+.35f*region.weather)*(.5f+.5f*region.weather);
192 float topDepth=region.top-altitude;
195 return {
Lerp(lower.density,upper,blend),topDepth,region.weather,
196 Lerp(lower.extinction,upper*32.f,blend)};
203 const auto region=
Regional(p,params,seed);
206 const float base=controls.base+(
Noise(
Scale(region.surface,.71f),seed)-.5f)
207 *(.12f+.24f*
Smooth((controls.turbulence-.2f)/.65f));
208 const float envelope=
Weight(params)<1 ? (std::max)(region.top,
LegacyBoundaries(p,params,seed).top) : region.top;
209 float high=envelope,low=params.
top;
210 const auto occupied=[&](
float altitude) {
211 return Evaluate(
Scale(region.radial,params.
radius+altitude),params,seed,®ion).density>.001f;
213 for(
int step=0;step<1201;++step)
215 const float altitude=(std::max)(params.
top,envelope-.01f*step);
216 if(occupied(altitude)){low=altitude;
break;}
220 if(altitude<=params.
top)
break;
222 for(
int step=0;step<8;++step)
224 const float middle=(low+high)*.5f;
225 if(occupied(middle))low=middle;
else high=middle;
227 return {base,high,region.weather,region.structure,controls.turbulence};