Jump to content

Rendering to Custom Buffer for Post-Processing


nick.ace
 Share

Recommended Posts

[App.h]:

Buffer* mybuffer;
Buffer* mainbuffer;
Texture* mytexture;
Texture* mydepthtexture;

 

[App.cpp, App::Start after context = Context::Create(window);]

mainbuffer = Buffer::GetCurrent();
mybuffer = Buffer::Create(context->GetWidth(), context->GetHeight(), 2, 0);
mytexture = Texture::Create(context->GetWidth(), context->GetHeight(),Texture::RGBA,0,1,0);
mydepthtexture = Texture::Create(context->GetWidth(), context->GetHeight(), Texture::Depth, 0, 1, 0);
mytexture->SetFilter(Texture::Smooth);
mybuffer->SetColorTexture(foregroundtexture1);
mybuffer->SetDepthTexture(foregrounddepthtexture1);
mybuffer->Disable();

 

[when rendering (normally in App::Loop())]

world->Update();
Buffer::SetCurrent(mybuffer);
mybuffer->Enable();
world->Render();
mybuffer->Disable();
Buffer::SetCurrent(mainbuffer);

Link to comment
Share on other sites

Sorry, I think I need to reword my question. I'm trying to write to a custom buffer using a model fragment shader. I want to access this buffer using a post-process shader. Is there a way to do this? Right now the only way I can think of accomplishing this is to cram values into the depth/normal/diffuse buffers, but then that messes up other post-processing effects.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...