Commit a1caf32e authored by David Gilbert's avatar David Gilbert

Fixed and broke some stuff

parent b8c3cc2f
......@@ -19,23 +19,25 @@ uniform vec3 cameraPosition;
float getTessLevel(float d0, float d1){
float avg = (d0 + d1) / 2.0;
if(avg >= 1000){
if(avg >= 100){
return 1;
}
if(avg >= 500){
if(avg >= 80){
return 2;
}
if(avg >= 400){
if(avg >= 60){
return 4;
}
if(avg >= 200){
if(avg >= 40){
return 8;
}
if(avg >= 100){
if(avg >= 20){
return 16;
}
if(avg >= 50){
if(avg >= 10){
return 32;
}
if(avg >= 0){
......
......@@ -211,7 +211,7 @@ void main(){
//vec4 camWorld = uModelMatrix * vec4(tPosition, 1.0);
tPosition += tNormal * fBM( tPosition , 8, 64, 0.007) ;
//tPosition += tNormal * fBM( tPosition , 8, 80, 0.003) ;
//tNormal = inverse(transpose(mat3(uModelMatrix))) * normalize(tNormal);
......
......@@ -21,18 +21,18 @@ uniform vec2 viewport;
float getTessLevel(float d0, float d1){
float avg = (d0 + d1) / 2.0;
float factor = 1.0;
if(avg >= 2500 * factor){
float factor = 1.0/(recursionDepth*recursionDepth*recursionDepth);
if(avg >= 2000 * factor){
return 1;
}
if(avg >= 1500 * factor){
if(avg >= 1000 * factor){
return 2;
}
if(avg >= 1000 * factor){
if(avg >= 700 * factor){
return 4;
}
if(avg >= 500 * factor){
if(avg >= 400 * factor){
return 8;
}
if(avg >= 200 * factor){
......@@ -41,13 +41,10 @@ float getTessLevel(float d0, float d1){
if(avg >= 100 * factor){
return 32;
}
if(avg >= 50 * factor){
return 64;
}
if(avg >= 0){
return 64;
}
else return 0;
else return 1;
}
......
......@@ -208,7 +208,7 @@ void main(){
//vec4 camWorld = uModelMatrix * vec4(tPosition, 1.0);
//tPosition += tNormal * fBM( tPosition , 8, 32, 0.005 ) ;
//tPosition += tNormal * fBM( tPosition , 8, 32, 0.002 ) ;
//tNormal = inverse(transpose(mat3(uModelMatrix))) * normalize(tNormal);
//tPosition = (uModelMatrix * vec4(tPosition, 1)).xyz;
......
......@@ -65,10 +65,12 @@ void GameLoopSystem::run() {
SDL_StartTextInput();
Uint32 currentTime = SDL_GetTicks();
Uint32 accumulator = 0;
Uint32 t = 0;
Uint32 dt = Uint32(1000.0f / m_targetFrameRate);
Uint32 accumulator = dt;
do {
Uint32 newTime = SDL_GetTicks();
......
......@@ -88,7 +88,7 @@ bool RendererSystem::startup() {
m_transformFeedbackBuffer->bind(GL_TRANSFORM_FEEDBACK_BUFFER);
m_transformFeedbackVAO->bind();
m_transformFeedbackBuffer->setData(GL_TRANSFORM_FEEDBACK_BUFFER, 100000 *3*3*2, NULL, GL_DYNAMIC_COPY);
m_transformFeedbackBuffer->setData(GL_TRANSFORM_FEEDBACK_BUFFER, 300000 *3*3*2, NULL, GL_DYNAMIC_COPY);
// Second buffer
m_transformFeedbackVAO2 = SharedVertexArrayObject(new VertexArrayObject(GL_TRIANGLES));
......@@ -102,7 +102,7 @@ bool RendererSystem::startup() {
m_transformFeedbackBuffer2->bind(GL_TRANSFORM_FEEDBACK_BUFFER);
m_transformFeedbackVAO2->bind();
m_transformFeedbackBuffer2->setData(GL_TRANSFORM_FEEDBACK_BUFFER, 100000 * 3 * 3 * 2, NULL, GL_DYNAMIC_COPY);
m_transformFeedbackBuffer2->setData(GL_TRANSFORM_FEEDBACK_BUFFER, 300000 * 3 * 3 * 2, NULL, GL_DYNAMIC_COPY);
// Feedback objects
......@@ -272,60 +272,51 @@ void RendererSystem::frame(double interp, double totalTime) {
auto& drawCall = m_submittedDrawCallsOpaque[i];
glEnable(GL_RASTERIZER_DISCARD);
// Render drawcall to buffer
for (int i = 0; i < drawCall.recursionDepth; i++) {
glEnable(GL_RASTERIZER_DISCARD);
for (int j = 0; j < drawCall.recursionDepth; j++) {
m_tfShaderProg->use();
m_tfShaderProg->setUniform("uFar", cam->far);
m_tfShaderProg->setUniform("uModelMatrix", drawCall.thisRenderTransform);
m_tfShaderProg->setUniform("uViewProjectionMatrix", viewProjectionMatrix);
m_tfShaderProg->setUniform("cameraPosition", glm::vec3{ camPos.x, camPos.y, camPos.z });
m_tfShaderProg->setUniform("recursionDepth", (float) i+1);
m_tfShaderProg->setUniform("recursionDepth", (float) j+1);
m_tfShaderProg->setUniform("viewport", windowSize);
q->begin();
// First pass will render the geometry vao into the transform feedback buffer which is the first one initially
if (i == 0) {
glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, Feedback);
glBeginTransformFeedback(GL_TRIANGLES);
if (j == 0) {
glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, Feedback);
glBeginTransformFeedback(GL_TRIANGLES);
drawCall.geometry.vao->render();
glEndTransformFeedback();
glEndTransformFeedback();
}
// If we're doing an odd number of recursion, render the first buffer into the second one.
else if (i % 2 == 1){
else if (j % 2 == 1){
m_transformFeedbackVAO->bind();
m_transformFeedbackBuffer->bindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0);
glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, Feedback2);
glBeginTransformFeedback(GL_TRIANGLES);
glDrawTransformFeedback(GL_PATCHES, Feedback);
glEndTransformFeedback();
glEndTransformFeedback();
}
// Even number: Second -> First
else if (i % 2 == 2) {
else if (j % 2 == 2) {
m_transformFeedbackVAO2->bind();
m_transformFeedbackBuffer2->bindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0);
glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, Feedback);
glBeginTransformFeedback(GL_TRIANGLES);
glDrawTransformFeedback(GL_PATCHES, Feedback2);
glEndTransformFeedback();
glEndTransformFeedback();
}
q->end();
glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glDisable(GL_RASTERIZER_DISCARD);
}
glDisable(GL_RASTERIZER_DISCARD);
......
......@@ -127,7 +127,7 @@ void OrbitalSimulationSystem::simulateOrbitals(float dt, float totalTime) {
p.unpack<Planet, Transform>(planet, transform);
// dt here is interpreted as a DAY NUMBER. TODO: Conversion/scale
position = applyKepler(planet, dt*1 );
position = applyKepler(planet, dt*0.1 );
position = glm::vec3(AUToWorld(position.x), AUToWorld(position.y), AUToWorld(position.z));
// TODO: Natural conversion from au to world coords
......@@ -142,7 +142,7 @@ Entity OrbitalSimulationSystem::addPlanet(Transform::Handle sun, std::string n,
auto planetEntity = m_scene->create();
auto planetTransform = planetEntity.assign<Transform>();
planetTransform->parent = sun;
planetEntity.assign<Drawable>(defaultGeom, planetMat, 1 );
//planetEntity.assign<Light>(glm::vec4(1, 1, 1, 1), glm::vec3(1, 0, 0), false);
// Mass, Radius, Eccentricity, Semimajor axis, Inclination, Ascending Node, Arg. of Periapsis, time at perihelion
......@@ -155,6 +155,8 @@ Entity OrbitalSimulationSystem::addPlanet(Transform::Handle sun, std::string n,
planetTransform->scale = glm::vec3(solarToWorld(r), solarToWorld(r), solarToWorld(r));
planetTransform->position = pos;
planetEntity.assign<Drawable>(defaultGeom, planetMat, 1);
// Add an atmosphere to the planet
auto atmosphere = m_scene->create();
auto atmosphereTransform = atmosphere.assign<Transform>();
......@@ -167,7 +169,7 @@ Entity OrbitalSimulationSystem::addPlanet(Transform::Handle sun, std::string n,
auto moon = m_scene->create();
auto moonTransform = moon.assign<Transform>();
moonTransform->parent = planetTransform;
//moon.assign<Drawable>(defaultGeom, planetMat, true);
moon.assign<Drawable>(defaultGeom, planetMat);
auto moonComponent = moon.assign<Planet>("Moon", 0.000000036939686, 0.003505316091954, 0.205633, 0.08, 0.0898041713, 5.4583095414, 1.671072474, 0 );
// change starting point
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment