How to Access Normal and Diffuse Values from the Camera?

Hello.

I would like to use the normal and diffuse values from the camera view in a script. Is it possible to get those information as separate buffers for that purpose?

You could set up a separate camera (that matches the main camera), that renders to a texture, and get it to render normal and similar.

It’d be something similar to this example: PlayCanvas Examples

See the Mode drop down control - you can pick a world normal and albedo.

1 Like

Thanks.
Hmmm, I have seen this exsample a few times, but honestly, I don’t know how to utilize it in the editor.
I have done the method of using a render target from another camera. If so, do I need to use custom shaders to show only normals and diffuse?

you need to call something like this

entity.camera.setShaderPass(pc.SHADERPASS_WORLDNORMAL);

to render world normals by the camera.

See more here: CameraComponent | PlayCanvas API Reference

So if you’re happy with what this can render, you don’t need a custom shader. It can render world normals and albedo (diffuse), so that’s what you need I think.

1 Like

Thanks!
I think I can do what I want with that code.