Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void initDeferred(){
- batch = new Batch;
- batch.begin(4, GL_TRIANGLE_FAN);
- batch.add([-1, 1, 0]);
- batch.add([-1, -1, 0]);
- batch.add([1, -1, 0]);
- batch.add([1, 1, 0]);
- batch.finish();
- width = 512;
- height = 512;
- gbuffer = new GBuffer(width, height);
- string vertex = "
- #version 330
- in vec4 vertex;
- void main(){
- gl_Position = vertex;
- }
- ";
- string fragment = "
- #version 330
- out vec3 outDiffuse;
- void main(){
- outDiffuse = vec3(1,1,1);
- }
- ";
- geomPassShader = Shader.prepare("gbuffer_forwarder");
- geomPassShader.start("gbuffer_forwarder", vertex, fragment);
- geomPassShader.addAttribute(gl.attributeVertex, "vertex");
- geomPassShader.bindFragOut(GBuffer.DIFFUSE, "outDiffuse");
- geomPassShader.finish;
- }
- void geomPass(){
- gbuffer.bindWrite;
- glViewport(0,0,width,height);
- float[3] green = [0, 1, 0];
- float one = 1;
- glClearBufferfv(GL_COLOR, 0, green.ptr);
- glClearBufferfv(GL_DEPTH, 0, &one);
- geomPassShader.use;
- batch.draw;
- }
- void lightPass(){
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
- gbuffer.bindRead();
- gbuffer.setRead(GBuffer.DIFFUSE);
- glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement