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

Not working when changing shader at runtime with App SpaceWarp #4

Open
smitdylan2001 opened this issue Jan 17, 2022 · 6 comments
Open

Comments

@smitdylan2001
Copy link

I have a cross platform game I want to add spacewarp support to on quest. I use custom shaders which don't support motion vectors, so in Awake I change the shader to the Lit (also tested Simple Lit) shader and added the main tex to the material again.
If I do this there is a LOT of issues.
Objects seem to have a link to their original position and have weird artifacts between them as if the object exists on start position, end position and everything in between at the same time.

@smitdylan2001 smitdylan2001 changed the title Not working when changing shader at runtime Not working when changing shader at runtime with App SpaceWarp Jan 17, 2022
@smitdylan2001
Copy link
Author

I tried both doing it in Awake and have the same issue if I do it with callback while building
https://docs.unity3d.com/ScriptReference/Callbacks.PostProcessSceneAttribute.html

@tsaileo1
Copy link
Collaborator

Hey, I'd recommend adding the motion vector pass to your custom shader instead of swaping the shaders at runtime. That might be easier and cause less issues. Try looking at how the motion vector pass is added in the Lit shader and you can do the same or something similar in your custom shader.

@smitdylan2001
Copy link
Author

Hey, I'd recommend adding the motion vector pass to your custom shader instead of swaping the shaders at runtime. That might be easier and cause less issues. Try looking at how the motion vector pass is added in the Lit shader and you can do the same or something similar in your custom shader.

Sadly no one in our team is skilled enough to do this, at least not next to all other work. The shaders are made in amplify, and they become quite complex behind the scenes. If it's not as hard as it seems I wouldn't mind trying, but doubt it will go great.
Sadly the amplify team couldn't help me further either, as they don't have great support for custom render pipelines.

P.S. the callbacks I mentioned in my reply should change the shaders at runtime, so that should have worked, and this would be a good thing to look into in general as some games do change shaders or materials at runtime, which now could cause issues.

@tsaileo1
Copy link
Collaborator

How are you enabling space warp? Are you calling OVRManager.SetSpaceWarp()? Another question I have is if you're trying to switch the shader on awake, why not have it as the Lit shader starting off? Is there something preventing you from having the object with the Lit shader on it initially?

Unfortunately, I'm not to familiar with amplify. I could help investigate a bit to see how the shaders are built under that system.

@smitdylan2001
Copy link
Author

  1. i think so? I was using a sample project to start with: https://github.com/nukadelic/unity-application-spacewarp/ and added in my materials/sjaders from my main project. There is a button which sets spacewarp true or false.
  2. The regular game uses custom shaders with a combined texture map for specular, roughness, etc. This costs extra vram and performance and for the quest we wanted to get it working with jist the maintexture for performance reasons.

@tsaileo1
Copy link
Collaborator

tsaileo1 commented Jan 21, 2022

Ah, I was talking to nukadelic in the other issue they posted here. There was a bug in how that sample project was enabling space warp. Try updating the sample project to see if it has been fixed. If not you can see what we discussed here to fix it:
#3

I see you have a cross platform game to uses one shader type for like PC and you want a lighter variant for Quest. I would recommend seeing if space warp is being turned on properly first and seeing if your script still works in switching the shader.

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