- //cam stuff
- float near = 1.0;
- float far = 100.0;
- float fov = 60.0;
- float asp = resolution.x/resolution.y;
- float half_height = near*tan(fov*0.5*half_pi);
- float half_width = half_height*asp;
- vec2 projPlane = vec2(half_width*2.0, half_height*2.0);
- ...
- void main(){
- vec3 camPos = vec3(0.0, 0.0, 4.0);
- vec3 pixel = vec3(-projPlane/2.0+(gl_FragCoord.xy/resolution.xy)*projPlane, camPos.z-near); //ray origin auf die nearplane setzen
- vec3 rayDir = normalize(pixel-camPos);
- ....raycasting
- }