Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - SonicBurst

#1
Hi  Jpct Community,

     Recently I was fiddling with Jpct's renderToTexture... and I wanted to do some Sobel filter to a texture for edge detection for a nice toony effect.
So I did this->

                fb.setRenderTarget(targetTexture);
fb.setBlittingShader(shader);
fb.clear(RGBColor.BLUE);
world.renderScene(fb);
world.draw(fb);
fb.display();
fb.removeRenderTarget();


fb.blit(targetTexture, srcX, srcY, destX, destY, sourceWidth, sourceHeight, destWidth, destHeight, -1, false);

blitNumber(lfps, 5, 5);
fb.display();


and this is the fragment shader I intend to apply on the texture->
(copied from internet) ->

in vec2 TexCoords;
out vec4 color;

uniform sampler2D screenTexture;

mat3 sx = mat3(
    1.0, 2.0, 1.0,
    0.0, 0.0, 0.0,
   -1.0, -2.0, -1.0
);
mat3 sy = mat3(
    1.0, 0.0, -1.0,
    2.0, 0.0, -2.0,
    1.0, 0.0, -1.0
);

void main()
{
   vec3 diffuse = texture(screenTexture, TexCoords.st).rgb;
    mat3 I;
    for (int i=0; i<3; i++) {
        for (int j=0; j<3; j++) {
            vec3 sample  = texelFetch(screenTexture, ivec2(gl_FragCoord) + ivec2(i-1,j-1), 0 ).rgb;
           I[i][j] = length(sample);
    }
}

float gx = dot(sx[0], I[0]) + dot(sx[1], I[1]) + dot(sx[2], I[2]);
float gy = dot(sy[0], I[0]) + dot(sy[1], I[1]) + dot(sy[2], I[2]);

float g = sqrt(pow(gx, 2.0)+pow(gy, 2.0));
color = vec4(diffuse - vec3(g), 1.0);
}



     I guess that we dont have that "texelFetch()" in opengles 2.0  . So do we have any alternate for this?
Or any pointer to a different approach ?
     I am new to 3d programming and trying to experiment with different concepts . I would like to make a 3d game for android,
I found Jpct-ae and I loved its simplicity :)