1
Graphics / CPU/Pixel based "Post processing"
« on: February 21, 2016, 07:18:28 pm »
I wonder if there's a more performant way of doing this:
Full code:
I am drawing everything to a RenderTexture, then I retrieve a copy of the underlying texture as an Image.
Then I manipulate the image (e.g. do xBRZ scaling) and render the result to the screen.
Rendering resolution will be around 660x360px.
The pixel manipulation will be done using the Uint8 array, not with setPixel.
And yes, I am not able to create the GLSL shader to do the resizing ... lack of knowledge atm
//Draw everything
renderTex.clear(sf::Color(200,200,200));
renderTex.draw(shape);
renderTex.display();
//Do "Post-Processing"
window.clear();
sf::Image img = renderTex.getTexture().copyToImage();
//Manipulate the pixels in any way, this is just an example
for(unsigned int i=0; i < img.getSize().x; i+=8)
{
for(unsigned int j=0; j < img.getSize().y; j++)
{
img.setPixel(i,j,sf::Color::White);
}
}
//Draw result
postTexture.loadFromImage(img);
sf::Sprite sprite(postTexture);
window.draw(sprite);
window.display();
renderTex.clear(sf::Color(200,200,200));
renderTex.draw(shape);
renderTex.display();
//Do "Post-Processing"
window.clear();
sf::Image img = renderTex.getTexture().copyToImage();
//Manipulate the pixels in any way, this is just an example
for(unsigned int i=0; i < img.getSize().x; i+=8)
{
for(unsigned int j=0; j < img.getSize().y; j++)
{
img.setPixel(i,j,sf::Color::White);
}
}
//Draw result
postTexture.loadFromImage(img);
sf::Sprite sprite(postTexture);
window.draw(sprite);
window.display();
Full code:
(click to show/hide)
I am drawing everything to a RenderTexture, then I retrieve a copy of the underlying texture as an Image.
Then I manipulate the image (e.g. do xBRZ scaling) and render the result to the screen.
Rendering resolution will be around 660x360px.
The pixel manipulation will be done using the Uint8 array, not with setPixel.
And yes, I am not able to create the GLSL shader to do the resizing ... lack of knowledge atm