Jump to content
  • Advertisement
Sign in to follow this  

HLSL parser in 3DSMAX and lights

This topic is 2578 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 :

#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 }

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,

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!