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

VR Compatibility - single pass instanced? #4

Open
reddo123 opened this issue Nov 12, 2021 · 1 comment
Open

VR Compatibility - single pass instanced? #4

reddo123 opened this issue Nov 12, 2021 · 1 comment

Comments

@reddo123
Copy link

Hi. The example works nicely in VR with multipass. I'm trying to get it to display with stereo instancing/single-pass instanced using this guide - https://docs.unity3d.com/Manual/SinglePassInstancing.html

However, no success at the moment.
In the grass.hlsl file I've inserted some lines

struct Varyings {
	//float4 positionOS   : SV_POSITION;
	float3 positionWS	: TEXCOORD1;
	float3 positionVS	: TEXCOORD2;
	float3 normal		: TEXCOORD3;
	float4 tangent		: TEXCOORD4;
	float2 texcoord		: TEXCOORD0;
	UNITY_VERTEX_INPUT_INSTANCE_ID // insert
};

and

Varyings vert (Attributes input) {
	Varyings output = (Varyings)0;

	// added code
	UNITY_SETUP_INSTANCE_ID(input);
#if defined(UNITY_COMPILER_HLSL)
#define UNITY_INITIALIZE_OUTPUT(type,name) name = (type)0;
#else
#define UNITY_INITIALIZE_OUTPUT(type,name)
#endif
	UNITY_INITIALIZE_OUTPUT(Varyings, output); //Insert
	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); //Insert
	// added code end
...

Not sure exactly what needs to be added but any assistance appreciated.

@Cyanilux
Copy link
Owner

Cyanilux commented Nov 16, 2021

I'm not very familiar with VR, but at a guess you'd need to add the same sort of macros in the geom shader as well as vert.
This isn't for URP, but the answer here should help as the macros are similar (except maybe UNITY_INITIALIZE_OUTPUT but that just sets it equal to 0, which is what = (Varyings)0; is doing already). https://answers.unity.com/questions/1702908/geometry-shader-in-vr-stereo-rendering-mode-single.html

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