Salut, j'essaye d'effecture du multi-pass rendering à l'aide de shaders et de texture mais c'est assez lent, bref, voici le code source de mes "fragment shaders" :
Sinon j'ai tout optimisé là ou je pouvais : rendu VBO en prétransformant les entités dynamique pour update leur position dans leur vbo, j'ai aussi regroupé tout les tableau de sommets utilisant la même texture ensemble pour éviter de devoir faire trop d'appels à glBind, etc...
Code : 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
31
32
33 const std::string depthGenFragShader = "uniform sampler2D depthBuffer;" "uniform sampler2D texture;" "uniform vec3 resolution;" "void main () {" "vec2 position = ( gl_FragCoord.xy / resolution.xy );" "vec4 color = texture2D(depthBuffer, position);" "vec4 pixel = texture2D(texture, gl_TexCoord[0].xy);" "if (gl_FragCoord.z >= color.z && pixel.a >= color.a) {" "gl_FragColor = vec4(0, 0,gl_FragCoord.z, pixel.a);" "} else {" "gl_FragColor = color;" "}" "}"; const std::string frameBufferGenFragShader = "uniform sampler2D depthBuffer;" "uniform sampler2D frameBuffer;" "uniform sampler2D texture;" "uniform vec3 resolution;" "void main () { " "vec2 position = ( gl_FragCoord.xy / resolution.xy );" "vec4 depth = texture2D(depthBuffer, position);" "vec4 color = texture2D(frameBuffer, position);" "vec4 pixel = texture2D(texture, gl_TexCoord[0].xy);" "if (gl_FragCoord.z > depth.z) {" "gl_FragColor = pixel;" "} else if (color.a < pixel.a) {" "gl_FragColor = pixel;" "} else {" "gl_FragColor = color;" "}" "}";
Et sans le shader mon rendu est rapide donc...
Partager