Saturday, November 6, 2021

Unity Frame Rates

To reach 60FPS we must update and render each frame in less than 16.67 milliseconds. The time budget for 30FPS is double that, thus 33.33ms per frame.

URP prefers the SRP batcher over GPU instancing, so to make GPU instancing work the SRP batcher has to be disabled. 

We could conclude from this data that for URP GPU Instancing is best, followed by dynamic batching, and then the SRP batcher. But the difference is small, so they seem effectively equivalent for our graph. The only clear conclusion is that either GPU instancing or the SRP batcher should be used.

Tuesday, August 7, 2018

Vector3 Extensions

public static Vector3 xyz (this Vector3 v, float x, float y, float z) {
    v.x = x;    v.y = y;   v.z = z;
    return v;
}
public static Vector3 xy (this Vector3 v, float x, float y) {
    v.x = x;   v.y = y;
    return v;
}
public static Vector3 xz (this Vector3 v, float x, float z) {
    v.x = x;   v.z = z;
    return v;
}

//calling it
Vector3 v = Vector3.zero;
v.xz(5f,10f);


//============================

public static Vector3 ChangeX (this Transform transform, float x) {
    Vector3 position = transform.position;
    position.x = x;
    transform.position = position;
    return position;
}
// Do the same for ChangeY and ChangeZ
// ...

// Old version
Vector3 position = transform.position;
position.x = 10;
transform.position = position;

// New version
transform.ChangeX(10);

Unity3D - Vector3 to Quaternion


static vector3 quaternion
vector3.zero (0, 0, 0) (0.0, 0.0, 0.0, 1.0)
vector3.back (0, 0, -1) (0.0, 0.0, -0.5, 0.9)
vector3.down (0, -1, 0) (0.0, -0.5, 0.0, 0.9)
vector3.forward (0, 0, 1) (0.0, 0.0, 0.5, 0.9)
vector3.left (-1, 0, 0) (-0.5, 0.0, 0.0, 0.9)
vector3.one (1, 1, 1) (0.6, 0.2, 0.2, 0.8)
vector3.right (1, 0, 0) (0.5, 0.0, 0.0, 0.9)
vector3.up (0, 1, 0) (0.0, 0.5, 0.0, 0.9)

Wednesday, February 21, 2018

Inheritance

public interface iBaseClass {
  void BaseClassMethod;
}


public class BaseClass : iBaseClass{
   // equivalent to private
   protected internal float accesibleToDerivedFloat = 0f;

   protected virtual void PrivateBaseClassMethod (){
      accesibleToDerivedFloat = 1f;
   }

   public virtual void BaseClassMethod ( //empty ) {}
}

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

public interface IDerivedClass : IBaseClass{
}

public class DerivedClass : BaseClass, IDerivedClass{
   public override void PublicBaseClassMethod (){
      accesibleToDerivedFloat += 1f;
   }
}

Tuesday, February 13, 2018

Blender Sculpting Shortcuts


  • F = Adjust Brush SIZE
  • Shift + F = Adjust Brush Strength
  • Ctrl = Switch Between Add/Substract

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

Saturday, May 20, 2017

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

Sunday, November 20, 2016

PBR Spec/Gloss to Metal/Rough

  • Invert Gloss to generate Roughness
  • Metal must be done manually.
  • Diffuse/Albedo is more trick if the material is metallic. Spec color is a base for albedo, since Diffuse is black for metals.

Wednesday, July 27, 2016

Java Install under Windows

1. Go to http://www.oracle.com/technetwork/java/javase/downloads/index.html and download and install BOTH the JRE and the JDK

2. After they are installed you must add the following to your System Variables:

  • JAVA_HOME          C:\Program Files\Java\jdk1.8.0_74 (or whatever your actual install path is)
  • JDK_HOME            %JAVA_HOME%\bin
  • JRE_HOME            %JAVA_HOME%\jre

Monday, September 21, 2015

ZBrush Custom Menus

To Create Custom Menus in Zbrush:


  1. Preferences/Config/Enable Customize 
  2. Preferences/Custom UI/Create New Menu
  3. Name it
  4. It will appear along the top menus
  5. Drag it to the right most pane to edit it
  6. Ctrl + Drag Items into the New Menu 
  7. To add a Sub Palette, drag it from Preferences/Custom UI/Custom Subpalette (Ctrl + Click SubPalette's name to rename, AFTER it has things in it)
  8. When Done, CLICK OFF "Enable Customize" Button
  9. Preferences/Config/Save UI 
  10. Name and Save it.

ZBrush Custom UI

Customizing Zbrush UI


  1. Preferences/Config/Enable Customize 
  2. Ctrl + Alt + Drag Any Button from Any menu to Zbrush desktop
  3. Brushes Can ONLY be taken from the Brush Menu on the top. not the icons
  4. When Done, CLICK OFF "Enable Customize" Button
  5. Preferences/Config/Save UI 
  6. Name and Save it.

Sunday, September 20, 2015

Noticeable Differences week 6

- 20 minutes on stationary bike, speed 8mph, resistance 3.
- 10 minutes on Rowing Machine, 24spm
- walking up from Civic Center platform no longer makes legs wobbly. I am not as winded either.
- belt down to 2nd notch
- noticed more definition on arms.

Monday, August 3, 2015

Blender -- Cycles Renderer

Cycles Renderer -- Enable


To enable Cycles rendering in Blender:


  1. Select Cycles Render from the 3D View's pulldown.