~shockham/Physo

f58599c9360d3f970d3eeadac1363f6ce6c2de46 — shockham 3 years ago b315600 master
More tweaks to terrain
1 files changed, 8 insertions(+), 7 deletions(-)

M src/shaders/frag.glsl
M src/shaders/frag.glsl => src/shaders/frag.glsl +8 -7
@@ 88,8 88,8 @@ float opDisp(vec3 p, float amt) {

vec2 scene(in vec3 position) {
    vec2 scene = opUnion(
        //vec2(position.y - sdNoiseTerrain(position.xz), 1.0),
        vec2(sdPlane(position), 1.0),
        vec2(position.y - sdNoiseTerrain(position.xz), 1.0),
        //vec2(sdPlane(position), 1.0),
        opUnion(
            vec2(sdSphere(position - vec3(-1.0, 0.4, 0.0), 0.4), 10.0),
            opUnion(


@@ 242,12 242,13 @@ vec3 OECF_sRGBFast(const vec3 linear) {
// Rendering
//------------------------------------------------------------------------------

float floorColor(vec3 pos) {
    float cbSize = 10.0;//2.0 + 6.0 * cos(time);
float floorColor(vec3 pos, float distance) {
    /*float cbSize = 10.0;//2.0 + 6.0 * cos(time);
    return mod(
        floor(cbSize * pos.z) + floor(cbSize * pos.x),
        2.0 * sin(time / 20.0)
    );
    );*/
    return pos.y - distance;
}

vec3 render(in vec3 origin, in vec3 direction, out float distance) {


@@ 283,7 284,7 @@ vec3 render(in vec3 origin, in vec3 direction, out float distance) {

        if (material < 4.0) {
            // Checkerboard floor
            float f = floorColor(position) * distance;
            float f = floorColor(position, distance);
            baseColor = 0.4 + f * vec3(0.2);
            roughness = 0.1;
        } else if (material < 11.0) {


@@ 339,7 340,7 @@ vec3 render(in vec3 origin, in vec3 direction, out float distance) {
            if (indirectHit.y < 4.0)  {
                vec3 indirectPosition = position + indirectHit.x * r;
                // Checkerboard floor
                float f = floorColor(indirectPosition);
                float f = floorColor(indirectPosition, indirectHit.x);
                indirectSpecular = 0.4 + f * vec3(0.6);
            } else if (indirectHit.y < 16.0) {
                // Metallic objects