libgarbage demo update

This commit is contained in:
Crispy 2023-07-29 20:53:35 +02:00
parent ddcfca5b8d
commit 58f266d600
4 changed files with 553 additions and 45 deletions

View file

@ -318,6 +318,134 @@ MonoBehaviour:
maxValue: 1
updateMethod: 1
sampleDirection: 4
--- !u!1 &365616530
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 365616537}
- component: {fileID: 365616536}
- component: {fileID: 365616535}
- component: {fileID: 365616534}
- component: {fileID: 365616532}
- component: {fileID: 365616531}
m_Layer: 0
m_Name: Distorted world
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &365616531
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 365616530}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 990f6f4efb7f4ec98ad99f6dff1bc6f6, type: 3}
m_Name:
m_EditorClassIdentifier:
type: 3
objectId: 7271f6d6-1e8e-4444-8501-e33df2aad6db
--- !u!114 &365616532
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 365616530}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a37fd8d654d5c2840a0ab3a5ad65a5ae, type: 3}
m_Name:
m_EditorClassIdentifier:
spawnHeight: 2.55
useAdditionalValues: 0
syncValues: []
propPrivacy: 1
subSyncs: []
spawnableType: 0
preGeneratedInstanceId:
--- !u!65 &365616534
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 365616530}
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 &365616535
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 365616530}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: d41f18ea246cea60bae44bca806c0728, 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
--- !u!33 &365616536
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 365616530}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &365616537
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 365616530}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -5, y: 2.5, z: 5}
m_LocalScale: {x: 5, y: 5, z: 5}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 11
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &393448822
GameObject:
m_ObjectHideFlags: 0
@ -523,8 +651,11 @@ GameObject:
- component: {fileID: 683266146}
- component: {fileID: 683266145}
- component: {fileID: 683266144}
- component: {fileID: 683266150}
- component: {fileID: 683266149}
- component: {fileID: 683266148}
m_Layer: 0
m_Name: Cube (1)
m_Name: Raymarch Demo scene
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@ -604,6 +735,58 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &683266148
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 683266143}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 990f6f4efb7f4ec98ad99f6dff1bc6f6, type: 3}
m_Name:
m_EditorClassIdentifier:
type: 3
objectId: 19ac0a45-6040-4093-92d0-0499e618a878
--- !u!114 &683266149
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 683266143}
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 &683266150
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 683266143}
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
ikReference: {fileID: 0}
--- !u!1 &695617482
GameObject:
m_ObjectHideFlags: 0
@ -1154,6 +1337,154 @@ MeshFilter:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 884043981}
m_Mesh: {fileID: 4393975565123819156, guid: ef0474244602536ba83b1af50ff39b9a, type: 3}
--- !u!1 &887058541
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 887058545}
- component: {fileID: 887058544}
- component: {fileID: 887058543}
- component: {fileID: 887058542}
- component: {fileID: 887058548}
- component: {fileID: 887058547}
- component: {fileID: 887058546}
m_Layer: 0
m_Name: Nut
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!65 &887058542
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 887058541}
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 &887058543
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 887058541}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: c881d33e96e5ee113a7ca92a93839d15, 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
--- !u!33 &887058544
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 887058541}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &887058545
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 887058541}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -2, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 10
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &887058546
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 887058541}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 990f6f4efb7f4ec98ad99f6dff1bc6f6, type: 3}
m_Name:
m_EditorClassIdentifier:
type: 3
objectId: b6156cfd-0daa-4e22-ace6-220b7ba376bc
--- !u!114 &887058547
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 887058541}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a37fd8d654d5c2840a0ab3a5ad65a5ae, type: 3}
m_Name:
m_EditorClassIdentifier:
spawnHeight: 0.51
useAdditionalValues: 0
syncValues: []
propPrivacy: 1
subSyncs: []
spawnableType: 0
preGeneratedInstanceId:
--- !u!114 &887058548
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 887058541}
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
ikReference: {fileID: 0}
--- !u!1 &950930976
GameObject:
m_ObjectHideFlags: 0
@ -1288,6 +1619,154 @@ MeshFilter:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 950930976}
m_Mesh: {fileID: 4393975565123819156, guid: 955b9c52fc0be3217a2074e1e2169b9d, type: 3}
--- !u!1 &1057832710
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1057832714}
- component: {fileID: 1057832713}
- component: {fileID: 1057832712}
- component: {fileID: 1057832711}
- component: {fileID: 1057832717}
- component: {fileID: 1057832716}
- component: {fileID: 1057832715}
m_Layer: 0
m_Name: spinny+sunset
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!65 &1057832711
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1057832710}
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 &1057832712
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1057832710}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 628e41df70b6f01c9ae6b4499ad54dd6, 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
--- !u!33 &1057832713
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1057832710}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &1057832714
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1057832710}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -1.208, y: 0.33, z: -0.96}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1057832715
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1057832710}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 990f6f4efb7f4ec98ad99f6dff1bc6f6, type: 3}
m_Name:
m_EditorClassIdentifier:
type: 3
objectId: e84233ea-a6bb-4e2d-a550-0d201827fc90
--- !u!114 &1057832716
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1057832710}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a37fd8d654d5c2840a0ab3a5ad65a5ae, type: 3}
m_Name:
m_EditorClassIdentifier:
spawnHeight: 1
useAdditionalValues: 0
syncValues: []
propPrivacy: 1
subSyncs: []
spawnableType: 0
preGeneratedInstanceId:
--- !u!114 &1057832717
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1057832710}
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
ikReference: {fileID: 0}
--- !u!1 &1274159448
GameObject:
m_ObjectHideFlags: 0
@ -1678,7 +2157,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1485771011}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.429, y: 0.221, z: -1.743}
m_LocalPosition: {x: 0.429, y: 0.221, z: 3.69}
m_LocalScale: {x: 19.2, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
@ -1760,13 +2239,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1500710831}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0.009, z: -0.786}
m_LocalRotation: {x: 0.36414537, y: 0, z: 0, w: 0.9313421}
m_LocalPosition: {x: 0, y: 0.67, z: -0.7}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 42.71, y: 0, z: 0}
--- !u!1 &1651833084
GameObject:
m_ObjectHideFlags: 0

View file

@ -63,8 +63,8 @@ Material:
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _MaxDist: 512
- _MaxSteps: 512
- _MaxDist: 100
- _MaxSteps: 256
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1

View file

@ -79,12 +79,6 @@ START_RAYS_IN_SPHERE // TODO: implement
#define SCENE_SCALE 1
#endif
// TODO: implement
#ifndef AMBIENT_OCCLUSION_STEPS
#define AMBIENT_OCCLUSION_STEPS 4
#endif
struct AppData {
float4 vertex : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID

View file

@ -39,48 +39,83 @@ Shader "CrispyPin/LibGarbageExample"
// #define DISABLE_DEPTH
// #define DISCARD_ON_MISS
// #define USE_WORLD_SPACE
#define SCENE_SCALE 0.05
#define STEP_MULTIPLIER 0.8
#define SCENE_SCALE 0.2
#define LIMIT_DEPTH_TO_MESH
#include "libgarbage.cginc"
float3 checkers(float3 p, float3 a, float3 b, float2 size) {
float2 q = p.xz / size;
q = int2(abs(q) + 0.5);
int s = ((q.x + q.y) % 2);
return s * a + (1 - s) * b;
}
float3 floor_col(float3 p) {
return lerp(0.08,
checkers(p - 1, 0.06, 0.12, 2),
smoothstep(64, 0, length(p))
);
}
SurfacePoint main(float3 p) {
Material grass = mat(float3(0.001, 0.1, 0.001), 0.3);
Material dirt = mat(float3(0.1, 0.04, 0.01), 0);
Material metal = mat(0.1, 1);
Material blue = mat(float3(0.05, 0.1, 0.2), 0);
Material floor = mat(floor_col(p));
SurfacePoint d = mPlaneY(p, 0, grass);
d = qIntersect(d, mSphere(p, 9, dirt), 0.5);
d = qUnion(d, mSphere(p - float3(0, 2, 0), 2, metal));
d = qUnion(d, mTorus(rotX(p, _Time * 40 + UNITY_PI / 2), 5, 0.5, blue), 0.5);
d = qUnion(d, mTorus(rotZ(p, _Time * 40 + UNITY_PI / 2), 5, 0.5, blue), 0.5);
d = qUnion(d, mTorus(rotX(p, _Time * 40), 5, 0.5, blue), 0.5);
d = qUnion(d, mTorus(rotZ(p, _Time * 40), 5, 0.5, blue), 0.5);
// small spheres
float3 p2 = abs(rotY(p, -20 * _Time)) - float3(1.5, sin(_Time.y * 5) + 1, 1.5);
d = qUnion(d, mSphere(p2, 0.7, metal), 0.2);
p.y += 2.5;
// Material green = mat(float3(0.05, 0.8, 0.2));
Material mat1 = mat(1, 0.3, 0.1);
// Material mat1 = mat(0.05);
Material helix_glossy = mat(float3(1, 0.2, 0.05), 0.5);
SurfacePoint d;
d =/* qUnion(d, */ mSphere(p - float3(-2, 1, -2), 0.5, mat1)/* ) */;
d = qUnion(d, mTorus(p - float3(0, 1, -2), 0.4, 0.1, mat1));
d = qUnion(d, mLine(p, float3(1.5, 1.5, -2), float3(2.5, 0.5, -2), 0.2, mat1));
d = qUnion(d, mBox(p - float3(-2, 1, 0), float3(0.5, 0.5, 0.8), mat1));
d = qUnion(d, mHexPrism(p - float3(0, 1, 0), 0.5, 0.2, mat1));
d = qUnion(d, qIntersect(mHelix(rotY(p - float3(2, -1, 0), _Time.y), 0.5, 0.2, 0.13, helix_glossy), mBox(p - float3(2, 1, 0), 1.8, mat1),0.05));
d = qUnion(d, mCylinder(p - float3(-2, 1, 2), 0.4, 0.5, mat1));
d = qRound(d, 0.05 * sin(_Time.y));
// d.mat = mat1;
d = qUnion(d, mPlaneY(p, 0, floor));
d = qIntersect(d, mSphere(p, 7, d.mat)); // limit floor size for better performance
return d;
}
SurfacePoint separate_mat(float3 p) {
Material blue = mat(float3(0.05, 0.1, 0.2), 0);
SurfacePoint d = mSphere(p, 1, blue);
return d;
}
float separate_dist(float3 p) {
return main(p).dist;
}
float3 lighting(Ray ray) {
if (ray.missed)
return lRenderSky(ray.dir, normalize(float3(4,2,1)));
float3 sun_dir = normalize(float3(2, 1, -1));
if (ray.missed) {
if (ray.dir.y >= 0) {
return lRenderSky(ray.dir, sun_dir);
} else
{
float3 cam = ray.start;
cam.y += 2.5;
float3 dir = ray.dir;
float3 surface_pos = float3(
cam.x - cam.y / (dir.y / dir.x),
0,
cam.z - cam.y / (dir.y / dir.z)
);
float col = floor_col(surface_pos);
return col * (lSky(float3(0,1,0)) + lSun(float3(0,1,0), sun_dir));
}
}
float3 sun_dir = normalize(float3(4, 2, 1));
float3 col = 0;
col = ray.mat.col * lSun(ray.normal, sun_dir);
float3 col = lSun(ray.normal, sun_dir);
col *= lShadow(ray.hit_pos + ray.normal * SURF_DIST, sun_dir, 50);
col += ray.mat.col * lSky(ray.normal);
return col;
col += lSky(ray.normal);
// col = clamp(col, 0, 1);
// col = smoothstep(0,1,col);
// col = pow(col, 1.3);
return ray.mat.col * col ;
// return col*0.2;
}
ENDCG