External Publication
Visit Post

CartoonEdgeFilter makes the entire background black

jMonkeyEngine Hub February 20, 2026
Source

This is because the cartoon edge shader does not preserve the alpha channel.

github.com/jMonkeyEngine/jmonkeyengine

jme3-effects/src/main/resources/Common/MatDefs/Post/CartoonEdge.frag

48ce41b8e

    47.     normalDelta = clamp((normalDelta - m_NormalThreshold) * m_NormalSensitivity, 0.0, 1.0);



    48.     depthDelta  = clamp((depthDelta - m_DepthThreshold) * m_DepthSensitivity,    0.0, 1.0);



    49.



    50.     // Does this pixel lie on an edge?



    51.     float edgeAmount = clamp(normalDelta + depthDelta, 0.0, 1.0) * m_EdgeIntensity;



    52.



    53.     // Apply the edge detection result to the main scene color.



    54.     //color *= (1.0 - edgeAmount);



    55.     color = mix (color,m_EdgeColor.rgb,edgeAmount);



    56.



    57.     gl_FragColor = vec4(color, 1.0);



    58. }

I think the best solution atm is to fork CartoonEdgeFilter to preserve alpha. Tbh I don’t know why it wouldn’t already do that.

Discussion in the ATmosphere

Loading comments...