Notifications
Clear all

[Closed] UV coordinates to xyz confusion

We used to use the sibl gui which creates a dome and sun from info in an ibl text file.

However this software is now broken. And is a bit outdated now that a hdr can be controlled with the vray dome light.

I would like to create a script where I dont have to keep placing the sun in the viewport but instead the suns position is calculated from the suns uv coordinates in the ibl txt file. Saving me time keep setting up the scene each time I need to use a sun and dome light setup.

I am trying to get my head around how the suns xyz coordinates are calculated from the uv coordinates (location of sun in the hdr) contained within the ibl text file.

I can create a sun at specific coordinates in maxscript and link this to a vray dome light, piece of cake, but how can the suns xyz coordinates be calculated from just uv coordinates contained in the ibl text file?

2 Replies
try (destroydialog X ) catch ()
 rollout X "" (
	 
	spinner u_coord "U:" range:[0.0,1.0,0.5] scale:0.01
	spinner v_coord "V:" range:[0.0,1.0,0.5] scale:0.01
	spinner radius "Radius:" range:[0.0,999999.9,100]
	button createSun "Create sun"
	 
	 on createSun pressed do (
	
		local theta = radtodeg ((u_coord.value + 0.5) * PI * 2)
		local phi = radtodeg (v_coord.value * PI)

		local x = (cos theta) * (sin phi)
		local y = (sin theta) * (sin phi)
		local z = cos phi * -1
		
		point pos:(radius.value * [x,y,z]) wirecolor:yellow
		 
		 
	 )
	 
)
 createDialog X pos:[100,100]

based on this thread

Thanks Serejah that is exactly what I needed.