Jump to content

Recommended Posts

Posted

Hi,

 

is it possible to use the depthbuffer for postprocessing effects?

I looked at all the existing postprocessing shaders and saw, all of them only use the color-texture, which is retrieved by

 

uniform sampler2D texture1;

 

I also found, that texture2 contains some kind of a cobblestone texture but all the other slots seem to be empty.

 

Also I saw, it is possible to push a Vec4 Uniform to the shader by

 

(C++):
myShader->SetVec4("foo", Vec4(0,0, 1, 1));

(GLSL):
uniform vec4 foo;

 

but I didn't find any way of pushing an arbitrary texture as a uniform.

Posted

Look in bloom.lua

 

--Called each time the camera is rendered
function Script:Render(camera,context,buffer,depth,diffuse,normals,emission)

  • Upvote 1

HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB

Posted

Thanks, got it working with your bloom.lua.

In case anyone else is interested:

 

//Render first image
myBuffer->Enable();
world->Render();
myBuffer->Disable();
context->Enable();
context->SetShader(myShader);
myBuffer->GetColorTexture()->Bind(1);
myBuffer->GetDepthTexture()->Bind(2);
context->DrawImage(myBuffer->GetColorTexture(),0,0);

 

The shader will get those by

 

uniform sampler2D texture1;
uniform sampler2D texture2;

 

Another question regarding this:

The depth-texture will only use the red-channel. The green- and blue-channel will always be 0 and the alpha-channel will always be 1. Storing four values per pixel if actually only one is useful, seems to be kind of a waste of space. Especially on the GPU space is a valuable good.

Is there anything I can do to help this?

  • Upvote 1

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.

×
×
  • Create New...