Basic MSAA

This commit is contained in:
Nigel Barink 2022-10-16 20:57:11 +02:00
parent 94428d43c9
commit 4f4eb2f496
2 changed files with 6 additions and 13 deletions

View File

@ -19,7 +19,7 @@ const float diamond_ri = 2.42;
void main() void main()
{ {
// Regular shading // Regular shading
// texture( texture_diffuse1, TexCoords) ; FragColor = texture( texture_diffuse1, TexCoords) ;
// Reflective shading // Reflective shading
@ -32,9 +32,11 @@ void main()
// Refractive shading // Refractive shading
/*
float ratio = air_ri/water_ri; float ratio = air_ri/water_ri;
vec3 I = normalize(Position-cameraPos); vec3 I = normalize(Position-cameraPos);
vec3 R = refract(I, normalize(Normal), ratio); vec3 R = refract(I, normalize(Normal), ratio);
FragColor = vec4(texture(skybox, R).rgb, 1.0); FragColor = vec4(texture(skybox, R).rgb, 1.0);
*/
} }

View File

@ -143,6 +143,8 @@ GLFWwindow* CreateWindowWithOpenGLContext()
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// multisampling
glfwWindowHint(GLFW_SAMPLES, 4);
GLFWwindow* window = glfwCreateWindow(800, 600, "LearnOpenGL", NULL, NULL); GLFWwindow* window = glfwCreateWindow(800, 600, "LearnOpenGL", NULL, NULL);
if( window == NULL){ if( window == NULL){
@ -169,9 +171,6 @@ GLFWwindow* CreateWindowWithOpenGLContext()
void Skybox_pass (GLuint& SkyboxVAO, Shader& skyboxShader, Cubemap& skycubemap) void Skybox_pass (GLuint& SkyboxVAO, Shader& skyboxShader, Cubemap& skycubemap)
{ {
//glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
//glClear(GL_COLOR_BUFFER_BIT );
glDepthMask(GL_FALSE); glDepthMask(GL_FALSE);
skyboxShader.use(); skyboxShader.use();
@ -188,11 +187,6 @@ void Skybox_pass (GLuint& SkyboxVAO, Shader& skyboxShader, Cubemap& skycubemap)
void drawScene_pass(Shader& shader, Model& Object, Cubemap& skybox) void drawScene_pass(Shader& shader, Model& Object, Cubemap& skybox)
{ {
//glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
shader.use(); shader.use();
shader.setVec3("cameraPos", camera.Position); shader.setVec3("cameraPos", camera.Position);
@ -312,7 +306,6 @@ int main() {
skybox.loadCubeTextures(faces); skybox.loadCubeTextures(faces);
// Create ScreenVAO // Create ScreenVAO
#pragma region ScreenVAO
GLuint ScreenVAO, VBO; GLuint ScreenVAO, VBO;
glGenVertexArrays(1, &ScreenVAO); glGenVertexArrays(1, &ScreenVAO);
glBindVertexArray(ScreenVAO); glBindVertexArray(ScreenVAO);
@ -327,10 +320,7 @@ int main() {
glEnableVertexAttribArray(1); glEnableVertexAttribArray(1);
glVertexAttribPointer(1,2,GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*)(2*sizeof(float))); glVertexAttribPointer(1,2,GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*)(2*sizeof(float)));
glBindVertexArray(0); glBindVertexArray(0);
#pragma endregion ScreenVAO
// Create SkyboxVAO // Create SkyboxVAO
GLuint SkyboxVAO, SkyboxVBO; GLuint SkyboxVAO, SkyboxVBO;
@ -351,6 +341,7 @@ int main() {
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glEnable(GL_STENCIL_TEST); glEnable(GL_STENCIL_TEST);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
glEnable(GL_MULTISAMPLE);
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); //glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
while(!glfwWindowShouldClose(window)) while(!glfwWindowShouldClose(window))