Results 1 to 9 of 9

Thread: GLSL / HLSL Lighting Models

  1. #1

    GLSL / HLSL Lighting Models

    Yet another question for anyone who has working with shaders.

    I am implementing normal mapping in my engine, currently I am passing in my Light Position in world coordiantes, most of the shaders i have seen use eye coordinates for calculating the light direction.

    mostly this is done via

    GLSL
    Code:
    lightDir = (lightPosition - ecPosition).xyz
    where ecPosition is the gl_Vertex transformed into eye space.

    now, I have tried to transform my lightPosition into eye space by

    Code:
    ecLightPos = lightPosition * gl_ModelViewMatrix;
    but this does not produce the result I am expecting, in fact it produces some weird results, the lights seem rotate as well.

    I would rather not have to define my lights in eye coordinates in my app, but as an actual location in the world.


    I hope this makes sense. Anyone got any tips or examples on this.

    Oh as a side note, most of the example shaders don't deal with moving objects, they all seem to assume that an object is at 0,0,0
    <A HREF="http://www.myhpf.co.uk/banner.asp?friend=139328">
    <br /><IMG SRC="http://www.myhpf.co.uk/banners/60x468.gif" BORDER="0">
    <br /></A>

  2. #2

    GLSL / HLSL Lighting Models

    Having read my own post it doesn't really make any sense .

    I have been playing with GLSL the last few days and figured out that most of the demos assume the light position is in object space or the light direction is in object space ( depending on your lighting model), so I'm going to re do my shaders to use that same model and do some stuff on the client to transform the light postion into object space.
    <A HREF="http://www.myhpf.co.uk/banner.asp?friend=139328">
    <br /><IMG SRC="http://www.myhpf.co.uk/banners/60x468.gif" BORDER="0">
    <br /></A>

  3. #3

    GLSL / HLSL Lighting Models

    Fixed the problem, turns out there was an issue with the way the normals were being passed to the renderer.

    Some screen shots





    <A HREF="http://www.myhpf.co.uk/banner.asp?friend=139328">
    <br /><IMG SRC="http://www.myhpf.co.uk/banners/60x468.gif" BORDER="0">
    <br /></A>

  4. #4

    GLSL / HLSL Lighting Models

    very noise!
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  5. #5

    GLSL / HLSL Lighting Models

    I'll second that!

  6. #6
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    GLSL / HLSL Lighting Models

    nice work
    NecroSOFT - End of line -

  7. #7
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    GLSL / HLSL Lighting Models

    Very nice, Dean.

    Can't wait to see how your engine turns out.

    Any time-frame for a public alpha/beta?
    Jason McMillen
    Pascal Game Development
    Co-Founder





  8. #8

    GLSL / HLSL Lighting Models

    not at the moment, since I started writting it, most of the work has been going into the kernel of the engine (window/input support, xml support loading images etc) and the renderer support (OpenGL and DirectX). I have only just got the shader system working, it still needs work on the directX side of things though. But there is no hardware vertex buffer support yet or Framebuffer support, but that is on the way (once I figure it out)

    Then I need to add scene management in, then terrain and networking and physics ... the list goes on...and on ....and on

    It's kinda interesting cos I'm learning move about OpenGL and at the same time learning about Direct3D too. That reminds me I'd better check it still compiles and runs under linux
    <A HREF="http://www.myhpf.co.uk/banner.asp?friend=139328">
    <br /><IMG SRC="http://www.myhpf.co.uk/banners/60x468.gif" BORDER="0">
    <br /></A>

  9. #9

    GLSL / HLSL Lighting Models

    Another thing, this project has got me side tracked..... I should be working on my competition entry..shoud'nt I....
    <A HREF="http://www.myhpf.co.uk/banner.asp?friend=139328">
    <br /><IMG SRC="http://www.myhpf.co.uk/banners/60x468.gif" BORDER="0">
    <br /></A>

Bookmarks

Posting Permissions

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