libgarbage: clean up lighting defaults
This commit is contained in:
parent
3005cfc8aa
commit
8ca3dc6e53
3 changed files with 15 additions and 13 deletions
|
@ -285,12 +285,13 @@ SurfacePoint default_material_sdf(float3 p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
float3 default_lighting(Ray ray) {
|
float3 default_lighting(Ray ray) {
|
||||||
float3 sun_dir = normalize(float3(1, 0.5, 0));
|
float3 sun_dir = normalize(float3(1, 0.5, -0.5));
|
||||||
if (ray.missed)
|
if (ray.missed)
|
||||||
return 0.1;
|
return lRenderSky(ray.dir, sun_dir);
|
||||||
float3 col = 0;
|
float3 light = lSun(ray.normal, sun_dir);
|
||||||
col = ray.mat.col * dot(ray.normal, sun_dir);
|
light *= lShadow(ray.hit_pos + ray.normal * SURF_DIST, sun_dir, 50);
|
||||||
return col;
|
light += lSky(ray.normal);
|
||||||
|
return light * ray.mat.col;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // LIBGARBAGE_INCLUDED
|
#endif // LIBGARBAGE_INCLUDED
|
||||||
|
|
|
@ -52,6 +52,9 @@ Shader "CrispyPin/LibGarbageExample"
|
||||||
}
|
}
|
||||||
|
|
||||||
float3 floor_col(float3 p) {
|
float3 floor_col(float3 p) {
|
||||||
|
p = rotY(p, sin(length(p.xz) * 0.2) * 0.2);
|
||||||
|
p.x += smoothstep(0, 0.5, fmod(_Time.x, 1)) * 2;
|
||||||
|
p.z += smoothstep(0.5, 1, fmod(_Time.x, 1)) * 2;
|
||||||
return lerp(0.08,
|
return lerp(0.08,
|
||||||
checkers(p - 1, 0.06, 0.12, 2),
|
checkers(p - 1, 0.06, 0.12, 2),
|
||||||
smoothstep(64, 0, length(p))
|
smoothstep(64, 0, length(p))
|
||||||
|
@ -92,8 +95,7 @@ Shader "CrispyPin/LibGarbageExample"
|
||||||
if (ray.missed) {
|
if (ray.missed) {
|
||||||
if (ray.dir.y >= 0) {
|
if (ray.dir.y >= 0) {
|
||||||
return lRenderSky(ray.dir, sun_dir);
|
return lRenderSky(ray.dir, sun_dir);
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
float3 cam = ray.start;
|
float3 cam = ray.start;
|
||||||
cam.y += 2.5;
|
cam.y += 2.5;
|
||||||
float3 dir = ray.dir;
|
float3 dir = ray.dir;
|
||||||
|
|
|
@ -3,18 +3,17 @@
|
||||||
// common lighting operations
|
// common lighting operations
|
||||||
// --------------------------------
|
// --------------------------------
|
||||||
|
|
||||||
float3 lRenderSun(float3 ray_dir, float3 sun_dir) {
|
float3 lRenderSun(float3 ray_dir, float3 sun_dir, float3 sun_col = float3(0.8, 0.4, 0.1)) {
|
||||||
float alignment = min(acos(dot(ray_dir, sun_dir)), 1);
|
float alignment = min(acos(dot(ray_dir, sun_dir)), 1);
|
||||||
float sun_amount = smax(min(0.03 / alignment, 5) - 0.06, 0, 0.15);
|
float sun_amount = pow(0.025/alignment, 3);
|
||||||
return sun_amount* float3(0.8, 0.4, 0.1);
|
return sun_amount * sun_col;
|
||||||
}
|
}
|
||||||
|
|
||||||
// a basic procedural sky
|
// a basic procedural sky
|
||||||
float3 lRenderSky(float3 ray_dir, float3 sun_dir) {
|
float3 lRenderSky(float3 ray_dir, float3 sun_dir) {
|
||||||
float3 rendered_sun = lRenderSun(ray_dir, sun_dir);
|
float3 rendered_sun = lRenderSun(ray_dir, sun_dir);
|
||||||
// float3 rendered_sun = max(0, pow(dot(ray_dir, sun_dir) + 0.4, 10)-28) * float3(0.8, 0.4, 0);
|
float a = 1 - abs(ray_dir.y);
|
||||||
return float3(0.7, 0.75, 0.8) - abs(ray_dir.y) * 0.5 + rendered_sun;
|
return lerp(float3(0.3, 0.3, 0.7), float3(0.6, 0.7, 0.9), a) + rendered_sun;
|
||||||
// return rendered_sun;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//calculate sky light
|
//calculate sky light
|
||||||
|
|
Loading…
Reference in a new issue