cvr-props/Assets/raymarched/flesh_cube.shader

68 lines
1.5 KiB
Text
Raw Normal View History

Shader "CrispyPin/FleshCube2"
{
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 LIGHT_FN lighting
#define SCENE_SCALE 0.04
#define REFLECTIONS 2
#define DISCARD_ON_MISS
#include "lib/libgarbage.cginc"
#define SPEED 1.5
SurfacePoint main(float3 p) {
Material mRed = mat(.95, 0.1, 0.1, 0.4);
Material mCut = mat(.7, 0.2, 0.1, 0.4);
SurfacePoint d;
// base
float3 bias = -pow(sin(_Time*60 + p.y*0.1), 8)*.5+1.3;
d = mGyroid(p, .5, bias, 0.2, mCut);
float3 gp = p + sin(_Time + p*0.1);
d.dist -= sdGyroid(gp, 1.63, .5, 0.2) * 0.3;
d.dist += sdGyroid(gp, 3.327, 0, 0.2) * 0.1;
d.dist += sdGyroid(gp, 7.351, .5, 0.2) * 0.1;
d.dist -= sdGyroid(gp, 17.351, .5, 0.2) * 0.05;
d.dist -= sdGyroid(gp, 23.521, .2, 0.2) * 0.05;
d = qUnion(d, mSphere(p, 6 + bias*3, mRed), 5);
d = qIntersect(d, mBox(p, 25, mRed));
return d;
}
ENDCG
}
}
}