Jump to content

Capture Framebuffer - Get result in shader?


SpiderPig
 Share

Recommended Posts

If I capture a screenshot with framebuffer->Capture(), is there a way I get the result within a shader without first getting it as a pixmap, then converting it to a texture, then giving it to a material?

if (window->KeyHit(KEY_SPACE)) framebuffer->Capture();

auto caps = framebuffer->GetCaptures();
for (auto pixmap : caps)
{
    auto path = GetPath(PATH_DESKTOP) + "/screenshot.jpg";
    pixmap->Save(path);
    RunFile(path);
}

Maybe something like this might be possible?

FRAGMENT SHADER

if (capture_result_handle != -1){
	vec4 capture_color = texture(capture_result_handle, frag_coords)
}

 

Link to comment
Share on other sites

Not really, I want to capture a screen shot before I open my inventory and then use that result as a background for my inventory that will be blurred.  Like the window transparent effect in the editor.  It won't be real time but that's fine.  I'm just worried about spending the time waiting for the capture to be ready as a pixmap and then going through all the conversion and re-upload to the GPU when it's already there.

Link to comment
Share on other sites

  • 2 weeks later...

Just an idea, you can use 2 cameras for this. 

1. the normal realtime camera

2. a non realtime camera where you set the rendertarget to a new TextureBuffer. 

to the second camera you you attach the blur posteffect and assign the colorbuffer from the first (original) framebuffer via SetUnifrom("color", fb->GetColorAttachment(0)).

whenever you open the inventory, you render the second camera once and the Texturebuffer of the second camera will have the processed blurred image. This could be extended to also work in realtime. as the 2nd camera can be using a complete empty world or a comeplere unique renderlayer, so no processing power is lost.

  • Thanks 1
  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
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...