Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Z-distance for VR headsets #8

Open
PaulTapper1 opened this issue Jul 7, 2021 · 4 comments
Open

Z-distance for VR headsets #8

PaulTapper1 opened this issue Jul 7, 2021 · 4 comments

Comments

@PaulTapper1
Copy link

Hi

Thanks for making this.... lens flares not working in Universal RP is a real problem.

I am trying to get this working in my Oculus Quest 2 VR project. At the moment URPLensFlare.cs has DISTANCE = 1f; which means that it draws as if its very close to my head (so my eyes have to focus right in to see it). If I set DISTANCE = 3000f; then the two viewpoints of my eyes see it correctly as something focussed in the distance, but now it draws behind objects in the scene.

Do you know if other users are using this in a VR project?... how do I make it appear at the correct distance for the two viewpoints, but not get Z-tested away by objects in the scene?

Thanks for any help

Paul

@Reguluz
Copy link
Collaborator

Reguluz commented Jul 8, 2021

Hi, I'm so sorry for that. For I don't have any VR development kit, I can't be sure that if this solution will run correctly on VR project. And I have never thought about making adaption.
However, I think you could close the ZTest function of the material you use for rendering flares.
I've just updated an example material with a new shader. This shader is copied from ParticleUnlit shader inside URP package. For I need to show the custom property, I have close the original editor of this shader(but the properties are the same). I added ZTest option and set it on "Never" option as default. Maybe you can trying this shader to solve your problem(I'm really not sure if it will effect or not). I'll waiting for your feedback.

@Reguluz
Copy link
Collaborator

Reguluz commented Jul 8, 2021

And you can contrast this new shader with the original version to find the code I have added. If this methods can solve your problem, you can do the same change for any shader you will used for rendering flares.

@PaulTapper1
Copy link
Author

Hi Reguluz

I Pulled your latest code and tried it. Unfortunately it doesn't seem to have disabled the z-test :( . If I draw the flares at DISTANCE = 3000; they still z-sort behind objects in the scene.

I've actually decided against Universal RP for our project for now anyway, due to performance issues, so please don't spend any more time trying to fix it for me, but I guess it could be a useful thing to fix for other possible users. You could probably reproduce the problem easily yourself by just setting DISTANCE = 3000; and checking it aren't getting z-tested.

Thanks for trying.

Paul

@Reguluz
Copy link
Collaborator

Reguluz commented Jul 9, 2021

Hi Reguluz

I Pulled your latest code and tried it. Unfortunately it doesn't seem to have disabled the z-test :( . If I draw the flares at DISTANCE = 3000; they still z-sort behind objects in the scene.

I've actually decided against Universal RP for our project for now anyway, due to performance issues, so please don't spend any more time trying to fix it for me, but I guess it could be a useful thing to fix for other possible users. You could probably reproduce the problem easily yourself by just setting DISTANCE = 3000; and checking it aren't getting z-tested.

Thanks for trying.

Paul

Oh, I'm so sorry that this solution based on rendering billboard typed mesh on the scene, and the DISTANCE property set the real distance between the mesh and your camera. I designed it for non VR situation so the distance of lshould be a bit more far from "near clip plane". Though I don't have any VR equipments, I'm sure that there will be some solution by changing shader settings to solve your question. Maybe you could think about using stencil to force render flare meshes in front of any other game objects. And this lens flare render system don't requires any special usages of different render pipeline, so it could be rendered correctly in any render pipeline.You can still have a try

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

No branches or pull requests

2 participants