Green ScrollView with RenderTexture

Green ScrollView with RenderTexture
0.0 0

#1

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


#2

Found the answer. Looks like

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

solves the issue.


#3

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?


#4

Are you testing on real device?


#5

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


#6

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


#7

Yes.

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


#8

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.


#9

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:


#10

Well I don’t really know too,

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


#11

Do you remember what cocos version you were using?


#12

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:


#13

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.


#14

Version: 3.13.1

I remember I found a fix here:


#15

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!