GLSL

GLSL - C++ - Programmation

Marsh Posté le 15-12-2005 à 15:12:33    

Bonjour, je cherche a obtenir (en glsl) la couleur du pixel de fond (celui qui est dans le back buffer, celui qu'on swap)...
 
Quelqu'un a déja cherché a le faire ? Moi je trouve pas grand choses a ce sujet, meme si cela m'étonne que personne n'en ai jamais eu besoin....
 
Je vous remercie...

Reply

Marsh Posté le 15-12-2005 à 15:12:33   

Reply

Marsh Posté le 16-12-2005 à 18:39:01    

Ce serait effectivement trés utile mais ce n'est pas accessible, pour être plus précis la fonctionnalité a été envisagée mais n'a pas été retenue comme l'indique la spec du GLSL :
 

Citation :

7) Is alpha blending programmable?
Fragment shaders can read the contents of the frame buffer at the current location using the built-in
variables gl_FBColor, gl_FBDepth, gl_FBStencil, and gl_FBDatan. Using these facilities,
applications can implement custom algorithms for blending, stencil testing, and the like. However,
these frame buffer read operations may result in a significant reduction in performance, so
applications are strongly encouraged to use the fixed functionality of OpenGL for these operations if
at all possible. The hardware to implement fragment shaders (and vertex shaders) is made a lot
simpler and faster if each fragment can be processed independently both in space and in time. By
allowing read-modify-write operations such as is needed with alpha blending to be done as part of the
fragment processing we have introduced both spatial and temporal relationships. These complicate
the design because of the extremely deep pipelining, caching and memory arbitration necessary for
performance. Methods such as render to texture, copy frame buffer to texture, aux data buffers and
accumulation buffers can do most, if not all, what programmable alpha blending can do. Also the
need for multiple passes has been reduced (or at least abstracted) by the high-level shading language
and the automatic resource management.
RESOLVED on October 12, 2001: Yes, applications can do alpha blending, albeit with possible
performance penalties over using the fixed functionality blending operations.
REOPENED on July 9, 2002: This issue is related to Issue (23) which remains open, so this issue
should also remain open.
Another possibility would be to create an extension that allows more flexibility than the current alpha
blending allows, but would still be considered fixed functionality.
RESOLUTION: Issue 23) is resolved as allowing frame buffer reads, so this is once again resolved
allowing alpha blending, with the caveats listed above.
REOPENED on December 10, 2002. Issue 23 is re-resolved to disallow frame buffer reads.
RESOLUTION: No, applications cannot do alpha blending, because they cannot read alpha.
CLOSED on December 10, 2002.
 
23) Should the fragment shader be allowed to read the current location in the frame buffer?
DISCUSSION: It may be difficult to specify this properly while taking into account multisampling. It
also may be quite difficult for hardware implementors to implement this capability, at least with
reasonable performance. But this was one of the top two requested items after the original release of
the shading language white paper. ISVs continue to tell us that they need this capability, and that it
must be high performance.
RESOLUTION: Yes. This is allowed, with strong cautions as to performance impacts.
REOPENED on December 10, 2002. There is too much concern about impact to performance and
impracticallity of implementation.
CLOSED on December 10, 2002.


 
La seule façon de faire ce que tu souhaites c'est de faire copier ton rendu dans une texture que tu donnes en entrée à ton fragment shader, c'est la technique que j'emploie, l'impact sur les performances est raisonnable si tu n'en abuses pas.

Reply

Marsh Posté le 19-12-2005 à 12:16:14    

Je te remercie !!  
 
Dans ton cas, tu utilise quels fonction afin de perdre une minimum de performance ? glCopyTexImage2D ?


Message édité par dickymoe le 19-12-2005 à 12:16:30
Reply

Marsh Posté le 19-12-2005 à 14:39:53    

Oui c'est exactement ce que j'utilise, glCopyTexSubImage2D est sensé être plus rapide mais je n'ai pas fait de tests vu que les performances actuelles me convenaient

Reply

Marsh Posté le 19-12-2005 à 14:53:28    

Ok merci !!
 
Je suis entrain de faire mes tests mais j'ai encore d'autre problèmes lier a GLSL... Mais je vais me débrouiller !!
 
Merci de tes éclairssissements !!

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed