Skip to content

Commit

Permalink
Merge pull request #106 from amamagi/stereo-instancing
Browse files Browse the repository at this point in the history
Add support for single pass instanced stereo rendering
  • Loading branch information
Santarh authored Apr 5, 2021
2 parents cbf459c + e29da2a commit bef0e20
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion MToon/Resources/Shaders/MToonCore.cginc
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@ struct v2f
UNITY_FOG_COORDS(7)
UNITY_SHADOW_COORDS(8)
//UNITY_VERTEX_INPUT_INSTANCE_ID // necessary only if any instanced properties are going to be accessed in the fragment Shader.
UNITY_VERTEX_OUTPUT_STEREO
};

inline v2f InitializeV2F(appdata_full v, float4 projectedVertex, float isOutline)
{
v2f o;
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
//UNITY_TRANSFER_INSTANCE_ID(v, o);

o.pos = projectedVertex;
Expand Down Expand Up @@ -114,6 +115,7 @@ float4 frag_forward(v2f i) : SV_TARGET
#endif

//UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);

// const
const float PI_2 = 6.28318530718;
Expand Down
3 changes: 3 additions & 0 deletions MToon/Resources/Shaders/MToonSM3.cginc
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@

v2f vert_forward_base(appdata_full v)
{
UNITY_SETUP_INSTANCE_ID(v);
v.normal = normalize(v.normal);
return InitializeV2F(v, UnityObjectToClipPos(v.vertex), 0);
}

v2f vert_forward_base_outline(appdata_full v)
{
UNITY_SETUP_INSTANCE_ID(v);
v.normal = normalize(v.normal);
return InitializeV2F(v, CalculateOutlineVertexClipPosition(v), 1);
}

v2f vert_forward_add(appdata_full v)
{
UNITY_SETUP_INSTANCE_ID(v);
v.normal = normalize(v.normal);
return InitializeV2F(v, UnityObjectToClipPos(v.vertex), 0);
}
2 changes: 2 additions & 0 deletions MToon/Resources/Shaders/MToonSM4.cginc
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

appdata_full vert_forward_base_with_outline(appdata_full v)
{
UNITY_SETUP_INSTANCE_ID(v);
v.normal = normalize(v.normal);
return v;
}

v2f vert_forward_add(appdata_full v)
{
UNITY_SETUP_INSTANCE_ID(v);
v.normal = normalize(v.normal);
return InitializeV2F(v, UnityObjectToClipPos(v.vertex), 0);
}
Expand Down

0 comments on commit bef0e20

Please sign in to comment.