Skip to content

Instantly share code, notes, and snippets.

@d4rkc0d3r
d4rkc0d3r / InverseProjectionMatrix.shader
Last active May 17, 2025 22:46
Sample shader to show how to fixup the unity_CameraInvProjection matrix to work correctly
Shader "d4rkpl4y3r/Debug/Inverse Projection Matrix"
{
Properties
{
_UseTrueInverse("Use True Inverse", Range(0, 1)) = 0
}
SubShader
{
Tags { "Queue"="Geometry" }
#if UNITY_EDITOR
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEditor;
using System.Linq;
public class MeshVRAMSize : EditorWindow
{

Here is what I learned about unity skinned meshes and blendshapes and how they are dealt with on the GPU.
I use Nvidia Nsight Graphics to profile performance and read buffer sizes on GPU. Performance numbers are for a 4090 clocked at 2310 MHz core and stock memory. Unity version is 2019.4.31f1

TLDR

For Unity 2019 Split meshes with blendshapes into two meshes, one for blendshapes and one without.

This does not help much with the memory usage, but it does help a lot with performance. The only VRAM savings is one less copy of POSITION, NORMAL, TANGENT.

For Unity 2021+ merge skinned meshes regardless of if they have blendshapes. No more extra copies and it always uses a fast compute shader now for the bone skinning.

Shader "d4rkpl4y3r/RayMarching/Shpere Cut"
{
Properties
{
_Radius("Radius", Float) = 1
_Frequency("Frequency", Float) = 10
_PositionNoise("Position Noise", Range(0,1)) = .5
_MaxDist("Max View Distance", Float) = 150
[Gamma] _Metallic ("Metallic", Range(0, 1)) = 0
_Smoothness ("Smoothness", Range(0, 1)) = 0