Welcome, Guest. Please login or register. Did you miss your activation email?

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.


Messages - artelius

Pages: [1]
1
Graphics / Re: RenderTexture.create() is slow
« on: March 04, 2016, 09:48:38 pm »
Thanks eXpl0it3r!

There are plenty of ways to achieve what I'm after; I'm just trying to do something conceptually simple because I'm planning to create a teaching tool based on SFML.

All I'm really trying to do is prepare a lot of textures for later use, using texture-to-texture copying, which I figure should be faster than CPU-based rendering.

2
Graphics / Re: CPU/Pixel based "Post processing"
« on: March 02, 2016, 10:19:05 am »
Hi! The GLSL may be easier than you think.

I created a little proof-of-concept for 4x upscaling. So a 4x4 block of screen pixels corresponds to 1 texture pixel. My code just does some smoothing in the y direction but it should be enough to give you an idea of how to do more sophisticated upscaling.

To get your head around it, you just need to understand that the main() function is called once for each pixel on screen (as if in a pair of for loops; although in reality they run in parallel), and the colour of that pixel is determined by what ends up in gl_FragColor.

Any questions, just ask.

Here is the shader code:

#version 130

uniform sampler2D texture;

void main () {

    //get window co-ordinates
    int window_x = int(gl_FragCoord.x); //varies from 0 to 799 (0,0 is bottom-left)
    int window_y = int(gl_FragCoord.y); //varies from 0 to 599

    //get the index into the texture corresponding to this pixel
    int tex_x = window_x / 4;
    int tex_y = window_y / 4;

    //figure out which "subpixel" this one is
    int xoff = window_x % 4;
    int yoff = window_y % 4;

    //get colour of corresponding texture pixel
    vec4 here = texelFetch(texture, ivec2(tex_x,tex_y), 0);
    //get colour of texture 1 pixel up
    vec4 up1 = texelFetch(texture, ivec2(tex_x,tex_y+1), 0);
    //get colour of texture 1 pixel down
    vec4 down1 = texelFetch(texture, ivec2(tex_x,tex_y-1), 0);
   
    if (yoff == 0) //mix with below colour
        gl_FragColor = (here + down1) / 2.0;
    else if (yoff == 3) //mix with above colour
        gl_FragColor = (here + up1) / 2.0;
    else  //mix them all!
        gl_FragColor = (2.0 * here + up1 + down1) / 4.0;

    //How the heck do you debug shaders??
    //You can't print stuff but you CAN colour pixels instead
    //try uncommenting the following to get an idea:
    //gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); //will make all pixels red
    //if (window_x >= 400 && window_x < 404)
    //    gl_FragColor = vec4(0.0, float(window_y)/600.0, 0.0, 1.0); //a bar ranging from black to green
}
 


Here a full example:

(click to show/hide)

3
Graphics / RenderTexture.create() is slow
« on: March 02, 2016, 02:57:46 am »
Hi,


RenderTexture.create() takes about 40ms on my machine, even for small textures (e.g. 16x16). Since I am creating a lot of these it is taking several seconds.

I'm just wondering if this is normal, or if it's once again an Intel HD Graphics problem.

I have tried this on SFML 2.1 and 2.3.2. Running Ubuntu 14.04.


Thanks!

Pages: [1]