Je souhaite redessiner une nouvelle frame avec des données de l'ancienne frame, mais ça ne fonctionne pas.

Code cpp : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
        const std::string transfFragVertexShader =
                        R"(#version 130
                        out mat4 newViewMatrix;
                        out mat4 projMat;
                        void main() {
                            gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
                            gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
                            gl_FrontColor = gl_Color;
                            newViewMatrix = gl_ModelViewMatrix;
                            projMat = gl_ProjectionMatrix;
                        })";
                        const std::string transfFragFragmentShader =
                        R"(#version 130
                        uniform mat4 oldViewMatrix;
                        in mat4 newViewMatrix;
                        in mat4 projMat;
                        uniform vec3 resolution;
                        uniform sampler2D oldFrameBuffer;
                        void main() {
                            vec4 oldFragPos = inverse(projMat) * gl_FragCoord;
                            oldFragPos /= oldFragPos.w;
                            oldFragPos = inverse(newViewMatrix) * oldViewMatrix * oldFragPos;
                            oldFragPos /= oldFragPos.w;
                            oldFragPos = oldFragPos * projMat;
                            vec2 position = (resolution.xy / oldFragPos.xy);
                            gl_FragColor = texture2D(oldFrameBuffer, position);
                        })";
 
    Edit / Delete Edit Post   Quick reply to this message Reply   Reply With Quote Reply With Quote   Multi-Quote This Message

Et peut importe la couleur que j'affecte à gl_FragColor ça ne m'affiche toujours rien.

Comment avoir les coordonnées vue du fragment pour le transformer en coordonnées vue de l'ancienne vue ?