I want to resize my texture. I am using cubemap to compute reflection. I want to use this cubemap to draw skybox. Skybox is drawn but I want to resize texture down, because it is dilated. As I wrote in my previous question (question), to draw skybox I use shaders:
//vertex shader
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
attribute vec4 position;
varying mediump vec4 texCoord;
void main() {
texCoord = position;
gl_Position = projectionMatrix * modelViewMatrix * position;
}
//fragment shader
uniform samplerCube Sampler;
varying mediump vec4 texCoord;
void main() {
mediump vec3 cube = vec3(textureCube(Sampler, texCoord.xyz));
gl_FragColor = vec4(cube, 1.0);
}
I send this data:
float vertices[24] = {
-1.0, -1.0, 1.0,
1.0, -1.0, 1.0,
-1.0, 1.0, 1.0,
1.0, 1.0, 1.0,
-1.0, -1.0, -1.0,
1.0, -1.0, -1.0,
-1.0, 1.0, -1.0,
1.0, 1.0, -1.0,
};
In this order to draw cube:
GLubyte indices[14] = {0, 1, 2, 3, 7, 1, 5, 4, 7, 6, 2, 4, 0, 1};
I think, that main problem is in the vertex shader, where I use vertex data as texture coord. But I have no idea how to map vertexes to cube map texture coordinates. Can you help me? Thanks
Edit: It is strange, but when I multiply modelviewMatrix with projectionMatrix it does not work. Now my code is:
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
uniform mat3 normalMatrix;
attribute vec4 position;
varying mediump vec3 texCoord;
void main() {
gl_Position = projectionMatrix * modelViewMatrix * position;
texCoord = normalMatrix * (gl_Position.xyz);
}
I have attached the screenshot, it looks quite good. Maybe it is distorted, because of the aspect ratio: