Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/xjine/unity_shadermatrixhacks

Get some parameters from shader matrix.
https://github.com/xjine/unity_shadermatrixhacks

unity

Last synced: 15 days ago
JSON representation

Get some parameters from shader matrix.

Awesome Lists containing this project

README

        

# Unity_ShaderMatrixHacks

Get some parameters from shader matrix.

```hlsl
float3 cameraForward = -unity_MatrixV._m02_m12_m22;

float3 objectScale = float3(length(unity_ObjectToWorld._m00_m10_m20),
length(unity_ObjectToWorld._m01_m11_m21),
length(unity_ObjectToWorld._m02_m12_m22));

float3 worldPosition = unity_ObjectToWorld._m03_m13_m23;

float4 clipPosition = UnityWorldToClipPos(unity_ObjectToWorld._m03_m13_m23);

float2 viewportPosition = (clipPosition.xy + 1) * 0.5;
viewportPosition.y = 1 - viewportPosition.y;
```