x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Accessing GBuffer from C++

For a university project I am working on implementing an RGBD camera as a plugin for Unreal.

Right now the plugin works by using three SceneCaptureComponent2Ds in order to capture a fully rendered image of the scene, depth data and an object mask. I had some issues with SceneCaptureComponents (e.g. the captured image being darker than ingame), so my instructor suggested "skipping the middle man" getting the data directly from the GBuffer.

I found GetGBufferData in DeferredShadingCommon.ush, though I don't whether it's possible (and if yes, how) to access that function from within regular C++ code.

I also am aware of the option View Mode -> Buffer Visualization Mode menu in the editor and tried to investigate how that is implemented, hoping to find some code to have a look at, but so far I haven't found anything.

Product Version: UE 4.18
Tags:
more ▼

asked Jan 18 '18 at 06:09 PM in C++ Programming

avatar image

jcmack
31 1 3

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Hello!!!!!

This is another way than not to use SceneCapu:This is Base On Unreal4.18

Source Code by BaiPaoXiaoDao

         ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER(
             DZRenderSutioBP_InterceptSceneBaseColor,
             UTexture2D*, vTextureAsset, TextureAsset,
             {
                 /*if (!IsInRenderingThread())
                 return;*/
                 FRHICommandListImmediate& RHICmdList = GRHICommandList.GetImmediateCommandList();
                 //计数加一避免Render完成后直接清空了GBuffer,但会慢一帧,你猜
                 FSceneRenderTargets::Get(RHICmdList).AdjustGBufferRefCount(RHICmdList, 1);
                 static const FString ScrollingMessage(TEXT("Hello World: "));
                 GEngine->AddOnScreenDebugMessage(-1, 0.2f, FColor::Red, ScrollingMessage);
                 FSceneRenderTargets& SceneContext = FSceneRenderTargets::Get(RHICmdList);
                 if (SceneContext.GBufferA)
                 {
                     FTexture2DRHIRef vTextTarget = SceneContext.GetGBufferATexture();
                     FString vSiceStr = FString::Printf(TEXT("FSceneRenderTargets GBufferA Size = %d*%d"), vTextTarget->GetSizeX(), vTextTarget->GetSizeY());
     
                     GEngine->AddOnScreenDebugMessage(-1, 0.2f, FColor::Red, vSiceStr);
                 }
                 //移除
                 FSceneRenderTargets::Get(RHICmdList).AdjustGBufferRefCount(RHICmdList, -1);
             }
         );


more ▼

answered Feb 12 '19 at 05:11 PM

avatar image

道藏小道
1 1

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question