Hi all.

I have followed the learningwebgl tutorials and have gone over them many times trying different things.

• I have learnt about dot products (angle between 2 vectors)[/*:m:2dzmvpoo]
• I have learnt about a vector being a direction and magnitude(length of a vector)[/*:m:2dzmvpoo]
• I have learnt about what a normal is (perpendicular vector to a plane (and in this case, the center of 3 vertices? right?)[/*:m:2dzmvpoo]
• I have learnt about multiplying colours together to get a mix of colours that represent shading.[/*:m:2dzmvpoo]
• I have learnt that you can get the distance (magnitude) of a vector by doing what is pretty much pythagoras across x,y and z rather than just aČ + bČ.[/*:m:2dzmvpoo]

I have come across a fundamental lack of understanding now and it's time to clear it up so I can progress.

Here is a few questions to start this thread going:
1. A vertex shader does linear interpolation between 3 points to find out all the pixels/points within that plane. The fragment shader processes each of those points which allows us to apply colours to it?[/*:m:2dzmvpoo]
2. I noticed that in the shader files, there is void main() for each one. Can i then assume that these are completely different apart from whatever is declared within the vertex shader is eventually passed through into the fragment shader. [/*:m:2dzmvpoo]
3. From the vertex shader, you are given a triangulated plane (3 vertices) in which you can do some math to... within the shader... to identify which points in the fragment shader need to be multipled with a 50% opaque black in order to cast a sexy shadow?[/*:m:2dzmvpoo]

I really do appreciate any help given. Although not utterly stuck, I find clarification the key to confident progression.

I found this and this seems to help alot. I'll read it tonight and get back to you on any further thoughts: http://archive.gamedev.net/archive/refe ... page2.html

is it possible to write functions in the shader files:

void function_name(param1 type, param2 type){
//
}

kinda thing?

then call them like
function_name(param1 type, param2 type);

Can i have an example of a function if so.
It being made, and it being called.

Your first post is a bit unclear in terms of what you are looking for. That article is a very simplistic type of shadowing, but perhaps that is all you need(?). The common techniques make use of either a stencil buffer or shadow mapping. There are lots of articles online for both, but they are fairly advanced topics.

To answer your last question, you can certainly create functions inside of glsl shaders similar to what you described.