Sign in to follow this  
Ludal

HLSL parser in 3DSMAX and lights

Recommended Posts

Ludal    100
Hi all !
I have a weird problem with 3DSMAX hlsl parser (it's not the first one - and certainly not the last -, but this time I'm stuck...). In my opinion it doesn't work the way it's supposed to (as described in MAX's help) :
so what I'm simply trying to do is getting back a 3DSMAX light description into my home-made DirectX shader, which is linked to a MAX material applied on an object. I would like to get light direction, position, color, etc... Stunning isn't it :wink: ? But the fact is that I haven't managed to do so yet...

As explained in MAX's help, I can build a compact UI using "refID/LightRef" annotations (ahh SAS...) : one component of the light description, say the direction, is defined as the "parent" (using refID) and has UI, and all the other components are "linked" to this parent (using LightRef) and therefore do not need UI. It works well for instance when dealing with direction and light color. But when it comes to get back light position, it doesn't work any longer... :(

Here is a macro I'm using to declare a light in a FX file shared between MAX and my DirectX application :
[code]
#define EXPOSED_DIRECTIONAL_LIGHT(param, NameUI, lightIndex, default) \
float3 param : Direction \
< \
string UIName = NameUI; \
string Object = "TargetLight"; \
string Space = "World"; \
int refID = lightIndex; \
> = default; \
\
float4 param##Pos : POSITION <int LightRef = lightIndex; string UIWidget = "None";> = { 0.0f, 0.0f, 0.0f, 1.0f }; \
\
float4 param##Color : LIGHTCOLOR <int LightRef = lightIndex; string UIWidget = "None";> = { 1.0f, 1.0f, 1.0f, 1.0f }; \
float4 param##Attenuation : Attenuation <int LightRef = lightIndex; string UIWidget = "None";> = { 20.0f, 30.0f, 0.0f, 100.0f}; \
float param##Hotspot : HotSpot <int LightRef = lightIndex; string UIWidget = "None";> = { 43.0f }; \
float param##Falloff : FallOff <int LightRef = lightIndex; string UIWidget = "None";> = { 45.0f }
[/code]

I've tried a few things (using ParentRef instead of LightRef, changing the order of direction/position, etc...) but never managed to get the results I'm expecting. I know for sure the shader which interprets this data is correctly written as if I remove the link between position and direction, add UI for position and choose the same scene's light for Direction and Position I get the expected render (btw I want to get direction and position at the same time as I want to handle directional lights with attenuation).

Has anyone of you guys already tried to do that and managed to find a solution or is it definitly a bug ?
Thanks a lot,
Cheers.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this