added raymarching demo for testing
This commit is contained in:
+18
-3
@@ -1,13 +1,28 @@
|
||||
// shader.frag
|
||||
#version 450
|
||||
|
||||
// Variables
|
||||
layout(location=0) in vec2 vert_uv;
|
||||
layout(location=0) out vec4 frag_color;
|
||||
|
||||
layout(location=0) out vec4 out_color;
|
||||
layout(set=0, binding=0) uniform texture2D tex;
|
||||
layout(set=0, binding=1) uniform sampler tex_smp;
|
||||
|
||||
// Defines
|
||||
#define PI 3.141592
|
||||
#define EPSILON 0.01
|
||||
#define NEAR 0.01
|
||||
#define MAX_STEPS 200
|
||||
|
||||
// Include
|
||||
#include "shapes.cginc"
|
||||
#include "raymarching.cginc"
|
||||
|
||||
void main()
|
||||
{
|
||||
frag_color = texture(sampler2D(tex, tex_smp), vert_uv);
|
||||
// Calculate ray
|
||||
vec3 ro = vec3(0.0, 2, -6.0); // Ray origin
|
||||
vec3 rd = normalize(vec3(vert_uv - vec2(0.5, 0.5), 1.001)); // Ray direction
|
||||
|
||||
// Render
|
||||
out_color = vec4(raymarch(ro, rd), 1);
|
||||
}
|
||||
Reference in New Issue
Block a user