Skip to content

Commit 6e5dc91

Browse files
committed
Small planet change, and ability to change planet size with 'a' and 'd'
1 parent e57d63a commit 6e5dc91

File tree

5 files changed

+23
-21
lines changed

5 files changed

+23
-21
lines changed

Blobtory/Scripts/Main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# so stuff doesn't get out of control
1010
#
1111
# Author: Daniel Kierkegaard Andersen (dax@daxode.dk)
12-
# Version: 2020-09-22
12+
# Version: 2020-10-24
1313
#
1414
# Copyright (c) 2020 Daniel Kierkegaard Andersen. All rights reserved.
1515
# https://github.com/Daxode/ComplexSoftwareProject

Blobtory/Scripts/game/SceneBuilder.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,15 @@ def SetupScene(self):
3131
Sequence(startInterval, endInterval).loop()
3232

3333
def SetupPlanets(self):
34-
planetGen: PlanetGenerator = PlanetGenerator(self.winCreator, 128, 500)
35-
planetGen.cubeformer.mouseTime.setData(PTAFloat([10, 0, 0, 1]))
36-
self.base.accept("a", planetGen.RegenPlanet)
34+
planetGen: PlanetGenerator = PlanetGenerator(self.winCreator, 128, 450)
35+
self.base.accept("d", self.IncreaseSize, [planetGen, 1.5])
36+
self.base.accept("d-repeat", self.IncreaseSize, [planetGen, 1.5])
37+
self.base.accept("a", self.IncreaseSize, [planetGen, -1.5])
38+
self.base.accept("a-repeat", self.IncreaseSize, [planetGen, -1.5])
39+
40+
def IncreaseSize(self, planetGen: PlanetGenerator, a):
41+
planetGen.cubeformer.mouseTime.setData(PTAFloat([10, 0, 0, planetGen.cubeformer.mouseTime.getElement(3)+a]))
42+
planetGen.RegenPlanet()
3743

3844
def SetupLighting(self):
3945
# Add ambient lighting

Blobtory/Scripts/planet_former/CubeFormer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(self, winCreator: WindowCreator, width: int, length: int, height: i
1616
self.size = LVecBase3i(width, length, height)
1717
self.spacing = spacing
1818
self.vertexCount = width*length*height
19-
self.mouseTime = PTAFloat([0, 0, 0, 0])
19+
self.mouseTime: PTAFloat = PTAFloat([0, 0, 0, 0])
2020

2121
def GenerateCube(self) -> Texture:
2222
if self.vertexBuffer is None:

assets/shaders/compute/alphaNoiseSphere.glsl

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ uniform float radius;
88
uniform float offset;
99
uniform vec3 midPoint;
1010
uniform vec4 mouseTime;
11-
const int craterCount = 30;
11+
const int craterCount = 300;
1212

1313
layout(rgba32f, binding = 0) uniform image3D vertexBufferWAlpha;
1414

@@ -38,34 +38,30 @@ void main() {
3838
if (mouseTime.x == 0) mouseX = 0.1;
3939

4040
float lengthFromCenter = length(movedPoint);
41-
// float phi = atan(movedPoint.y/movedPoint.x);
42-
// float theta = acos(movedPoint.z/r)+mouseTime.y;
43-
// vec3 polarCoord = vec3(r, phi, theta);
4441

45-
46-
// point.w = (snoise(polarCoord.yz/(mouseX*10))*radius - r);
47-
48-
float noiseOuter = 1-abs(fractalNoise(normalize(movedPoint)*1)+1)*mouseTime.w*100;
42+
float noiseOuter = (1-abs(fractalNoise(normalize(movedPoint)*1)+1))*mouseTime.w;
4943
float planetRadius = radius+noiseOuter;
50-
point.w = smoothstep(0, 1, (planetRadius - lengthFromCenter)/10);
44+
point.w = smoothstep(0, 1, (planetRadius - lengthFromCenter)/100);
5145

5246

53-
float cometOffset = 0.9;
54-
float cometDiff = 0.01;
55-
float sizeMatters = 0.4;
47+
float cometOffset = 0.8;
48+
float cometDiff = 50.5;
49+
float sizeMatters = 0.1;
5650
for (int i = 0; i < craterCount; i++) {
5751
float theta = rand((offset+i))*2*PI;
5852
float phi = rand((offset+i+200))*2*PI;
5953

60-
float cometSize = rand((offset+i))*200+50;
54+
float cometSize = rand((offset+i))*50+100;
6155

6256
vec3 cartCraterNormal = vec3(sin(theta)*cos(phi), sin(theta)*sin(phi), cos(theta));
6357
vec3 cartCraterPosCenter = (planetRadius*cometOffset-cometDiff+cometSize*sizeMatters)*cartCraterNormal;
6458
vec3 cartCraterPosOffset = (planetRadius*cometOffset+cometSize*sizeMatters)*cartCraterNormal;
6559

66-
point.w += smoothstep(0,1, max(0, cometSize-distance(movedPoint, cartCraterPosCenter)));
67-
point.w -= smoothstep(0,1, max(0, cometSize-cometDiff-distance(movedPoint, cartCraterPosOffset)))*5;
60+
point.w += smoothstep(0,1, max(0, (cometSize-distance(movedPoint, cartCraterPosCenter))/100));
61+
point.w -= smoothstep(0,1, max(0, (cometSize-cometDiff-distance(movedPoint, cartCraterPosOffset))/100))*5;
6862
}
6963

64+
//point.w = dot(sin(movedPoint.xyz*0.05)*0.3, vec3(1));
65+
7066
imageStore(vertexBufferWAlpha, ivec3(gl_GlobalInvocationID.xyz), point);
7167
}

assets/shaders/compute/cubemarcher.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void main() {
7070

7171
vec3 normal = normalize(cross(v2-v0, v1-v0));
7272
//vec3 normal = normalize(v2+v0+v1);
73-
int type = int(distance(vec3(512), v1)/55);
73+
int type = int(distance(vec3(512), v1)/45);
7474
//if(type > 6) if(dot(normalize(vec3(512)-v1), normal)<0.8) type = 5;
7575
imageStore(normalBuffer, int(triangleIDIndex/3), vec4(normal, type));
7676

0 commit comments

Comments
 (0)