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
Revolution. Use length(xy) as one of the parameters for any function. | |
Subtract X from SDF - scale it up. | |
max - intersect | |
min - unite | |
lerp(sdf1, sdf2, t) to morph the two |
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
// Article: https://medium.com/@quizcanners/unity-i-have-a-custom-editor-for-every-script-5eddf20fdacc | |
using System.Collections.Generic; | |
using QuizCanners.Inspector; | |
#if UNITY_EDITOR | |
using UnityEditor; | |
#endif | |
public class SomeScript : MonoBehaviour: IPEGI { |
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
inline float3 DetectSmoothEdge(float3 edge, float3 junkNorm, float3 sharpNorm, float3 edge0, float3 edge1, float3 edge2) { | |
edge = max(0, edge - 0.965) * 28; | |
float allof = edge.r + edge.g + edge.b; | |
float border = min(1, allof); | |
float3 edgeN = edge0*edge.r + edge1*edge.g + edge2*edge.b; | |
float junk = min(1, (edge.g*edge.b + edge.r*edge.b + edge.r*edge.g)*2); | |
return normalize((sharpNorm*(1 - border)+ border*edgeN)*(1 - junk) + junk*(junkNorm)); | |
} |
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
// Transparency | |
alpha:fade // Means it is not a glass | |
Tags { "Queue" = "Transparent" "RenderType" = "Transparent" } | |
ZWrite Off | |
Blend SrcAlpha OneMinusSrcAlpha | |
// Adjusting strength of the Normal | |
o.Normal = UnpackNormal(bump0); | |
o.Normal.xy *= wet; | |
o.Normal.z = 1; |
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
public Inspect() | |
{ | |
if ("Object's Transparency:".edit(ref transparency)) | |
RecalculateShaderParameters(); | |
if (transparency != 0.5f && icon.Refresh.Click("Will load default value",25).nl()) | |
transparency = 0.5f; | |
} |
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
public override void OnInspectorGUI() { | |
var controller = (MyMaterialController )target; | |
EditorGUILayout.BeginHorizontal(); | |
EditorGUI.BeginChangeCheck(); | |
controller .transparency = EditorGUILayout.FloatField("Object's Transparency:", controller .transparency); |
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
// https://gist.github.com/hecomi/9580605 | |
//Dirctionary: | |
View Matrix : camera.worldToCameraMatrix | |
// How to project a texture: | |
//cs: | |
projectionMatrix = camera.projectionMatrix * camera.worldToCameraMatrix | |
//vert: |
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
// 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 |
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
// This is a starting point for most effects I make. | |
Shader "Playtime Painter/Effects/Circle" { | |
Properties{ | |
_MainTex("Albedo (RGB)", 2D) = "white" {} | |
[Toggle(_DEBUG)] debugOn("Debug", Float) = 0 | |
} | |
SubShader{ | |
Tags{ |
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
//https://neginfinity.bitbucket.io/ - a blog where I found how to do shadows for raymarched/raytraced primitives. | |
//https://docs.unity3d.com/Manual/SL-UnityShaderVariables.html | |
//https://github.com/TwoTailsGames/Unity-Built-in-Shaders/blob/master/CGIncludes/UnityCG.cginc - Most interesting stuff ;) | |
//https://github.com/TwoTailsGames/Unity-Built-in-Shaders/tree/master/CGIncludes | |
//https://docs.unity3d.com/Manual/SL-Shader.html | |
//http://developer.download.nvidia.com/CgTutorial/cg_tutorial_appendix_e.html | |
//https://unity3d.com/how-to/shader-profiling-and-optimization-tips | |
//https://docs.unity3d.com/Manual/SL-UnityShaderVariables.html | |
//http://www.deepskycolors.com/archive/2010/04/21/formulas-for-Photoshop-blending-modes.html | |
//http://www.iquilezles.org/blog/ |
NewerOlder