public override Color32 Value(Vector3 dir) { float theta = Mathf.Atan2(dir.z, dir.x); float phi = Mathf.Acos(dir.y); var m_direction = 0; theta += m_direction * Mathf.PI / 180.0f; while (theta < -Mathf.PI) { theta += Mathf.PI + Mathf.PI; } while (theta > Mathf.PI) { theta -= Mathf.PI + Mathf.PI; } float dx = theta / Mathf.PI; float dy = phi / Mathf.PI; dx = dx * 0.5f + 0.5f; int px = (int)(dx * src.w); if (px < 0) { px = 0; } if (px >= src.w) { px = src.w - 1; } int py = (int)(dy * src.w); if (py < 0) { py = 0; } if (py >= src.w) { py = src.w - 1; } Color32 col = src.Value(px, src.w - py - 1, Vector3.zero); return(col); }
public override Color32 Shade(Vertex p) => texture.Value(p.uv.X, p.uv.Y, Vector3.One);