Texture not rendering on whole blender-exported object

#1

Hi
Ok so, I made a model in Blender. In particular, it’s a grid (513x513), with a heightmap attached to it (using the displace modifier). In the UV editor, I opened a texture for the terrain, then I unwrapped the model using "Project from view (bounds). So the model showed up with the texture and everything, and everything was perfect as I wanted. Here is how it looks like:


Then, I exported it as an OBJ file, so that I could play with it with my opengl java project.
I made sure to check these options: include UVs, write modifiers
And now I’m in Eclipse. I implemented the code to open this terrain, and it’s just… wrong.
If I use a random texture, like “grass”, it renders fine:


but if I use the actual texture, that texture covers only a part of the model instead of everything ->

There is some sort of black border that shows how big the model is (i didn’t do that btw), but the texture covers only that small part. I tried reinporting it in blender, and it works fine there.

Vertex Shader:

#version 400 core

in vec3 position;
in vec2 textureCoords;
in vec3 normal;

out vec2 pass_textureCoords;
out vec3 surfaceNormal;
out vec3 toLightVector;
out vec3 toCamVector;
out float visibility;

uniform mat4 transformationMatrix;
uniform mat4 projectionMatrix;
uniform mat4 viewMatrix;
uniform vec3 lightPosition;

uniform float useFakeLighting;

uniform float density;
uniform float gradient;

void main(void){

	vec4 worldPosition = transformationMatrix*vec4(position,1.0);
	vec4 toCamPosition = viewMatrix*worldPosition;
	gl_Position = projectionMatrix*toCamPosition;
	pass_textureCoords = textureCoords;
	
	vec3 actualNormal = normal;
	if(useFakeLighting > 0.5){
		actualNormal = vec3(0.0,1.0,0.0);
	}
	
	surfaceNormal = (transformationMatrix*vec4(actualNormal, 0.0)).xyz;
	toLightVector = lightPosition - worldPosition.xyz;
	toCamVector = (inverse(viewMatrix)*vec4(0.0,0.0,0.0,1.0)).xyz - worldPosition.xyz;
	
	float distance = length(toCamPosition.xyz);
	visibility = exp(-pow((distance*density),gradient));
	visibility = clamp(visibility,0.0,1.0);
	
	
}

Fragment Shader:

#version 400 core

in vec2 pass_textureCoords;
in vec3 surfaceNormal;
in vec3 toLightVector;
in vec3 toCamVector;
in float visibility;

out vec4 out_colour;

uniform sampler2D textureSampler;
uniform vec3 lightColor;
uniform float shineDamper;
uniform float reflectivity;
uniform vec3 skyColor;

void main(void){
	
	vec3 unitNormal = normalize(surfaceNormal);
	vec3 unitLightVector = normalize(toLightVector);

	float nDot1 = dot(unitNormal, unitLightVector);
	float brightness = max(nDot1,0.2);
	vec3 diffuse = brightness*lightColor;
		
	vec3 unitCamVector = normalize(toCamVector);
	vec3 lightDirection = -unitLightVector;
	vec3 reflectedLightDirection = reflect(lightDirection,unitNormal);
	
	float specularFactor = dot(reflectedLightDirection, unitCamVector);
	specularFactor = max(specularFactor,0.0);
	float dampedFactor = pow(specularFactor,shineDamper);
	vec3 finalSpecular = dampedFactor*lightColor;
	
	vec4 textureColor = texture(textureSampler,pass_textureCoords);
	if(textureColor.a<0.5){
		discard;
	}
	out_colour = vec4(diffuse,0.0)*textureColor+vec4(finalSpecular,1.0)*0;
	//out_colour = mix(vec4(skyColor,1.0),out_colour,visibility);
}