- Home /
What is "sampler_ScreenTextures_linear_clamp" and what other options do I have in shaders?
In an example shader I found the use of: half depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_ScreenTextures_linear_clamp, reflectionScreenPos.xy);
. What is 'sampler_ScreenTextures_linear_clamp'? This variable is defined nowhere in the project but it still seems to function. Is this a variable hidden in the unity source code?
Answer by Namey5 · Jan 22, 2021 at 01:21 AM
https://docs.unity3d.com/Manual/SL-SamplerStates.html
Unity has two types of auto samplers;
Implicitly derived from a texture by the same name.
Created dynamically based on certain keywords.
Number 2 would be the case here, with the 'linear' and 'clamp' keywords at the end denoting that the texture should be sampled using bilinear texture filtering and clamped texture wrapping. If you wanted to user one yourself, you just need to declare it somewhere in the shader;
//Creates a SamplerState for sampling shadowmaps with hardware bilinear filtering
SamplerComparisonState sampler_LinearClampCompare;
Texture2D _Shadowmap;
...
//Sample the shadowmap using the auto-sampler
float shadow = _Shadowmap.SampleCmpLevelZero (sampler_LinearClampCompare, shadowCoords);
Your answer
Follow this Question
Related Questions
Render the scene only using a given a renderType tag 2 Answers
Shadergraph: Getting normal vectors 1 Answer
depth mask braking lighting 0 Answers
Shader queue tags not working...? -3 Answers
UI Blur shader not working 0 Answers