• NFT
  • Explore
  • Challenge
Sign in Sign up
Create Art arrow_drop_down
settings
Templates Resources
help CANCEL
Save as...
xxxxxxxxxx
45
 
1
precision highp float;
2
​
3
uniform vec2 resolution;
4
uniform float time;
5
uniform vec2 mouse;
6
uniform sampler2D backbuffer;
7
​
8
vec2 map(vec3 p){
9
    vec2 o = vec2(10.,0.);
10
    
11
    o.x = length(p) - 1.;
12
    return o;
13
}
14
​
15
vec2 march(vec3 cp , vec3 rd){
16
    float depth = 0.;
17
    for(int i = 0 ; i < 99; i++){
18
        vec2 d = map(cp + rd * depth);
19
        if(abs(d.x) < 0.001){
20
            return vec2(depth , d.y);
21
        }
22
        depth += d.x;
23
    }
24
    return vec2(-depth);
25
}
26
​
27
void main(void) {
28
    vec2 p = (gl_FragCoord.xy * 2.0 - resolution.xy) / min(resolution.x, resolution.y);
29
    
30
    vec3 cp = vec3(0.,0.,-5.);
31
    vec3 target = vec3(0.,0.,0.);
32
    vec3 cd = normalize(target - cp);
33
    vec3 cu = normalize(vec3(0.,1.,0.) );
34
    vec3 cs = normalize(cross(cu,cd));
35
    
36
    float fov = 2.5;
37
    vec3 rd = normalize(cs * p.x + cu * p.y + cd * fov);
38
    vec3 color = vec3(0.);
39
    
autorenew