I’m trying to find a way to implement ray-casing completely by GLSL, and I was thinking of maybe getting the vertices from the vertex shader into the fragment shader. Then using some kind of algorithm for calculating a shadow.
Heres my shaders;
light.fs;
#version 150
uniform vec2 lightLocation;
uniform vec3 lightColor;
uniform vec3 ambientLight;
vec3 baseColor = vec3(1.0, 1.0, 1.0);
void main() {
vec4 light = vec4(ambientLight, 1);
vec4 color = vec4(baseColor,1);
float distance = length(lightLocation - gl_FragCoord.xy);
float attenuation = 1.0 / distance;
vec4 lColor = vec4(attenuation, attenuation, attenuation, pow(attenuation, 3.0)) * vec4(lightColor, 1);
color += lColor;
gl_FragColor = color * light;
}
light.vs
#version 150
void main(){
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}