PDA

View Full Version : spherical environment lookup fliped



Olaf Finkbeiner
April 8th, 2009, 17:57
Hi there,
in max 2010 the viewport spherical map reflects upside down.
In the the nvsg its rotated 90 degrees (z to y ...)...
How can i fix this?

Please help....

thx

Olaf

Olaf Finkbeiner
April 8th, 2009, 22:50
I think i found a sollution myself...

I edited(copy first of course) the shader Environment_map_spherical

for upside down:
gamma = asin(v.z);

changed into:

gamma = asin(-1.0 * v.z);


Hmm seems to work... I dont realy know if what i was doing is right so please fell free to correct me...

thx

Olaf

Olaf Finkbeiner
April 8th, 2009, 22:52
in max2010 i had to rotate the raytrace environment in the end by 0.25 or 90 degrees too...

Olaf Finkbeiner
April 9th, 2009, 10:23
now i still have the (urgent) nvsg problem... the reflection is tilted 90 degrees towards the viewer...

thx

Olaf

Olaf Finkbeiner
April 9th, 2009, 11:01
HI there is this the sollution?
i exchanged y and z in the spherical_environment shader at this position in the code:
gamma = asin(v.y);
theta = atan2(v.x, v.z);
Seems to work...

greetings

Olaf

ruediger
April 9th, 2009, 13:34
Different engines use different coordinate systems. Some engines define the z-axis as the up axis, other take y. So if you load your shader in a 'rotated' system, it will take the input from the engine and thus might be rotated. To avoid this trouble, we have several exporters that take the rotation of the target engine into account. In your case you would need a NVSG exporter for that to work.
Your approach to rotate the axes in the shader takes exactly that into account, so this the right workaround for that. However, normally this should be taken care of by the exporter.

Cheers,
Ruediger

Olaf Finkbeiner
April 9th, 2009, 13:49
Hi Rüdiger,
i know about z up and y up...
ok i use custom cgfx to export (i cant find a special nvsg exporter!)
The environment for cubicals seems to work in nvsg!
The same settings for sphericals however does not work... useing the same exporter...
So there is my second "Bug" for your database?
Anyway no big deal as it was a good excersise to learn a tiny bit more metasl....

thx a million!

On that note (spherical environments):
It would be nice to be able to spin/tilt them and even more important to scale the diameter of the environement. In the moment it is infinit .... I will reasearch this myself but help would be appreciated as allways...

Olaf

ruediger
April 15th, 2009, 22:07
That sounds like a challenge to code a new Environment shader. I guess someone can do this ;)

As an inspiration, you can look for a way of how to intersect your reflection direction with a sphere, calculate the intersection coordinate and map it to a texture lookup (using the same technique as the "Environment_map_spherical" shader)

Best Regards,
Ruediger