I’ve got a texture cubemap that I sample using reflection direction. The skybox has 11 miplevels.
#version 460 core
layout(location = 0) out vec4 f_color;
layout(location = 0) in vec3 v_worldPosition;
layout(location = 1) in vec3 v_normal;
layout(std140, binding = 0) uniform Camera
{
mat4 cameraModel;
};
layout(binding = 1) uniform samplerCube u_skybox;
void main()
{
vec3 viewDirection = normalize(cameraModel[3].xyz - v_worldPosition);
vec3 reflectionDirection = reflect(-viewDirection, v_normal);
vec3 color = textureLod(u_skybox, reflectionDirection, 10.0f).rgb;
f_color = vec4(color, 1.0f);
}
now it looks like this:
I’d expect it to look like this:
The correct result was produced using DX11, incorrect using OpenGL.
I’ve checked
cameraModel[3].xyz
viewDirection
reflectionDirection
in both applications (output as pixel color) and the result is the same, thus I guess it’s not problem here.
code that creates the texture:
GLuint sampler;
glCreateSamplers(1, &sampler);
glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glSamplerParameteri(sampler, GL_TEXTURE_WRAP_S, GL_REPEAT);
glSamplerParameteri(sampler, GL_TEXTURE_WRAP_T, GL_REPEAT);
glSamplerParameteri(sampler, GL_TEXTURE_WRAP_R, GL_REPEAT);
GLuint texture;
glCreateTextures(GL_TEXTURE_CUBE_MAP, 1, &texture);
glTextureStorage2D(texture, 11, GL_RGBA32F, 1024, 1024);
and the first frame executes a compute shader that writes into this texture cubemap.
How can I fix this? Why does it work like this? What do I do wrong?