[SOLVED] GrayScale Filter

Yeah you have to make your shader support multisampling.

All core filters have 2 versions : classic and a glsl 1.5 version that supports multisampling.



you should have a grayScale15.frag that does it.

this should work.

[java]

#import "Common/ShaderLib/MultiSample.glsllib"



uniform COLORTEXTURE m_Texture;



in vec2 texCoord;

out vec4 fragColor;



void main() {



// Convert to grayscale

vec3 colour = getColor(m_Texture, texCoord).xyz;

float gray = (colour.x + colour.y + colour.z) / 3.0;

vec3 grayscale = vec3(gray);



fragColor = vec4(grayscale, 1.0);

}

[/java]



also your j3md should look like that

[java]

MaterialDef GrayScale {



MaterialParameters {

Int NumSamples

Texture2D Texture

}



Technique {

VertexShader GLSL150: Common/MatDefs/Post/Post15.vert

FragmentShader GLSL150: Common/MatDefs/Post/GrayScale15.frag



WorldParameters {

WorldViewProjectionMatrix

}



Defines {

RESOLVE_MS : NumSamples

}

}



Technique {

VertexShader GLSL100: Common/MatDefs/Post/Post.vert

FragmentShader GLSL100: Common/MatDefs/Post/GrayScale.frag



WorldParameters {

WorldViewProjectionMatrix

}

}

}

[/java]

2 Likes