This file contains 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
// example of how to move a current value towards a target value at a constant speed | |
// without going over the target value | |
// formula is the same for vectors of any dimension | |
Vector3 Seek(Vector3 currentValue, Vector3 targetValue, float maxSpeed, float dt) | |
{ | |
// delta/difference from current value to target value | |
Vector3 delta = targetValue - currentValue; | |
// don't take the square root of magnitude yet | |
// so we can potentially early out on degenerate case of currenvValue ~= targetValue |
This file contains 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
Vector3 inputVec = Vector3.zero; | |
if (Input.GetKey(KeyCode.UpArrow)) | |
inputVec += Vector3.up; | |
if (Input.GetKey(KeyCode.DownArrow)) | |
inputVec += Vector3.down; | |
if (Input.GetKey(KeyCode.LeftArrow)) | |
inputVec += Vector3.left; |
This file contains 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
float3 quantize(float3 p, float cellSize, float strength) | |
{ | |
float3 r = p / cellSize; | |
float3 f = floor(r); | |
float3 t = r - f; | |
return (f + smoothstep(0.0f, 1.0f, strength * (t - 0.5f) + 0.5f)) * cellSize; | |
} |
This file contains 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
string rpAsset = ""; | |
if (GraphicsSettings.renderPipelineAsset != null) | |
rpAsset = GraphicsSettings.renderPipelineAsset.GetType().Name; | |
if (rpAsset.Equals("HDRenderPipelineAsset")) | |
renderPipeline = RenderPipeline.HDRP; | |
else if (rpAsset.Equals("UniversalRenderPipelineAsset")) | |
renderPipeline = RenderPipeline.URP; | |
else | |
renderPipeline = RenderPipeline.BuiltIn; |
This file contains 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
bool (*functions[])() = | |
{ | |
Function0, | |
Function1, | |
Function2, | |
}; | |
bool LogicalAnd() | |
{ | |
for (auto f : functions) |
OlderNewer