|
|
|
|
|
|
projMatrix._13_23_33_43 = -projMatrix._13_23_33_43; |
|
|
|
} |
|
|
|
|
|
|
|
#if UNITY_REVERSED_Z |
|
|
|
#if SHADER_API_OPENGL || SHADER_API_GLES || SHADER_API_GLES3 |
|
|
|
//GL with reversed z => z clip range is [near, -far] -> should remap in theory but dont do it in practice to save some perf (range is close enough) |
|
|
|
#define UNITY_Z_0_FAR_FROM_CLIPSPACE(coord) max(-(coord), 0) |
|
|
|
#else |
|
|
|
//D3d with reversed Z => z clip range is [near, 0] -> remapping to [0, far] |
|
|
|
//max is required to protect ourselves from near plane not being correct/meaningfull in case of oblique matrices. |
|
|
|
#define UNITY_Z_0_FAR_FROM_CLIPSPACE(coord) max(((1.0-(coord)/_ProjectionParams.y)*_ProjectionParams.z),0) |
|
|
|
#endif |
|
|
|
#elif UNITY_UV_STARTS_AT_TOP |
|
|
|
//D3d without reversed z => z clip range is [0, far] -> nothing to do |
|
|
|
#define UNITY_Z_0_FAR_FROM_CLIPSPACE(coord) (coord) |
|
|
|
#else |
|
|
|
//Opengl => z clip range is [-near, far] -> should remap in theory but dont do it in practice to save some perf (range is close enough) |
|
|
|
#define UNITY_Z_0_FAR_FROM_CLIPSPACE(coord) (coord) |
|
|
|
#endif |
|
|
|
|
|
|
|
#endif // UNITY_SHADER_VARIABLES_FUNCTIONS_INCLUDED |