frag
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 g_Resolution;
uniform float g_Time;
void main() {
vec2 st = gl_FragCoord.xy/g_Resolution;
gl_FragColor = vec4(st.x,st.y,0.0,1.0);
}
vec2 st = gl_FragCoord.xy/g_Resolution;
I guess my use of screen coordinates caused the box to display different colors in different views.
How do I pass UV coordinates to “st”?
Modify:
The above problems were solved but I was confused by the code that solved them
//the global uniform World view projection matrix
//(more on global uniforms below)
uniform mat4 g_WorldViewProjectionMatrix;
//The attribute inPosition is the Object space position of the vertex
attribute vec3 inPosition;
attribute vec2 inTexCoord;
varying vec2 texCoord1;
void main(){
texCoord1=inTexCoord;
//Transformation of the object space coordinate to projection space
//coordinates.
//- gl_Position is the standard GLSL variable holding projection space
//position. It must be filled in the vertex shader
//- To convert position we multiply the worldViewProjectionMatrix by
//by the position vector.
//The multiplication must be done in this order.
gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition, 1);
}
This is the vertex shader
attribute vec2 inTexCoord;
This definition is known from literature that model UV coordinates are transferred by inTexCoord Assign inTexCoord to the texCoord1 fragment shader using texCoord1 coordinates.
I don’t know if I got that right.
I was also confused about the role of attribute and varying and didn’t understand what they did. I only found some code from Google that didn’t explain the role of these two keywords
Where can I find information on how JME passes vertex parameters to shaders? Such as passing model UV coordinates