View Full Version : How do I get a light to sample a point from a ramp instead of projecting the ramp?

04 April 2009, 04:10 PM
Hi there, I've come up against a brick wall in MAYA (2008)

I want a light to read in a colour from a ramp (or 3D proj texture map of a ramp) so that the light emits the colour of the ramp at the point that the ramp and the light intersect.

Sounds simple, right? Just connect the ramp to the light?
Not so, the 3d projection works like an image projector - projecting the whole range of the ramp - in this case a multicoloured gradient.

This is probably because the light gets the projection information well before it looks at its position in space. I need a way around this.

Basically the real-world problem is:

I have lightbulb geometry running up the outside of a fairground attraction, the nurbs 'lightbulbs' get their colour from a standard 3d projection of a ramp node, the 3Dproj node is animated so the colours of the lights seem to roll up the ride over time.

I want them to emit light without using Global Illumination - so conneted the ramp to the point lights - but the point lights don't pick up the colour properly, they just project the whole ramp and each light emits a stripey gradient.
Really I want the red 'lightbulb' and its point light to emit red, the blue ones blue and green = green.

So I want something which samples the colour of the nurbs bulb or the point on the gradient where the light crosses it and push that through the light.

I can't EASILY do it via animation curves in the lights' colour attribute because there are a lot of them and + all their animCurves would need offsetting by 1 or 2 frames to match the ramp gradient (I probably can do it manually that way, but it will take ages). That wouldn't match the nurbs bulbs either, and getting the output of the light colour into every bulb at that point would probably be just as messy.

Any ideas?
How would you do it?

I believe there's a way to do it in Max called 'RayEx'. You define a point in space (the light) and a vector (usually down). It then returns a point on a poly surface, and from that you can derive the UV cords, and then from that the pixel colour in a bitmap.

Something like that, or a nifty hypershade trick would be ideal.


04 April 2009, 10:53 PM
Have you tried animating in the attribute spread sheet?

Also, why are you projecting a ramp onto the lightbulb geo shader instead of just mapping it straight?

05 May 2009, 01:07 AM
I've been wrestling with this for awhile and I'm interested to see if there is an answer to this. The instance I'd like see is the case of sampling points with spotlights located on a textured sky dome so the color will change dynamically with the sky's texture.

05 May 2009, 07:27 PM
Exactly - that's almost the same situation (mapping sky lights).

I've only got a minute to answer as I'm not at home - but the reason for not mapping directly is in the op. Apologies for not going into more detail.

CGTalk Moderation
05 May 2009, 07:27 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.