Passing light data to shader


#1

Hey all,

I am trying to write a scripted material with maxscript. But I am having problems with passing the light position to the shader.

In the shader itself the position is a float4.

I tried to do it this way

on ddl_Light1Pos selected item do
 	(
 		local temp = getNodeByName ddl_Light2Pos.selected
 		delegate.light1_Position = temp.position
 	)

I then get the error that it has to be of a value of integer. How can that possibly be if the variable in the shader is a float4

I already tried a lot of other stuff but I am not getting some good results. I researched the information on the wiki but I am not finding the way how the position of the light is passed.

Is there a specific way to do this?

Greetings

Nysuatro


#2

Gah I remember this problem, but I don’t remember what we had to end up doing… if you don’t get a response by Monday I’ll ping one of the guys who maintain our shader system (I helped implement the core of it but am out of practice).


#3

Thanks for the help Rob Galanakis. I appreciate it


#4

My solution is not used scripted shaders, made life so much easyer dropping them :slight_smile:

I don’t know if it is realvant but I know the lights are considered as intergers in directx materials in terms of which light you are choosing. So 0 (or 1 can’t remember) is the first light in the scene. I think, to be honest I need my glasses to read exactly what the problem is :slight_smile:


#5

Yes, I tried it with just integers. But the results is not the same as with the default UI of the shader…

How does it work then? You send a integer that represents the element in the array Lights. And the shader declares the position and light color automatically?

I am now using the array Lights to put the names of the lights in the item property of the dropdownlist for the light position. I am just not sure I am doing it the right way.

I was hoping someone could tell me the way it can/has be done.


#6

Owkay. Lightproblem is solved. It has something to do with my countlights that was not resetting …

Well anyway. I got an other question. In the shader there is a mapchannel in the texture variable for like Diffuse Map.
I got a UI element 'spinner ’ in maxscript for that channel. But how can I pas the value of the spinner to the map channel ? I already used the identifier for the texture to pass the bitmap …