Green ScrollView with RenderTexture

Hi,

I am working on some postprocessing. Everything works perfectly fine except rendering the ScrollView with RenderTexture. I am getting the “green” result - ScrollView is rendered as a green rectangle.

I have already tried glContextAttrs {8, 8, 8, 8, 24, 8}, but without any success.

Cocos version: 3.12.

I appreciate any hint.

Thank you,
kds

Found the answer. Looks like

scrollView->setClippingType(cocos2d::ui::Layout::ClippingType::SCISSOR)

solves the issue.

Unfortunately I have discovered another issue. Setting clipping type to SCISSOR solves “green” issue, but it causes another one :confused: It looks like the visible part of the scroll view is “moved” by some offset.

Here are all the cases (checked on Android and Windows):

  1. Without RenderTexture (proper behaviour)

  1. With RenderTexture and clipping type set to STENCIL

The visible region of the ScrollView is not moved.

  1. With RenderTexture and clipping type set to SCISSOR

The visible region of the ScrollView is moved by some offset.

When I scale the window on Windows this region is changing. It doesn’t happen when STENCIL clipping is set.

Could anyone help?

Are you testing on real device?

Yes, screenshots are grabbed from Samsung Grand Prime. But I get same results on Windows 10.

Also are you using cocos2d::ui::ScrollView ?

Yes.

I haven’t noticed any other issue - e.g. everything else (except ScrollView) is rendered properly to RenderTexture.

When I resize the window in Windows 10 (SHOW_ALL policy), the scene is scaled and the inner container of the ScrollView is moving. It doesn’t happen when STENCIL clipping type is set.

It looks like some calculations in Layout are wrong when the SCISSOR is enabled. But to be honest… I have no idea where I should dig :confused:

Well I don’t really know too,

I just remember I had similar issue which was only in android emulator.

Do you remember what cocos version you were using?

I have made more “build” tests.

win32 - works!
win 8.1 - doesn’t work
wp 8.1 - doesn’t work
android:

  • Grand Prime - doesn’t work
  • Sony Experia Z1 - works!

I also checked UIScrollView test in cpptests (I added RenderTexture) and the results are the same :confused:

Any idea? :frowning:

Hmm… I checked the RenderTexture again. When I pass GL_DEPTH24_STENCIL8 as a parameter to RenderTexture everything seems to work with STENCIL clipping. Unfortunately I have no idea why SCISSOR doesn’t work :confused:

The current solution seems to be creating render texture with GL_DEPTH24_STENCIL8.

Version: 3.13.1

I remember I found a fix here:

1 Like

I have already read it and it led me to the solution - creating RenderTexture with stencil. Previously I was creating texture with stencil disabled.

It seems that scissor is not supported by every device so it may explain why it worked differently.

The most important thing is that I can do my postprocessing now :slight_smile:

Thank you for your support!

@kds

I am also facing the same issue.
If I choose, SCISSOR as my clipping type to avoid the white and green textures in STENCIL
then, the clipping node size is not correct, it shows only a part of the scrollview.
as if the width and the height for the clipping node is not calculated correctly.

Did you find any fix for this in the SCISSOR mode !!

Hi, unfortunately I didn’t find fix for it. I found out that SCISSOR is not supported by all devices. That was the reason why I didn’t use SCISSOR.