Uninomicon

Documenting the dark corners of the Unity Engine.

User Tools

Site Tools


shadercompiler

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
shadercompiler [2021/04/30 04:43]
uninomiconadmin
shadercompiler [2021/05/10 21:17] (current)
uninomiconadmin
Line 1: Line 1:
 ====== Shader Compiler ====== ====== Shader Compiler ======
  
-==== "sampler_texname not found" compile error when sharing samplers ====+==== Bug: Samplers are incorrectly stripped when used with stripped Texture2D ====
  
 Consider this code: Consider this code:
  
-<code>+<code glsl>
 #pragma shader_feature_local_fragment _ _ALBEDO; #pragma shader_feature_local_fragment _ _ALBEDO;
 TEXTURE2D(_Albedo); TEXTURE2D(_Albedo);
Line 21: Line 21:
 </code> </code>
  
- +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: this error will only be thrown on some platforms (windows)) ((the spelling of the error is wrong, as it's all lowercase when the variable is not))
-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: this error will only be thrown on some platforms (windows)) ((the spelling of the error is wrong, as it's all lowercase when the variable is not)) +''"sampler_texname not found" compile error when sharing samplers''
  
 DX9 associates samplers with textures, and so Unity does too. When you set a Unity Texture to ''Clamp'', it sets '-''clamp'' on sampler_<TEXTURENAME>. When the variant with ''_ALBEDO'' not defined is compiled, the compiler strips the albedo texture because it's not being used. DX9 associates samplers with textures, and so Unity does too. When you set a Unity Texture to ''Clamp'', it sets '-''clamp'' on sampler_<TEXTURENAME>. When the variant with ''_ALBEDO'' not defined is compiled, the compiler strips the albedo texture because it's not being used.
Line 33: Line 33:
   * Make sure you always sample the texture associated with the sampler so it doesn't get stripped. Something like:   * Make sure you always sample the texture associated with the sampler so it doesn't get stripped. Something like:
  
-<code>+<code glsl>
 result *= saturate(1 + SAMPLE_TEXTURE2D_LOD(_Albedo, sampler_Albedo, float2(0,0), 11)); result *= saturate(1 + SAMPLE_TEXTURE2D_LOD(_Albedo, sampler_Albedo, float2(0,0), 11));
 return result; return result;
shadercompiler.1619757813.txt.gz · Last modified: 2021/04/30 04:43 by uninomiconadmin