Skip to content

v0.3.3 — Fix render-texture positioning + opacity

Choose a tag to compare

@UniqueName54321 UniqueName54321 released this 20 Aug 04:21
· 13 commits to main since this release

Two rendering bugs, one patch

Bug 1: VHS overlay was rendering offscreen

CCRenderTexture creates its internal sprite with scaleY = -1 (to flip the FBO output). We were setting that sprite's anchor to (0,0) and position to (0,0) — which plus the negative Y scale means the entire texture was flipped downward, below the screen.

Fix: Don't touch the internal sprite's anchor/position. Position the CCRenderTexture node itself centered at (winSize.width/2, winSize.height/2) instead.

Bug 2: Fragment shader ignored opacity

The fragment shader was outputting vec4(color, 1.0) — hardcoded alpha=1.0. The sprite's setOpacity() value comes through v_fragmentColor.a, but the shader was ignoring it completely. This meant fade-in, fade-out, and the opacity slider all did nothing.

Fix: Output vec4(color * v_fragmentColor.rgb * alpha, alpha) where alpha = v_fragmentColor.a. This uses premultiplied-alpha blending (matching CCRenderTexture's default blend mode), so the fade system now has actual authority over visibility.

The archaeology so far

Version Problem
v0.2.x Edit Special crashes (Object Collab beta.2 bug)
v0.3.0 Shader broken → overlay created → CCSprite::draw() crashes
v0.3.1 Null-shader guards added, crash prevented, shader fails to compile
v0.3.2 CC_MVPMatrix redeclaration fixed, shader compiles → nothing visible
v0.3.3 Positioning + opacity fixed → hopefully: VHS works 🎥

Full Changelog: v0.3.2...v0.3.3