Problem with blending (day/night cycle)

Hello. I’m sorry for my bad English, I’ll do my best :slight_smile:

I’m doing a Opengl project for an exam. The actual status of the project is (this). As you can see there is a Skybox with clouds that changes (blend between two different skybox). And there is a directional light too, that represent the sun that changes direction (day/night) and changes the color of the scene (from light to darkness).

Now, the problem is that i’ve only the light. I need to insert the image (texture) of both (sun and moon) in the sky and make a day/night cycle.

The idea is to use a set of layers:

  • clouds.
  • sun/moon.
  • skybox.

.

For do that i’m trying to insert images with alpha channel and I’m trying to use masks. For do that I’m following this tutorial. But I have a problem with the image result. I’m trying to insert the same image (grass) of the guide as test, but I get this result:

Can someone help me to understand what is the problem?

Vertex shader

#version 330 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec2 aTexCoords;

out vec2 TexCoords;

uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;

void main()
{
    TexCoords = aTexCoords;
    gl_Position = projection * view * model * vec4(aPos, 1.0);
}

Fragment shader

#version 330 core
out vec4 FragColor;

in vec2 TexCoords;

uniform sampler2D texture_diffuse1;

void main()
{             
    vec4 texColor = texture(texture_diffuse1, TexCoords);
    	
    FragColor = texColor;
}

I made a quad in blender with the texture with alpha channel:

To insert the image I do the following things:

  1. Load the model. Using “.mtl” file it loads the texture too.

    V2::Model grassModel("../models/grass.obj");

  2. In the rendering phase I active the shader (use it), I load the uniforms needed, model, view, projection matrix, and finally draw.

    //Change shader
     	current_program = BLENDING;
    
     // We "install" the selected Shader Program as part of the current rendering process.
     shaders[current_program].Use();
    
     // vegetation
     //glActiveTexture(GL_TEXTURE0);
     //glBindTexture(GL_TEXTURE_2D, textureID[1]);
    
     glUniformMatrix4fv(glGetUniformLocation(shaders[current_program].Program, "projection"), 1, GL_FALSE, glm::value_ptr(projection));
     glUniformMatrix4fv(glGetUniformLocation(shaders[current_program].Program, "view"), 1, GL_FALSE, glm::value_ptr(view));
    
     glUniform1i(glGetUniformLocation(shaders[current_program].Program, "texture_diffuse1"), 0);
    
     glm::mat4 grassModel = glm::mat4(1.0f);
     grassModel = glm::translate(grassModel, glm::vec3(0.0f, 5.0f, 0.0f));
     grassModel = glm::rotate(grassModel, glm::radians(-90.0f), glm::vec3(1.0f, 1.0f, 0.0f));
     grassModel = glm::scale(grassModel, glm::vec3(5.0f, 5.0f, 5.0f));
    
     glUniformMatrix4fv(glGetUniformLocation(shaders[current_program].Program, "model"), 1, GL_FALSE, glm::value_ptr(grassModel));
    
     models[4].Draw(shaders[current_program]);
    

Can you help me to understand why I get this result? Thank you