Hi!

I want to add diffuse color texture to my object in GLSL shader code.

```
import bge
cont = bge.logic.getCurrentController()
VertexShader = """
uniform mat4 viewMatrix; // world to view transformation
uniform mat4 viewMatrixInverse;
// view to world transformation
varying vec3 viewDirection; // direction in world space
// in which the viewer is looking
varying vec3 normalDirection; // normal vector in world space
varying vec3 normal;
varying vec3 view;
void main()
{
vec4 positionInViewSpace = gl_ModelViewMatrix * gl_Vertex;
// transformation of gl_Vertex from object coordinates
// to view coordinates
vec4 viewDirectionInViewSpace = positionInViewSpace
- vec4(0.0, 0.0, 0.0, 1.0);
// camera is always at (0,0,0,1) in view coordinates;
// this is the direction in which the viewer is looking
// (not the direction to the viewer)
viewDirection =
vec3(viewMatrixInverse * viewDirectionInViewSpace);
// transformation from view coordinates
// to world coordinates
vec3 normalDirectionInViewSpace =
gl_NormalMatrix * gl_Normal;
// transformation of gl_Normal from object coordinates
// to view coordinates
normalDirection = normalize(vec3(
vec4(normalDirectionInViewSpace, 0.0) * viewMatrix));
// transformation of normal vector from view coordinates
// to world coordinates with the transposed
// (multiplication of the vector from the left) of
// the inverse of viewMatrixInverse, which is viewMatrix
normal = normalize(gl_NormalMatrix * gl_Normal);
view = -normalize(vec3(gl_ModelViewMatrix * gl_Vertex));
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
"""
FragmentShader = """
varying vec3 viewDirection;
varying vec3 normalDirection;
varying vec3 normal;
varying vec3 view;
uniform samplerCube cubeMap;
void main()
{
float fP = 0.5;
float metallic = 0.0;
vec3 reflectedDirection = reflect(viewDirection, normalize(normalDirection));
vec4 color = vec4(0.0, 0.5, 0.5, 1.0);
float fresnel = dot(view, normal);
float fresnelPower = pow(fresnel, fP);
vec3 specularColor = textureCube(cubeMap, vec3(reflectedDirection.x, -reflectedDirection.z, reflectedDirection.y));
vec4 specular = vec4(specularColor.xyz, 1.0);
gl_FragColor = mix(specular, mix(color + (specular * 0.04), specular, metallic), fresnelPower);
}
"""
mesh = cont.owner.meshes[0]
for mat in mesh.materials:
shader = mat.getShader()
if shader != None:
if not shader.isValid():
shader.setSource(VertexShader, FragmentShader, 1)
shader.setSampler('cubeMap', 0)
viewMatrix = bge.logic.getCurrentScene().active_camera.world_to_camera
shader.setUniformMatrix4('viewMatrix', viewMatrix)
viewMatrixInverse = bge.logic.getCurrentScene().active_camera.camera_to_world
shader.setUniformMatrix4('viewMatrixInverse', viewMatrixInverse)
```

In the code you can see ‘color’ variable(vec4) that needs to be replaced with a texture in slot 1(not slot 0 as 0 is cubemap). How can I do it? It should use UVs as coordinates.