Search code examples
opengltexturesdirectx-11directx-10

DirectX11 / OpenGL only renders half of the texture


enter image description here

This is how it should look like. It uses the same vertices/uv coordinates which are used for DX11 and OpenGL. This scene was rendered in DirectX10.

enter image description here

This is how it looks like in DirectX11 and OpenGL.

I don't know how this can happen. I am using for both DX10 and DX11 the same code on top and also they both handle things really similiar. Do you have an Idea what the problem may be and how to fix it? I can send code if needed.

enter image description here also using another texture.

enter image description here changed the transparent part of the texture to red.

Fragment Shader GLSL

    #version 330 core

in vec2 UV;
in vec3 Color;
uniform sampler2D Diffuse;


void main()
{

    //color = texture2D( Diffuse, UV ).rgb;
    gl_FragColor = texture2D( Diffuse, UV );
    //gl_FragColor = vec4(Color,1);
}

Vertex Shader GLSL

    #version 330 core

 layout(location = 0) in vec3 vertexPosition;
 layout(location = 1) in vec2 vertexUV;
 layout(location = 2) in vec3 vertexColor;
 layout(location = 3) in vec3 vertexNormal;

uniform mat4 Projection;
uniform mat4 View;
uniform mat4 World;

out vec2 UV;
out vec3 Color;

void main()
{

    mat4 MVP = Projection * View * World;
    gl_Position = MVP * vec4(vertexPosition,1);

    UV = vertexUV;

    Color = vertexColor;

}

Solution

  • I found the error.

    The reason is that I forgot to set the Texture SamplerState to Wrap/Repeat. It was set to clamp so the uv coordinates were maxed to 1.