Skip to content

Conversation

@jo-chemla
Copy link

Description

These Effects are meant to compute Normals based solely on the Depth-buffer, as well as compute matcap based on screen-space-normal (also included sobel) based on reference implementations:

I implemented ScreenSpaceNormalEffect, MatcapEffect and SobelOperatorShader in the same PR.

Note I did not have the time to test again, my understanding it that I was using v6 when writing these effects. I'm probably not using Geometry buffers correctly - relying on depth only. Would love some input to include this in next release!

@jo-chemla jo-chemla changed the title Screen depth effects Screen-Space depth effects: ScreenSpaceNormal, Matcap, Sobel Aug 11, 2025
@jo-chemla jo-chemla mentioned this pull request Aug 11, 2025
3 tasks
@vanruesc
Copy link
Member

Hi, thanks for this!

The current v6 version is effectively in maintenance mode and all development efforts are focused on v7. As such, I'd suggest that we close this PR and link to it as a reference implementation in new feature tickets for v7.

@vanruesc
Copy link
Member

I've created a ticket for the normal reconstruction: #726. I think it's more appropriate to create a pass for that so that it can be used in other passes and effects.

Sobel will be implemented as part of #583.

I'm not sure about MatcapEffect - that one seems more like a custom effect that belongs to user space.

@vanruesc vanruesc closed this Aug 21, 2025
@jo-chemla
Copy link
Author

Thanks, will try to have another take at these effects with v7 when I get the chance!

Indeed, the most important effect is ScreenSpaceNormalEffect. MatcapEffect can belong to user-space, but is a widely used shader for users to display geometry - available in blender, threejs etc if the object has vertexNormals. The nicety with screen-space-normals is that one could apply it to any object that writes to depth. See for example this great matcap spheres library or video.

Out of curiosity, any general rule of thumb for porting code from pmndrs/postprocessing v6 to v7 or upgrade guide available somewhere? Thanks a lot!

@vanruesc
Copy link
Member

Matcap is useful, but wouldn't it be better to use three's MeshMatcapMaterial as an override material instead? Calculating the lighting for all meshes in a scene only for them to be overwritten with a simple matcap filter in post seems very wasteful.

Out of curiosity, any general rule of thumb for porting code from pmndrs/postprocessing v6 to v7 or upgrade guide available somewhere?

There's a detailed guide for custom passes and effects for v7. Other than that, your best bet is to look at the existing passes and effects in v7 for reference.

For the NormalReconstructionPass I recommend using the DepthDownsamplingPass implementation from v7 as reference. You can check out the v6 implementation for comparison.

@jo-chemla
Copy link
Author

Thanks again for getting back with guidance, I'll do my best.

Regarding matcap, if vertex-normals are present using MeshMatcapMaterial as an override material is indeed probably very efficient.

Our use case was we had a threejs scene with 3DTilesRendererJS tileset loading hundreds of mesh tiles depending on viewport camera. The mesh tiles did not have vertex-normals so threejs default MeshMatcapMaterial turned simply black. The beauty of these passes from my point of view is that we don't compute lighting at all, just use depth-buffer -> normal-from-depth -> matcap, even if the scene renders PBR, where matcap fragment shader simply uses normal at pixel to compute matcap sphere lookup coordinates with a dot product (reflect).

@vanruesc
Copy link
Member

Ahh, I see. Well, it's up to you - if you send a PR with a v7 implementation of MatcapEffect I'll definitely take a look. And if it looks alright I'll merge it in. But the normal reconstruction pass should be done first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants