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

Author Topic: Question with shaders :  (Read 1454 times)

0 Members and 1 Guest are viewing this topic.

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Question with shaders :
« on: February 28, 2014, 06:03:30 pm »
Hi, I would like to retrieve the alpha component of the previous pixel in a fragment shader by setting the alpha blending on GL_DST_ALPHA like it's say it in this link :
http://www.developpez.net/forums/d1155703/applications/developpement-2d-3d-jeux/api-graphiques/opengl/glsl-pixel-precedent-fragment-shader/

But I don't know how to proceed. :/

When I've set the blending function to GL_DST_ALPHA, how can I retrieve the alpha value of the previous pixel in the fragment shader ?


Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: Question with shaders :
« Reply #1 on: February 28, 2014, 09:27:02 pm »
Aparrently we have to use a texture, so, I have to do a renderTexture and draw on the texture everytime that I want to draw something on the window and pass the render texture to the shader.

Is it possible to pass a rendertexture to a shader with SFML ???

(Or in more appropriate term, an fbo)



« Last Edit: February 28, 2014, 09:31:47 pm by Lolilolight »

G.

  • Hero Member
  • *****
  • Posts: 1592
    • View Profile

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: Question with shaders :
« Reply #3 on: February 28, 2014, 10:37:24 pm »
Ha ok it's like a simple texture. ^^

Now I've still to know how will I do that because I've to keep all the z positions of the pixels of the rendered texture, it seems to be too complicate to do..., I think I'll try to understand how the alpha's blending work, there is certainly an easier way to do that if I want to compare the alpha and the z of the current texture's pixel with the pixel which is already drawn on the screen.


Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: Question with shaders :
« Reply #4 on: March 01, 2014, 01:51:57 pm »
There is aparrently no way to do this without using a texture..., because it seems we can't read the depth buffer value and the current pixel color value in the fragment shader.

So, I think that using a shader rather than z sorting'll not improve the performance. (I'll always have to call the draw function so often)

But maybe I'm wrong...







 

anything