Feat: added compile error output for shaders and implementet first ray
march
This commit is contained in:
31
sdf.fs
31
sdf.fs
@@ -1,9 +1,36 @@
|
||||
R"###(
|
||||
#version 330 core
|
||||
|
||||
out vec4 FragColor;
|
||||
in vec2 texCoords;
|
||||
|
||||
vec3 center = vec3(0.0f,0.0f,20.0f);
|
||||
float radius = 5.0f;
|
||||
|
||||
float sphereMin(vec3 pos){
|
||||
return length(pos - center) - radius;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = vec4(1.0f, 0.5f, 0.2f, 1.0f);
|
||||
vec3 ray = vec3(texCoords.x, texCoords.y,2.0f);
|
||||
ray = (ray - 0.5f) * 2;
|
||||
vec3 pos = ray;
|
||||
float min = sphereMin(ray);
|
||||
|
||||
while( (min < 100.0f) && (min > 0.1f) ) {
|
||||
ray = normalize(ray);
|
||||
ray = ray * min;
|
||||
pos = pos + ray;
|
||||
min = sphereMin(pos);
|
||||
}
|
||||
|
||||
|
||||
if(min <= 0.2f){
|
||||
FragColor = vec4(texCoords.x, texCoords.y, 0.2f, 1.0f);
|
||||
} else {
|
||||
FragColor = vec4(0.0f,0.0f,0.0f,1.0f);
|
||||
}
|
||||
|
||||
}
|
||||
)###";
|
||||
)###";
|
||||
|
||||
Reference in New Issue
Block a user