Passing vectors from Vertex to Fragment

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;
}

old: varying
new: in & out
alltime: google

Thanks!, but is there a good example of this somewhere? Because everywhere I look I find some complicated-C++ stuff.

Also: Sorry for the wrong thread, really. My bad!

The C++ code isn’t relevant, just look at GLSL examples?

Alright, will do!

here is a bit of an example…



#version 410


uniform mat4 	in_projectionMatrix;
uniform mat4 	in_cameraMatrix;
uniform mat4    in_modelMatrix;
layout(location = 0) in vec3 vp;
layout(location = 1) in vec3 np;

out vec3 pass_normal;
out mat4 pass_cameraMatrix;

void main () {
    vec4 vertex = vec4(vp, 1.0);
    gl_Position = 	in_projectionMatrix * in_cameraMatrix * in_modelMatrix * vertex;
    pass_normal = np;
    pass_cameraMatrix = in_cameraMatrix;
   
    
}


#version 410

in  vec3 pass_normal;
in  mat4 pass_cameraMatrix;
out vec4 frag_colour;







void main(){
	//frag_colour = vec4(0.5, 0.0, 0.5, 1.0);
	vec4 colour = vec4(pass_normal, 1) * pass_cameraMatrix;
	//frag_colour = vec4(0.1,0.1,0.1,1) * colour;
	frag_colour = colour;
	
}