I’m trying to build a simple rasterizer using C# and OpenTK. Most of my stuff is working, but when attempting to implement a skybox feature I got lost. I followed the tutorial at https://learnopengl.com/Advanced-OpenGL/Cubemaps, but I figure something went wrong in translating the C++ glfw to C# OpenTK.
My relevant render code:
public void Render(Camera cam)
{
GL.DepthMask(false);
GL.UseProgram(SkyboxShader.ProgramID);
var camview = new Matrix4(new Matrix3(cam.GetPositionMatrix()));
var camproj = cam.GetFOVMatrix();
GL.UniformMatrix4(SkyboxShader.UniformMatrixView, false, ref camview);
GL.UniformMatrix4(SkyboxShader.UniformMatrixProjection, false, ref camproj);
GL.BindVertexArray(SkyboxVAO);
GL.ActiveTexture(TextureUnit.Texture11);
GL.BindTexture(TextureTarget.TextureCubeMap, CubeMap.ID);
GL.Uniform1(GL.GetUniformLocation(SkyboxShader.ProgramID, "skyboxCubeMap"), 11);
GL.DrawArrays(PrimitiveType.Triangles, 0, 36);
GL.DepthMask(true);
GL.UseProgram(0);
}
My vertex and fragment shader are as following:
#version 330 core
layout (location = 0) in vec3 aPos;
out vec3 TexCoord;
uniform mat4 projection;
uniform mat4 view;
void main()
{
TexCoord = vec3(0.5, 0.5, 1.0);
vec4 pis = projection * view * vec4(aPos, 1.0);
gl_Position = pis.xyww;
}
#version 330 core
out vec4 FragColor;
in vec3 TexCoord;
uniform samplerCube skyboxCubeMap;
void main()
{
FragColor = texture(skyboxCubeMap, TexCoord);
}
Am I just missing some small detail?
I already checked if my image loading was correct (yes, the pixel array is filled with values), my render method was actually called (yes) and if there were any GL errors (no). I’m pretty lost on what to look for.