shadercompiler
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| shadercompiler [2021/04/30 04:15] – 73.95.178.156 | shadercompiler [2025/01/15 04:35] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Shader Compiler ====== | ====== Shader Compiler ====== | ||
| - | **" | + | ==== Bug: Samplers are incorrectly stripped |
| Consider this code: | Consider this code: | ||
| - | < | + | < |
| #pragma shader_feature_local_fragment _ _ALBEDO; | #pragma shader_feature_local_fragment _ _ALBEDO; | ||
| TEXTURE2D(_Albedo); | TEXTURE2D(_Albedo); | ||
| Line 21: | Line 21: | ||
| </ | </ | ||
| + | When compiling, two variants are created, one for when albedo is on, another for when it's off. This will throw an error saying that sampler_albedo cannot be found((Note: | ||
| + | ''" | ||
| - | When compiling this code, two variants are created, one for when albedo is on, another for when it's off. This will throw an error saying that sampler_albedo cannot be found. First, | + | DX9 associates samplers with textures, and so Unity does too. When you set a Unity Texture to '' |
| - | The reason for this is because DX9 associated samplers with textures, and Unity as an engine does also. When you set clamp on a texture, really it sets clamp on sampler_< | + | **However**, Unity assumes that since '' |
| Possible workarounds: | Possible workarounds: | ||
| - | - Give the normal map it' | + | * Give the _Normal texture its own sampler |
| - | - Use a sampler not associated with a texture (which means the user cannot edit it via the texture settings) | + | |
| - | - Make sure you always sample the texture associated with the sampler so it doesn' | + | |
| + | <code glsl> | ||
| result *= saturate(1 + SAMPLE_TEXTURE2D_LOD(_Albedo, | result *= saturate(1 + SAMPLE_TEXTURE2D_LOD(_Albedo, | ||
| return result; | return result; | ||
| + | </ | ||
shadercompiler.1619756123.txt.gz · Last modified: 2025/01/15 04:35 (external edit)