Monday, August 14, 2017

Dependent Texture Reads

Not dependent:
float3 nonDependentTextureRead = tex2D(_MainTexture, input.texcoord).xyz;

Dependent:
float3 DependentTextureRead = tex2D(_MainTexture, input.texcoord.zw).xyz;
float3 DependentTextureRead = tex2D(_MainTexture, input.texcoord.yx).xyz;
float3 DependentTextureRead = tex2D(_MainTexture, input.texcoord*2.0).xyz;

==========================

struct v2f{
 half2 uv : TEXCOORDn; //pass uvs direcly
 half4 packed2uvs : TEXCOORDn; //afraid of dependent texture read, avoid packing 2 uvs into 1 varying
 half4 packed4Scalars : TEXCOORDn; //for general purpose scalar packing
}

tex2D(_Texture,i.uv); //good, fastest
tex2D(_Texture,i.uv.xy); //afraid of dependent texture read, depends on driver?. avoid
tex2D(_Texture,i.uv.zw); //afraid of dependent texture read. avoid

Tuesday, March 28, 2017

Substance Designer/Painter Usages

Type Identifier Usage
Ambient Occlusion ambient_occlusion ambientOcclusion
Anisotropy Angle anisotropyangle anisotropyangle
Anisotropy Level anisotropylevel anisotropylevel
Base Color basecolor basecolor
Color ID id colorID
Curvature curvature curvature
Diffuse diffuse diffuse
Height height height
IOR ior ior
Metallic metallic metallic
Normal normal normal
Position position position
Reflection reflection reflection
Roughness roughness roughness
Specular specular specular
Specular Level specularlevel specularlevel
Thickness thickness thickness
Transmissive transmissive transmissive
User 0 user0 user0
User 1 user1 user1
User 2 user2 user2
User 3 user3 user3
User 4 user4 user4
User 5 user5 user5
User 6 user6 user6
User 7 user7 user7
World space normals world_space_normals normalWS

Wednesday, March 8, 2017

Unity Shader Property Names

Legacy

  • _MainTex (Texture, diffuse color in the RGB channels, transparency in the A channel)
  • _Color (Color, diffuse color tint. This is multiplied by _MainTex)
  • _SpecMap (Texture, specular map)
  • _SpecColor (Color, specular color tint)
  • _Shininess (Value or Slider, controls glossiness)
  • _BumpMap (Texture, normal map)
  • _TransparencyLM (Texture, rgb channels define colored transparency)
  • _Illum (Texture, for emissive materials. This will be a mask of _MainTex * _Color)

Standard

  • Albedo  (diffuse color)
  • Normal (tangent space normal, if written)
  • Emission
  • Specular (specular power in 0..1 range)
  • Gloss (specular intensity)
  • Alpha (alpha for transparencies)

Physical (metallic)

  • Albedo (base - diffuse or specular - color)
  • Normal (tangent space normal, if written)
  • Emission
  • Metallic (0=non-metal, 1=metal)
  • Smoothness (0=rough, 1=smooth)
  • Occlusion (occlusion - default 1)
  • Alpha (alpha for transparencies)

Physical (specular)

  • Albedo (diffuse color)
  • Specular (specular color)
  • Normal (tangent space normal, if written)
  • Emission
  • Smoothness (0=rough, 1=smooth)
  • Occlusion (occlusion  - default 1)
  • Alpha (alpha for transparencies)

Monday, January 23, 2017

Unity3D Geometry LOD Stuff


  • Level of Detail (LOD)
    "Unity lets you set maximum LOD levels and a LOD bias preference (ie, whether to favour higher or lower LOD levels at threshold distances) in the Quality Settings."

Sunday, January 22, 2017

Unity3D Shader LOD Stuff

Unity3D Documentation:


  • Shader LOD Values
    VertexLit kind of shaders = 100
    Decal, Reflective VertexLit = 150
    Diffuse = 200
    Diffuse Detail, Reflective Bumped Unlit, Reflective Bumped VertexLit = 250
    Bumped, Specular = 300
    Bumped Specular = 400
    Parallax = 500
    Parallax Specular = 600
  • Global Shader LOD Setting

Shader Forge:

Thursday, January 5, 2017

Conversion Chart

Decimal 8bit Angular
0.05 13 18
0.1 26 36
0.15 38 54
0.2 51 72
0.25 64 90
0.3 77 108
0.35 90 126
0.4 102 144
0.45 115 162
0.5 128 180
0.55 141 198
0.6 154 216
0.65 166 234
0.7 179 252
0.75 192 270
0.8 205 288
0.85 218 306
0.9 230 324
0.95 243 342
1.0 255 360