Ma-Shell Posted June 21, 2014 Share Posted June 21, 2014 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. Quote Link to comment Share on other sites More sharing options...
shadmar Posted June 21, 2014 Share Posted June 21, 2014 Look in bloom.lua --Called each time the camera is rendered function Script:Render(camera,context,buffer,depth,diffuse,normals,emission) 1 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Ma-Shell Posted June 22, 2014 Author Share Posted June 22, 2014 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? 1 Quote Link to comment Share on other sites More sharing options...
Shadoh Posted June 22, 2014 Share Posted June 22, 2014 Cheers! I was actually just about to ask this Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.