cherdd
September 28, 2014, 8:44am
#1
Hi all,
I have a simple masking shader that works on OSX, but doesn’t seem to compile with VS2012 on Windows 8.
I’m not very experienced with shaders and Windows so I was hoping to be able get some help with this?
Here’s my shader code in the frag file:
uniform sampler2DRect mask;
uniform sampler2DRect image;
void main() {
vec4 coords = gl_TexCoords[0];
vec4 mask_pixel = texture2DRect(mask, coords.xy);
vec4 image_pixel = texture2DRect(image, coords.xy);
vec4 color = vec4(image_pixel.r, image_pixel.g, image_pixel.b, mask_pixel.r);
gl_FragColor = color;
}
and heres the vert file:
uniform float limit;
void main() {
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
}
Thanks in advance!
cherd
cherdd
September 28, 2014, 11:32am
#2
It seems that it’s something to do with incompatible lines? I’m digging deeper…
I get similar errors when trying to load the shaders in the shader tutorials that accompany the OF repo on github. Perhaps its a Windows 8 issue.
Any help will be greatly appreciated!
Hey mate, Can you post the errors you get?
cherdd
September 29, 2014, 11:31am
#4
Heya Dave!
Forum was down this evening from here so couldn’t reply.
Managed to get it fixed with the help of @trentbrooks !
It seems I needed some extensions enabled, and that some of the classes used were of older versions. Here’s the working shader:
#version 120
#extension GL_ARB_texture_rectangle : enable
uniform sampler2DRect mask;
uniform sampler2DRect image;
varying vec2 texCoordVarying;
void main() {
vec4 mask_pixel = texture2DRect(mask, texCoordVarying);
vec4 image_pixel = texture2DRect(image, texCoordVarying);
vec4 color = vec4(image_pixel.r, image_pixel.g, image_pixel.b, mask_pixel.r);
gl_FragColor = color;
}
and the vert file:
#version 120
uniform float limit;
varying vec2 texCoordVarying;
void main() {
texCoordVarying = gl_MultiTexCoord0.xy;
gl_Position = ftransform();
}
Thanks for checking in though… hope the fam is doing well.