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"

GetRenderTargetTexture() on GameViewport works in editor mode, but returns 0 in standalone

I'm trying to get a native texture pointer to the content currently displayed on screen.

Using 4.8.3 and executing the following code on the render thread:

 GEngine->GameViewport->GetGameViewport()->GetRenderTargetTexture().GetReference();

Returns the correct texture pointer when run in the editor, and everything works fine.

However, when I run my project as a standalone or after packaging, it returns a null pointer. I'm guessing the viewports and rendertargets are set up differently in standalone mode compared to regular mode. How can I achieve what I want, so it works in all cases?

Product Version: UE 4.8
Tags:
more ▼

asked Jul 30 '15 at 12:29 PM in Rendering

avatar image

Yu He
56 1 2 93

avatar image Yu He Aug 03 '15 at 02:07 PM

Okay, so I managed to get non-null texture pointer, by moving the code to the Draw() method of a custom UGameViewportClient, but the texture I get is not being rendered to when playing as standalone (I get a completely black texture). The exact same code works fine in PIE-mode.

avatar image Yu He Aug 04 '15 at 01:41 PM

So it seems that the viewport in PIE-mode creates a render texture with a format that is different from the one in standalone mode. I get:

  • PF_B8G8R8A8 in PIE-mode

  • PF_A2B10G10R10 in standalone-mode

Can I force the render texture format of standalone mode to be the same format?

avatar image jlanders Nov 18 '15 at 07:42 PM

Did you get anywhere with this?

I'm trying to enable the AVIWriter::StartCapture during a standalone build. Of course it gets a viewport with a null RenderTarget...

avatar image HaxO Nov 19 '15 at 10:37 PM

Hey Yu He!

I am working on a similar issue and like you can only get black video out. Did you end up finding a way to convert the Pixel Format?

Information on this stuff is so hard to find >.<

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

I did in fact solve this! To convert the pixel format, you can sample the backbuffer using a simple pixel shader and draw it on a new render target with the desired size and format. Seems to have close to zero impact on performance.

more ▼

answered Nov 26 '15 at 03:15 PM

avatar image

Yu He
56 1 2 93

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

hi Ye Hu, can you give some light on how did you solve this? Thanks alot, i'm having the same issue :(

more ▼

answered Feb 19 '19 at 10:51 AM

avatar image

Madlions
1 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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