Results 1 to 5 of 5

Thread: Shadows in WebGL

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    13

    Shadows in WebGL

    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.

    Thanks in advance!

  2. #2
    Junior Member
    Join Date
    Feb 2012
    Posts
    13

    Re: Shadows in WebGL

    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.

  3. #3
    Junior Member
    Join Date
    Mar 2012
    Posts
    12

    Re: Shadows in WebGL

    You should look for explanations about Shadow Map(ping).

  4. #4
    Junior Member
    Join Date
    Oct 2010
    Posts
    23

    Re: Shadows in WebGL

    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.

  5. #5
    Junior Member
    Join Date
    Feb 2012
    Posts
    13

    Re: Shadows in WebGL

    Do you have an example so I can get the syntax right?

Similar Threads

  1. Lighting - Lioght Obstruction And Shadows
    By LordAshes in forum Developers Coding:Advanced
    Replies: 8
    Last Post: 03-08-2012, 06:16 AM
  2. DEPTH BASED SHADOWS?
    By piezas in forum WebGL - General
    Replies: 2
    Last Post: 01-11-2010, 12:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •