Last active
February 28, 2024 14:07
-
-
Save quizcanners/6bc0b06172977c1a324e81e626079fb2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// All functions: http://developer.download.nvidia.com/CgTutorial/cg_tutorial_appendix_e.html | |
// Performance | |
// Accessing with "_Name" is slower | |
Shader.SetGlobalFloat("_Name", value); // => | |
int id = Shader.PropertyToID("_Name"); // Once at Start/ OnEnable | |
Shader.SetGlobalFloat(id, value); | |
// Trouble-shooting: | |
// Black Pixels on some devices = Division by zero | |
// Pixelation after running for while = using _Time to modify sampling uv (loss of percision), consider _SinTime, _CosTime | |
// Unity crashing and stuff ... also division by zero. A very common scenario: before you initialized values they are zero, | |
// so if script sets any value intended to be divided by, on the first render frame it may be 0. | |
// Dictionary: | |
y=cos(x) // Returns in range [-1, 1] f(0) = 1 | |
y=sin(x) // Returns in range [-1, 1] f(0) = 0 | |
lerp(a,b,t) // (b*t + a*(1-t)) | |
fmod( x , y ) = x % y | |
frac( x ) = x % 1 | |
_SinTime, _CosTime | |
_SinTime.x == Sin(t/8) | |
_SinTime.y == Sin(t/4) | |
_SinTime.z == Sin(t/2) | |
_SinTime.w == Sin(t) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment