1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Projected lighting for track objects

Discussion in 'Racer' started by Tiberius, Jan 12, 2010.

  1. I've been trying to get the projected car light shaders working for track objects, for some working floodlights on a nighttime version of a track I'm doing.

    What I've been trying to do is assign the actual shader to a cube (used as a dummy really), have tried getting the shader to input a fall-off factor, location and normal (this is what Racer would input for car lights?), just to see if I can get anything resembling a projected light working. I'm having no luck at all actually getting it to work, from what I can understand from the shader it's expecting diffuse map on layer0 and projected texture on layer 1 (both the same thing, surely?), I just want to be able to get a light to emit from the centre of a dummy object and be able to alter the direction of it (just point downwards probably, as most lights would)

    Has anyone had any luck at this who can give me a hint? :)
     
  2. Long time no speak Tib. ;)

    I played with this a looooong time ago, need to get back into the shader side of stuff, for the past year or so I've mainly been modelling/texturing/etc. but soon, hopefully, I'll be able to cut the edge again so to speak.

    Anyway, your question:
    Projected (head)lights actually need to use a camera to project the image. This is where I got stuck, I couldn't figure out how to transform the camera (since there was only 1 in the scene at that point) to the position I wanted it to be in.

    I'm still not sure what I did, I've probably lost my progress since it was negligible but I'll have a look when I have some time.

    Basically you need to create a camera, which is essentially a matrix, but I have no idea on how they're constructed in both racer and CG. (2 different definitions IIRC)

    Hope this helps.

    Cam
     
  3. Hi Cam, nice to see you around again :)

    Grrr, that's why it's not been working for me then, the actual colour parts of the shaders are fine but matrices and stuff are pretty much beyond my understanding

    If you (or anyone else?) can get it working, I'd be really interested, otherwise I've got a large part of a nighttime speedway track modelled here with lots of models which would be pretty useless without projected lighting, another dead end :-/
     
  4. If I remember correctly, I have a lot of senior moments, when I redid Shutoko which is a night track with street lights, I made a cone and used a glass type texture and then used a glass shader that controled the illumination of the cone.

    Worked quite nicely.
     
  5. Hi Boomer. Yeah, the lights on Shutoko looked fine back then but you can't make the edges of the light beam soft and they look bad when you get close. I really wanted a way to do projected lights that would overlay objects.

    Doesn't matter, I doubted whether that sort of thing could work properly in racer anyhow.
     
  6. Stereo

    Stereo
    Premium Member

    Well, you can -

    Change the alpha mix on the last line of the _f shader:

    outColor.a=baseCol.a;

    outColor.a=baseCol.a*dot(normalize(IN.I),N);

    IN.I might be slightly different in certain shaders, but the point is to take the dot product of the "eye" with the surface normals (N), so if it's perpendicular it's 0 (therefore transparent).
     
  7. Thanks Stereo, I'll give it a try :)