Notifications
Clear all

[Closed] Light from scripted spotlights not initially showing in viewport

I’ve noticed something weird that happens to me in several versions of Max (haven’t checked all of them, but I think it’s all versions prior to 2017).

When I create any type of spotlight using Maxscript, i.e. freeSpot(), directionalLight(), miAreaLight(), Free_Light(), the lighting does not initially display in the viewport. It’s not a redraw issue; rotating the scene or scrubbing the slider will not cause the lighting to show. And yes, this is with the display set to Realistic. The only way to fix it seems to be to move or rotate the spotlight after creating it. I can undo immediately afterward and the lighting remains visible in the viewport.

This does not appear to be related to a particular display driver. I have checked it with everything on my machine that supports the Realistic display setting.

The issue does not occur with any omnidirectional lights.

My questions are:

  1. Is this only happening to me, or is this a “feature” in all versions of Max prior to 2017?
  2. What could be causing it?
  3. Is there anything I can do in Maxscript to “activate” the light for the viewports?
6 Replies

here’s my quick test, all I did was manually created a Free Spot light, as expected it shows in viewport, I then copied the command from the listener…(that qualifies as a script right ?)

delete the existing light

  1. paste command in listener, Enter…light shows up

  2. create a button with the copied command, hit the button…light shows up…

seems to work, Max 2017, win7…

Two things: First, it isn’t the light object that is failing to show up. It’s the lighting cast from it. Second, the problem does not occur in Max 2017.

I couldn’t find Realistic mode…!!! sorry…

edit: did same test in Max 2016 Realistic mode…light ‘casts’ its effect straightaway…(even with shadows on)

Don’t apologize. Thank you for trying to help!

Hm, it seems to be adding the position that does the trick, so freeSpot() does not work, but freeSpot [x,y,z] does.

Right now I’m working with a script where the lights are position constrained to a helper object, and if I create them with a position and then set the controller, the projected light still doesn’t show. Weird.

(SEVERAL EDITS LATER):

Can’t seem to find a “working solution” that actually works. Would be a lot easier if I knew why this was happening.

I’ll try to post a simplified example of what I’m doing tomorrow…

…okay, this is just really weird.

fn test = (
    viz = point pos:[0,0,0]
    lit = freeSpot()
	
    lit.pos.controller = position_Constraint()
    lit.pos.controller.appendTarget viz 100
    lit.isFrozen = true

    return viz
)

(
    delete objects
    plane length:400 width:400 pos:[0,0,-100]
    viz = test()
)

If I change the initial position value of the viz object to [0,0,1], it works without a problem. But if I then try and reset the value at any point in the function, the light object stops casting a spotlight. Furthermore, if I try and reset the light to the origin within a code block like so…

fn test = (
    viz = point pos:[0,0,1]
    lit = freeSpot()
	
    lit.pos.controller = position_Constraint()
    lit.pos.controller.appendTarget viz 100
    lit.isFrozen = true
	
    return viz 
)

(
    delete objects
    plane length:400 width:400 pos:[0,0,-100]
    viz = test()
    viz.pos = [0,0,0]
)

… it once again will not cast a spotlight. But if I move the position reset outside the block as follows, it works fine.

(
    plane length:400 width:400 pos:[0,0,-100]
    viz = test()
)
viz.pos = [0,0,0]

I should be able to work around this easily enough, but I still want to know why it’s happening. Can anyone help to shed any light on this for me?