ODOShader

ODOS丨快乐几把猫3d.ver

by ERIN.Z, 2022-02-26


GIF 22-2-26 20-42-11.gif RayMarching基础搞完后迫不及待的第一件事——锵锵!几把猫3D版! 就是SDF建模!直接上代码啦:

//Scene
float f(vec3 p){
    p.x=abs(p.x);
    float d;
    {//face
    vec3 p0 = vec3(p.x*.8,p.y+.4,p.z);
    d = sdSphere(p0,vec3(0),1.5); 
    p0 = vec3(p.x*.6,p.y+.6,p.z+.7);
    float d0 = sdSphere(p0,vec3(0),1.);
    d = smUni(d,d0,.3);
    }
    float angle = sin(iTime*5.)*.1;
    {//ear
    vec3 p0 = vec3(p.x-.85,p.y-.3,p.z*1.2+.3);
    p0.xy *= rotate(-.3);
    p0.yz *= rotate(-.3);
    float d0 = sdRoundCone(p0,.8,.2,1.2)/1.2; 
    d = smUni(d,d0,.3);
    }
    {//nose
    float d0 = sdCapsule(p,vec3(0,0,-1.5),vec3(0,-.6,-1.7),.3); 
    d = smUni(d,d0,.05);
    }
    {//nose
    float d0 = sdSphere(p,vec3(.3,-.6,-1.65),.45); 
    d = smUni(d,d0,.05);
    }
    {//eye
    vec3 p0 = vec3(p.x-.6,p.y+.1,p.z+1.45);
    p0.xy *= rotate(-1.2);
    p0.yz *= rotate(-0.3);
    float d0 = sdRoundCone(p0,.06,.08,.2); 
    d = smUni(d,d0,.05);
    }
    {//
    vec3 p0 = vec3(p.x-.9,p.y+.5,p.z+1.3);
    p0.xy *= rotate(.2+angle*.5);
    float d0 = sdCapsule(p0,vec3(0,0,0),vec3(.8,0,0),.1);
    p0.xy *= rotate(-.4+angle*.5);
    d0 = smUni(d0,sdCapsule(p0,vec3(0,0,0),vec3(.8,0,0),.1),.05);
    d = smUni(d,d0,.05);
    }
    return d;
}

by ERIN.Z

2024 © typecho & elise