alelievr / HDRP-Custom-Passes

A bunch of custom passes made for HDRP
MIT License
1.25k stars 136 forks source link

Baking Custom Pass stretched texture #24

Closed quezdk closed 3 years ago

quezdk commented 3 years ago

In the Camera Depth Baking scene, the baking camera is stretched when the main view aspect ratio changes. This is different from the behavior when setting a target texture in the camera which respects the target texture's aspect ratio. What is causing this and is it possible to replicate the behavior of the baking to a target texture?

alelievr commented 3 years ago

Hello,

Thanks for reporting the issue. The current behavior of the RenderFromCamera functions (used in baking custom pass example) is to inherit the aspect ratio of the current rendering camera, which is causing the scale issue you observed.

Unfortunately, with the current API, it's impossible to override the aspect ratio to use the one of another camera. I've logged a feature request for HDRP but it will probably cause a breaking change in the API so it'll take quite a bit of time to land.

In the meantime, I've uploaded a workaround that adapts the render texture size to the current camera, this should improve a bit the current behavior (see e26b22b10f88015ec75811264d86d47a3eef3344)

https://user-images.githubusercontent.com/6877923/112519561-c7b5ea00-8d9a-11eb-9a97-48a00037f968.mp4