@Subgression wrote:
Hello to everyone.
I'm currently trying to display a simple texture (grabbed from an ofVideoPlayer) and applaying into a rectangle using a GLSL shader, the main problem is the texture appears to be monochrome, i can only see various shades of grey and not the whole texture, am i missing something? i'm really a beginner in GLSL programming, perhaps someone could help me.Here's the main code:
void draw() {
ofSetColor(ofColor::white);
shader.begin();
shader.setUniformTexture("tex", videoPlayer.getTexture(), 0);
ofDrawRectangle(0, 0, ofGetWidth(), ofGetHeight());
shader.end();
};the vertex shader:
uniform mat4 modelViewProjectionMatrix;in vec4 position;
in vec2 texcoord;
out vec2 texCoordVarying;void main()
{
texCoordVarying = texcoord;
gl_Position = modelViewProjectionMatrix * position;
}and the fragment shader:
uniform sampler2DRect tex;in vec2 texCoordVarying;
out vec4 outputColor;
void main()
{
vec3 rgb = texture(tex, texCoordVarying.xy).rgb;
outputColor = vec4(rgb, 1.0f);
}
Posts: 7
Participants: 4