Skip to content

Commit

Permalink
fix: Improve clouds by flattening dome (temporary test)
Browse files Browse the repository at this point in the history
  • Loading branch information
twpol committed Jan 2, 2023
1 parent 5ab8faa commit da4c88e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Source/RunActivity/Viewer3D/Sky.cs
Expand Up @@ -132,6 +132,7 @@ public class SkyPrimitive : RenderPrimitive
public const float SkyRadius = 6020;
public const float MoonRadius = 6010;
public const float CloudsRadius = 6000;
public const float CloudsFlatness = 0.1f;

public SkyElement Element;

Expand Down Expand Up @@ -175,7 +176,7 @@ public SkyPrimitive(RenderProcess renderProcess)
var vertexIndex = 0;
var indexIndex = 0;
InitializeDomeVertexList(ref vertexIndex, SkyRadius);
InitializeDomeVertexList(ref vertexIndex, CloudsRadius);
InitializeDomeVertexList(ref vertexIndex, CloudsRadius, CloudsFlatness);
InitializeDomeIndexList(ref indexIndex);
InitializeMoonLists(ref vertexIndex, ref indexIndex);
Debug.Assert(vertexIndex == VertexCount, $"Did not initialize all verticies; expected {VertexCount}, got {vertexIndex}");
Expand Down Expand Up @@ -223,10 +224,10 @@ public override void Draw(GraphicsDevice graphicsDevice)
}
}

void InitializeDomeVertexList(ref int index, float radius)
void InitializeDomeVertexList(ref int index, float radius, float flatness = 1)
{
// Single vertex at zenith
VertexList[index].Position = new Vector3(0, radius, 0);
VertexList[index].Position = new Vector3(0, radius * flatness, 0);
VertexList[index].Normal = Vector3.Normalize(VertexList[index].Position);
VertexList[index].TextureCoordinate = new Vector2(0.5f, 0.5f);
index++;
Expand All @@ -236,7 +237,7 @@ void InitializeDomeVertexList(ref int index, float radius)
var stepCos = (float)Math.Cos(MathHelper.ToRadians(90f * step / DomeStepsMain));
var stepSin = (float)Math.Sin(MathHelper.ToRadians(90f * step / DomeStepsMain));

var y = radius * stepCos;
var y = radius * stepCos * flatness;
var d = radius * stepSin;

for (var side = 0; side < DomeSides; side++)
Expand Down

0 comments on commit da4c88e

Please sign in to comment.