Irrlicht weird swapped XYZ to XZY + Grass Shader Problem

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
deadbeef
Posts: 14
Joined: Thu Apr 08, 2010 11:09 am

Irrlicht weird swapped XYZ to XZY + Grass Shader Problem

Post by deadbeef »

Hello.

I would like to ask why irrlicht uses some weird swapped Y <> Z (XZY) axis which gives height as Y axis instead of Z axis as it should.

It messes up most the shaders (even the irrlicht's internal ones like normal map, pseudo parallax, it uses wrong axis (Y not Z) for dot() lighting).

Each other engines i checked are using normal XYZ axis. Is there any way to fix that to Normal ?
Last edited by deadbeef on Fri Apr 09, 2010 7:25 pm, edited 1 time in total.
Bear_130278
Posts: 237
Joined: Mon Jan 16, 2006 1:18 pm
Location: Odessa,Russian Federation

Post by Bear_130278 »

Z is normally a Depth 8))))
Thus....
Do you like VODKA???
Image
Image
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Re: Irrlicht weird swapped XYZ to XZY

Post by randomMesh »

"Whoops..."
deadbeef
Posts: 14
Joined: Thu Apr 08, 2010 11:09 am

Post by deadbeef »

Yes i know what "Normal" is. Im just telling that DirectX and OpenGL uses Z axis as height and its kind of weird that irrlicht swaps it to Y.

I have tested other engines like Ogre, TrueVision and it used Z axis as height and its more correct to position anything in 2D space as XY and set its height as Z in 3D space. Its even more logic.

I have problems with most hlsl shaders and i have to convert all XYZ vectors to XZY to work correct.

It looks like all irrlicht space is rotated by 90 degrees :F
bonsalty
Posts: 120
Joined: Thu Dec 10, 2009 1:30 pm
Location: Budapest,Hungary

Post by bonsalty »

"its more correct to position anything in 2D space as XY and set its height as Z in 3D space. Its even more logic."

It is, thats what I've done in my wrapper, you can do the same. Even TerrainSceneNode uses the x-z for a default plane if Im correct.
Tomi
deadbeef
Posts: 14
Joined: Thu Apr 08, 2010 11:09 am

Post by deadbeef »

Hum. What wrapper ?
Can you tell me more about that ?
bonsalty
Posts: 120
Joined: Thu Dec 10, 2009 1:30 pm
Location: Budapest,Hungary

Post by bonsalty »

I found irrlicht quite impressive, but some functions are not easy to use and you need too much coding.

The ITerrainSceneNode for instance has no handy procedure for setting the terrain height. You can load a jpg from file or you can get an IMesh to manipulate things. I found out, that eventhough you want to load a terrain of size 300x300 it creates a mesh of 192*192 in the case you have a patchsize of 65. The wrapper can handle this issue by creating automaticly a larger texture in memory, so you dont even need to kill your harddrive. Heights can be given by setting a custom grid.

The wrapper can draw 2D polygons. Irrlicht can do this only in OpenGL.

It can create colored contourlines of a surface and vertical contours and contourmaps.

The wrapper can render into different windows and only two lines of code is needed.

It can handle camera movements, like GoForward, Pitch, etc.

Last but not at least, you dont want to put your code into an infinite loop. So its up to you, which window to render and when. Second all the above mentioned functions can be called with 12 lines of code...

[/img]
Tomi
deadbeef
Posts: 14
Joined: Thu Apr 08, 2010 11:09 am

Post by deadbeef »

Ok ok but how did you managed the XZY swap to XYZ ?
You made that globally ?

Btw. Im trying to run that shader:
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=24794

Do anyone has c++ source code for this sample ?
As i can see it uses XY axis instead of irrlicht's XZ and i cant make it look as it should :F
deadbeef
Posts: 14
Joined: Thu Apr 08, 2010 11:09 am

Post by deadbeef »

I have found something like "upVector" is it ok if i change it to vector3df(0,0,1) ?

It should make:
X - horizontal
Y - depth
Z - vertical

But in that way i would need to rotate each node by 90 degree :F
Isnt there any easier/faster way ?
CuteAlien
Admin
Posts: 9930
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Rotate your camera 90°, the world does not care which axis you use for up (and neither do OpenGL or D3D). Sorry default-camera is not to your tastes, but actually Y-up is rather common in 3D. Actually so common that the depth-buffer is even often called z-buffer (as it's going into the screen).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
deadbeef
Posts: 14
Joined: Thu Apr 08, 2010 11:09 am

Post by deadbeef »

Then why shaders are made other way?

Like this one:
http://irrlicht.sourceforge.net/phpBB2/ ... p?p=221252

I tried to run that and i cant make it work correct.
Any (example) help ?
deadbeef
Posts: 14
Joined: Thu Apr 08, 2010 11:09 am

Post by deadbeef »

I dont want to create another thread so i post it here. Its also kind of related to the XYZ axis problem so here it go:

I used the shader i posted before just as it is with simple plane "terrain" and i cant get it work with irrlicht. What am i doing wrong ? Or maybe i have to do it in some special way ?

Could anyone post me an example usage (working) of this shader ?
It would help me to understand that alot.

BTW. I didnt had any problems with PerPixelLighting as you can see on the character.
Last edited by deadbeef on Sat Apr 10, 2010 7:48 pm, edited 1 time in total.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

deadbeef wrote:its more correct to position anything in 2D space as XY and set its height as Z in 3D space. Its even more logic.
Z is Depth, Y is Height. It's always been like that in most 3D graphics engines, including OGRE. Why do you think the Depth Buffer is called the Z Buffer?

EDIT: Didn't read CuteAliens post first, made the same points :oops:
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Kojack
Posts: 67
Joined: Sun Jan 20, 2008 2:39 am

Post by Kojack »

Im just telling that DirectX and OpenGL uses Z axis as height and its kind of weird that irrlicht swaps it to Y.
DirectX and OpenGL can use either. Take a look at the "Coordinate Systems" section of the Direct3D sdk docs, where it shows Y as up, but says some modelling apps use Z as up. Or the D3DXMatrixLookAtRH function where it says "the current world's up, usually [0, 1, 0]".
deadbeef
Posts: 14
Joined: Thu Apr 08, 2010 11:09 am

Post by deadbeef »

Can anyone reply me on the Second question about Shader ?
I already know about Y up axis. There is no need to explain it anymore.

Ok problem solved.
Post Reply