Created
August 13, 2014 09:37
-
-
Save aras-p/dea83b8309a75554067c to your computer and use it in GitHub Desktop.
sampling shadowmap without comparison on d3d11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Problem is that by default SamplerComparisonState sampler is coupled with the shadowmap. | |
// So if you want to sample it regularly, you'll have to find a suitable sampler from another used texture. | |
// For example, let's say _MainTex has a suitable sampler (set to bilinear, whatever). | |
UNITY_DECLARE_TEX2D(_MainTex); // will declare Texture2D _MainTex and SamplerState sampler_MainTex | |
UNITY_DECLARE_SHADOWMAP(_Myshadow); // will declare Texture2D _Myshadow and SamplerComparisonState sampler_Myshadow | |
// sample as a shadowmap with comparison (all platforms) | |
float s = UNITY_SAMPLE_SHADOW_PROJ(_Myshadow, float4(xy,depth,1.0)); | |
// sample depth value without comparison | |
#ifdef SHADER_API_D3D11 | |
float z = _Myshadow.Sample (sampler_MainTex, xy); // use sampler from _MainTex | |
#else | |
// well, something else on other platforms | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment