Projected lighting for track objects

T

Tiberius

  • Tiberius

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? :)
 
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
 
  • Tiberius

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 :-/
 
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.
 
  • Tiberius

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.
 
you can't make the edges of the light beam soft

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).
 

Latest News

How long have you been simracing

  • < 1 year

    Votes: 362 15.8%
  • < 2 years

    Votes: 254 11.1%
  • < 3 years

    Votes: 245 10.7%
  • < 4 years

    Votes: 181 7.9%
  • < 5 years

    Votes: 303 13.2%
  • < 10 years

    Votes: 260 11.3%
  • < 15 years

    Votes: 166 7.2%
  • < 20 years

    Votes: 129 5.6%
  • < 25 years

    Votes: 99 4.3%
  • Ok, I am a dinosaur

    Votes: 296 12.9%
Back
Top