This commit is contained in:
barmal4 2022-01-19 18:23:15 +01:00
parent 260fe761fb
commit c5c2f8af9d
2 changed files with 8 additions and 5 deletions

View File

@ -1,6 +1,6 @@
#version 410 core
uniform vec3 objectColor;
uniform vec4 objectColor;
uniform vec3 lightPos;
uniform vec3 cameraPos;
@ -30,5 +30,5 @@ void main()
float specular = pow(max(0,dot(R,V)),10);
float diffuse = max(0,dot(normal,lightDir));
gl_FragColor = vec4(mix(objectColor,objectColor*diffuse+vec3(1)*specular,0.9), 1.0) * (1.0f - depth) + vec4(depth * vec3(5.0f/255.0f, 35.0f/255.0f, 95.0f/255.0f), 1.0f);
gl_FragColor = vec4(mix(objectColor.rgb,objectColor.rgb*diffuse+vec3(1)*specular,0.9), 1.0) * (1.0f - depth) + vec4(depth * vec3(5.0f/255.0f, 35.0f/255.0f, 95.0f/255.0f), objectColor.a);
}

View File

@ -31,7 +31,8 @@ glm::mat4 cameraMatrix, perspectiveMatrix;
glm::vec3 lightDir = glm::vec3(0.0f, 100.0f, 0.0f);
glm::quat rotation = glm::quat(1, 0, 0, 0);
glm::quat rotationX = glm::quat(1, 0, 0, 0);
glm::quat rotationY = glm::quat(1, 0, 0, 0);
std::vector<glm::vec3> planetsCoords;
std::vector<Bubble> bubbles;
@ -73,7 +74,9 @@ glm::mat4 createCameraMatrix()
mouseX = 0;
mouseY = 0;
cameraAngle = 0;
rotation = glm::normalize(rotationChange * rotation);
rotationX = glm::normalize(rotationChange * rotationX);
rotationY = glm::normalize(rotationChange * rotationY);
glm::quat rotation = rotationX * rotationY;
cameraDir = glm::inverse(rotation) * glm::vec3(0.0f, 0.0f, -1.0f);
cameraSide = glm::inverse(rotation) * glm::vec3(1.0f, 0.0f, 0.0f);
return Core::createViewMatrixQuat(cameraPos,rotation);
@ -136,7 +139,7 @@ void renderScene()
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glm::mat4 shipInitialTransformation = glm::translate(glm::vec3(0,-1.0f,-1.0f)) * glm::rotate(glm::radians(180.0f), glm::vec3(0,1,0)) * glm::scale(glm::vec3(0.25f));
glm::mat4 shipModelMatrix = glm::translate(cameraPos + cameraDir * 0.5f) * glm::mat4_cast(glm::inverse(rotation)) * shipInitialTransformation;
glm::mat4 shipModelMatrix = glm::translate(cameraPos + cameraDir * 0.5f) * glm::mat4_cast(glm::inverse(rotationX * rotationY)) * shipInitialTransformation;
drawObjectTexture(sharkModel, shipModelMatrix, sharkTexture);