Seems to be set up as a post shader (is looking into a prerendered sceneTex for the color info), are you providing it with a rendertex of the scene?
Also, are the threshold values and offsets set with SetShaderConstantByName?
If you want to skip all the post shenanigans and just use it as a simple object shader that takes the diffuse texture, applies stock lighting and then quickly crosshatches it, you can try something like this: (just a few changes needed)
I hardcoded the thresholds for simplicity, so that it works with any AppGameKit project, you can ofcourse put those back into uniforms and then set them from your AppGameKit code.
vs
attribute vec3 position;
attribute mediump vec3 normal;
attribute mediump vec2 uv;
varying vec2 uv0Varying;
varying vec3 posVarying;
varying vec3 normalVarying;
uniform mediump vec4 uvBounds0;
uniform mat4 agk_WorldViewProj;
uniform mat4 agk_World;
uniform mat4 agk_ViewProj;
uniform mat3 agk_WorldNormal;
void main(){
vec4 pos = agk_World * vec4(position,1);
gl_Position = agk_ViewProj * pos;
normalVarying = agk_WorldNormal * normal;
posVarying = pos.xyz;
uv0Varying = uv * uvBounds0.xy + uvBounds0.zw;
}
ps
#ifdef GL_ES
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
#endif
uniform sampler2D texture0; // D
varying vec2 uv0Varying;
varying vec3 normalVarying;
varying vec3 posVarying;
mediump vec3 GetPSLighting( mediump vec3 normal, highp vec3 pos );
void main() {
vec3 norm = normalize(normalVarying);
vec3 albedo = texture2D(texture0, uv0Varying).rgb;
vec3 diff = GetPSLighting( norm, posVarying );
vec3 amb = vec3(0.1,0.14,0.16);
vec3 col = albedo*(diff+amb);
vec3 tc = vec3(1.0, 0.0, 0.0);
float lum = length(col);
tc = vec3(1.0, 1.0, 1.0);
if (lum < 1.0) {
if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
}
if (lum < 0.7) {
if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
}
if (lum < 0.5) {
if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
}
if (lum < 0.3) {
if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
}
gl_FragColor = vec4(tc, 1.0);
}
Works fine on loaded models, just need to add a stock AppGameKit light. Test-screenshot attached.
You can prolly get more performance out of it if you convert it to not use so many conditionals, but then again, it runs pretty fast as it is.