Render To Texture crash / how to correctly use?

When following the “Adding the render to texture component in a scene” example on this page Lumberyard crashes with the message:

Attempt to bind a non-render-target texture as a render-target

when I start typing in the Texture name such as “$rendertarget” I don’t even get the chance to finish typing the name, it crashes the second I press a key after $.

The examples seem to suggest that this should work without issue.

Hi @AlexB54, I just ran through the steps on that page but was unable to reproduce the crash. Can you provide more details about your project, test level and setup or crash logs?

Some things to check

  • After enabling the RenderToTexture gem in your project, be sure to run lmbr_waf configure and rebuild all (lmbr_waf build_win_x64_vs2017_profile -p all)
  • Try disabling the ‘Update in editor’ checkbox on the Render To Texture Component
  • Look in the logs for any warnings or errors. You can find them in dev/Cache//pc/user/log

Hi @petrocket thanks for the response.

I typically do the configure and build whenever enabling any gems, but did it again for good measure however no luck there.

Disabling “Update in editor” still causes the error as soon as something is typed into the field.

The error log at that location is flooded with “Attempt to bind a non-render-target texture as a render-target”

I have been able to test this out on another installation on a co-workers Lumberyard with success so I’m going to go through and reinstall it in the hopes that will solve my issue. Something seems to be wrong with my installation somewhere.

Hi @petrocket, I managed to get it working yesterday by going through and fully reinstalling. unfortunately that does mean I am unable to test the fix.

Great news that you have found the cause of the problem though.

Hi @AlexB54, I think I know what is going on and I don’t know why I didn’t run into it before. Probably due to how memory is initialized I just got lucky a lot.

If you open dev\Code\CryEngine\RenderDll\XRenderD3D9\RTT\RTTContext.cpp in a text editor and delete line 475 which has this line that is the cause of the crash because that is outside the range of the CTexture::s_ptexBackBufferScaledTemp array.

{ &CTexture::s_ptexBackBufferScaledTemp[2], 8 },

Then re-compile and it should fix the crash. Sorry about that! We’ve logged the issue and are getting the fix into the next release now.