diff options
Diffstat (limited to 'BuddhaTest')
-rw-r--r-- | BuddhaTest/Shaders/BuddhaCompute.glsl | 14 | ||||
-rw-r--r-- | BuddhaTest/src/BuddhaTest.cpp | 8 |
2 files changed, 15 insertions, 7 deletions
diff --git a/BuddhaTest/Shaders/BuddhaCompute.glsl b/BuddhaTest/Shaders/BuddhaCompute.glsl index 4ca5141..7a363ec 100644 --- a/BuddhaTest/Shaders/BuddhaCompute.glsl +++ b/BuddhaTest/Shaders/BuddhaCompute.glsl @@ -9,7 +9,7 @@ layout(std430, binding=2) buffer renderedData uniform uint iterationCount;
-uniform uint orbitLength;
+uniform uvec3 orbitLength;
void addToColorOfCell(uvec2 cell, uvec3 toAdd)
{
@@ -155,7 +155,9 @@ vec2 getStartValue(uint seed) bool isGoingToBeDrawn(vec2 offset)
{
vec2 val = vec2(0);
- for(int i = 0; i < orbitLength;++i)
+ uint limit = orbitLength.x > orbitLength.y ? orbitLength.x : orbitLength.y;
+ limit = limit > orbitLength.z ? limit : orbitLength.z;
+ for(uint i = 0; i < limit;++i)
{
val = compSqr(val) + offset;
if(dot(val,val) > 4.0)
@@ -169,7 +171,9 @@ bool isGoingToBeDrawn(vec2 offset) void drawOrbit(vec2 offset)
{
vec2 val = vec2(0);
- for(int i = 0; i < orbitLength;++i)
+ uint limit = orbitLength.x > orbitLength.y ? orbitLength.x : orbitLength.y;
+ limit = limit > orbitLength.z ? limit : orbitLength.z;
+ for(uint i = 0; i < limit;++i)
{
val = compSqr(val) + offset;
if(dot(val,val) > 20.0)
@@ -177,7 +181,9 @@ void drawOrbit(vec2 offset) return;
}
if(val.x > -2.5 && val.x < 1.0 && val.y > -1.0 && val.y < 1.0)
- addToColorAt(val,uvec3(1,1,1));
+ {
+ addToColorAt(val,uvec3(i < orbitLength.r,i < orbitLength.g,i < orbitLength.b));
+ }
}
}
diff --git a/BuddhaTest/src/BuddhaTest.cpp b/BuddhaTest/src/BuddhaTest.cpp index 790b0b2..57edc14 100644 --- a/BuddhaTest/src/BuddhaTest.cpp +++ b/BuddhaTest/src/BuddhaTest.cpp @@ -14,7 +14,9 @@ int main() unsigned int bufferWidth = 1600;
unsigned int bufferHeight = 900;
- unsigned int orbitLength = 1000;
+ unsigned int orbitLengthRed = 100;
+ unsigned int orbitLengthGreen = 10;
+ unsigned int orbitLengthBlue = 1000;
GLFWwindow* window;
@@ -81,7 +83,7 @@ int main() glUseProgram(ComputeShader);
GLint iterationCountUniformHandle = glGetUniformLocation(ComputeShader, "iterationCount");
GLint orbitLengthUniformHandle = glGetUniformLocation(ComputeShader, "orbitLength");
- glUniform1ui(orbitLengthUniformHandle,orbitLength);
+ glUniform3ui(orbitLengthUniformHandle,orbitLengthRed,orbitLengthGreen,orbitLengthBlue);
glClearColor(0.0f, 0.0f, 0.4f, 0.0f);
@@ -92,7 +94,7 @@ int main() glUseProgram(ComputeShader);
//increase iterationCount, which is used for pseudo random generation
glUniform1ui(iterationCountUniformHandle,++iterationCount);
- glDispatchCompute(128, 1, 1);
+ glDispatchCompute(1024, 1, 1);
//before reading the values in the ssbo, we need a memory barrier:
glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT); //I hope this is the correct (and only required) bit
|