|
|
|
|
|
|
#define UNITY_SUPPORT_INSTANCING |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(SHADER_API_D3D11) |
|
|
|
#if defined(SHADER_API_D3D11) || defined(SHADER_API_GLCORE) || defined(SHADER_API_GLES3) |
|
|
|
#define UNITY_SUPPORT_STEREO_INSTANCING |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
// - UNITY_TRANSFER_VERTEX_OUTPUT_STEREO Copy stero target from input struct to output struct. Used in vertex shader. |
|
|
|
// - UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX |
|
|
|
#ifdef UNITY_STEREO_INSTANCING_ENABLED |
|
|
|
#if defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE) |
|
|
|
#define DEFAULT_UNITY_VERTEX_OUTPUT_STEREO uint stereoTargetEyeIndexSV : SV_RenderTargetArrayIndex; uint stereoTargetEyeIndex : BLENDINDICES0; |
|
|
|
#define DEFAULT_UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output) output.stereoTargetEyeIndexSV = unity_StereoEyeIndex; output.stereoTargetEyeIndex = unity_StereoEyeIndex; |
|
|
|
#else |
|
|
|
#endif |
|
|
|
#define DEFAULT_UNITY_TRANSFER_VERTEX_OUTPUT_STEREO(input, output) output.stereoTargetEyeIndex = input.stereoTargetEyeIndex; |
|
|
|
#define DEFAULT_UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input) unity_StereoEyeIndex = input.stereoTargetEyeIndex; |
|
|
|
#elif defined(UNITY_STEREO_MULTIVIEW_ENABLED) |
|
|
|
|
|
|
void UnitySetupInstanceID(uint inputInstanceID) |
|
|
|
{ |
|
|
|
#ifdef UNITY_STEREO_INSTANCING_ENABLED |
|
|
|
// stereo eye index is automatically figured out from the instance ID |
|
|
|
unity_StereoEyeIndex = inputInstanceID & 0x01; |
|
|
|
unity_InstanceID = unity_BaseInstanceID + (inputInstanceID >> 1); |
|
|
|
#if defined(SHADER_API_GLES3) |
|
|
|
// We must calculate the stereo eye index differently for GLES3 |
|
|
|
// because otherwise, the unity shader compiler will emit a bitfieldInsert function. |
|
|
|
// bitfieldInsert requires support for glsl version 400 or later. Therefore the |
|
|
|
// generated glsl code will fail to compile on lower end devices. By changing the |
|
|
|
// way we calculate the stereo eye index, we can help the shader compiler to avoid |
|
|
|
// emitting the bitfieldInsert function and thereby increase the number of devices we |
|
|
|
// can run stereo instancing on. |
|
|
|
unity_StereoEyeIndex = round(fmod(inputInstanceID, 2.0)); |
|
|
|
unity_InstanceID = unity_BaseInstanceID + (inputInstanceID >> 1); |
|
|
|
#else |
|
|
|
// stereo eye index is automatically figured out from the instance ID |
|
|
|
unity_StereoEyeIndex = inputInstanceID & 0x01; |
|
|
|
unity_InstanceID = unity_BaseInstanceID + (inputInstanceID >> 1); |
|
|
|
#endif |
|
|
|
#else |
|
|
|
unity_InstanceID = inputInstanceID + unity_BaseInstanceID; |
|
|
|
#endif |
|
|
|