create loops shader

This commit is contained in:
Crispy 2024-08-10 12:36:47 +02:00
parent 9f349f3616
commit 6d3ec4a19b
5 changed files with 340 additions and 4 deletions

View file

@ -143,7 +143,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 0
--- !u!114 &34125274 --- !u!114 &34125274
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -971,6 +971,162 @@ MonoBehaviour:
autoHold: 0 autoHold: 0
updateWithPhysics: 1 updateWithPhysics: 1
ikReference: {fileID: 0} ikReference: {fileID: 0}
--- !u!1 &649783669
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 649783676}
- component: {fileID: 649783675}
- component: {fileID: 649783674}
- component: {fileID: 649783673}
- component: {fileID: 649783672}
- component: {fileID: 649783671}
- component: {fileID: 649783670}
m_Layer: 0
m_Name: Loops
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &649783670
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 649783669}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 990f6f4efb7f4ec98ad99f6dff1bc6f6, type: 3}
m_Name:
m_EditorClassIdentifier:
type: 3
objectId: dfb56a47-2b0b-4814-a4b0-950b5054b182
randomNum: 67679218
unityVersion: 2021.3.41f1
cckVersion: 3.10:132
--- !u!114 &649783671
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 649783669}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a37fd8d654d5c2840a0ab3a5ad65a5ae, type: 3}
m_Name:
m_EditorClassIdentifier:
spawnHeight: 0.55
useAdditionalValues: 0
syncValues: []
propPrivacy: 1
subSyncs: []
spawnableType: 0
preGeneratedInstanceId:
--- !u!114 &649783672
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 649783669}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 12974925555b471580cacf5d2d5fa9e3, type: 3}
m_Name:
m_EditorClassIdentifier:
gripType: 1
gripOrigin: {fileID: 0}
disallowTheft: 0
maximumGrabDistance: 0
snappingReferences: []
autoHold: 0
updateWithPhysics: 1
ikReference: {fileID: 0}
--- !u!65 &649783673
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 649783669}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &649783674
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 649783669}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 9b56aa45e08ccf734bbd734558ade0af, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!33 &649783675
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 649783669}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &649783676
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 649783669}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.005, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 15
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &683266143 --- !u!1 &683266143
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1600,7 +1756,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 0
--- !u!114 &853608960 --- !u!114 &853608960
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -3094,7 +3250,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 0
--- !u!114 &2089314930 --- !u!114 &2089314930
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -3222,7 +3378,7 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2089314929} m_GameObject: {fileID: 2089314929}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.005, y: 0, z: 0} m_LocalPosition: {x: -1.255, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []

View file

@ -0,0 +1,84 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: loops
m_Shader: {fileID: 4800000, guid: 5c08f7418862453488eeb85bc14f45fd, type: 3}
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints:
- _MaxSteps: 128
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _MaxDist: 128
- _MaxSteps: 128
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _SurfDist: 0.01
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9b56aa45e08ccf734bbd734558ade0af
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,79 @@
Shader "CrispyPin/Loops"
{
Properties
{
[Header(Raymarcher Properties)]
_MaxSteps ("Max steps", Integer) = 128
_MaxDist ("Max distance", Float) = 128
_SurfDist ("Surface distance threshold", Range(.0001, .05)) = .001
}
SubShader
{
Tags { "RenderType"="Opaque" }
Cull Front
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
int _MaxSteps;
float _MaxDist;
float _SurfDist;
#define MAX_STEPS _MaxSteps
#define MAX_DIST _MaxDist
#define SURF_DIST _SurfDist
#define SCENE_FN main
#define SCENE_SCALE 0.04
#define DISCARD_ON_MISS
#include "lib/libgarbage.cginc"
float flatsin(float t, float period = 2, float transition = 0.5, float bias = 0) {
// period 2
// smoothstep(0.25, 0.75, abs(mod(x -0.75, 2) - 1))
// period 4
// smoothstep(0.75, 1.25, abs(mod(x -1.25, 4) - 2))
float start = (period/2-transition)/2;
return smoothstep(start - bias, start + transition - bias, abs(fmod(t - start - transition - bias, period) - period/2));
}
SurfacePoint Loop(float3 p, Material m = DEFAULT_MAT) {
return qSub(mBox(p, float3(2,4,6), m), mBox(p, float3(4,2,4)));
}
Material lCol(float t) {
Material mA = mat(1, .5, .2);
Material mB = mat(.2, .5, 1);
return mixMat(mA, mB, flatsin(t, 6, 0.5, 1));
}
SurfacePoint main(float3 p) {
SurfacePoint d;
float t = _Time.y;
Material mA = mat(1, .5, .2);
Material mB = mat(.2, .5, 1);
Material mCenter = mixMat(mA, mB, flatsin(t, 3, 0.5, .25));
d = Loop(p -float3( 0, 0,flatsin(t )*8 -4),mCenter);
d = qUnion(d,Loop(p.yzx-float3( 0, 4,flatsin(t+1.5)*8 -4),lCol(t+2.5)));
d = qUnion(d,Loop(p.zxy-float3( 4, 4,flatsin(t+1 )*8 -4),lCol(t+2)));
d = qUnion(d,Loop(p -float3( 4, 4,flatsin(t+1.5)*8 ),lCol(t+1.5)));
d = qUnion(d,Loop(p.yzx-float3( 4, 0,flatsin(t+1 )*8 ),lCol(t+1)));
d = qUnion(d,Loop(p.zxy-float3( 0, 0,flatsin(t+0.5)*8 ),lCol(t+0.5)));
d = qUnion(d,Loop(p.yzx-float3( 0,-4,flatsin(t+1.5)*8 -4),lCol(t-0.5)));
d = qUnion(d,Loop(p.zxy-float3(-4,-4,flatsin(t+1 )*8 -4),lCol(t-1)));
d = qUnion(d,Loop(p -float3(-4,-4,flatsin(t+1.5)*8 -8),lCol(t-1.5)));
d = qUnion(d,Loop(p.yzx-float3(-4, 0,flatsin(t+1 )*8 -8),lCol(t-2)));
d = qUnion(d,Loop(p.zxy-float3( 0, 0,flatsin(t+0.5)*8 -8),lCol(t-2.5)));
return d;
}
ENDCG
}
}
}

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 5c08f7418862453488eeb85bc14f45fd
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant: