Parallax problem, maybe a irrlicht bug?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Justei
Posts: 47
Joined: Fri Aug 20, 2010 11:20 am

Parallax problem, maybe a irrlicht bug?

Post by Justei »

Hello, I tried asking this in the IRC but no1 seems to be able to help me :/.
Some theories in the IRC were that it's actually a irrlicht bug since another user had has this problem but never got it solved...

Anyhow, the problem I have is:

I got a really weird bug, if u don't mind helping me out then check this pastebin:
http://pastebin.com/A0ptCzNf
The odd thing is that the bumpmap and all looks PERFECT, untill I look in the corners or not in the middle, where the map looks all... oily or something, really odd...

This is what it looks like in the corners: http://i41.tinypic.com/bjep3d.png
And this is what it looks like in the middle: http://i39.tinypic.com/wcbfpd.png

As you can tell it looks perfect in the middle, just like I want it, but when you get to the edges or actually anywhere but the center it looks like crap :/... Hopefully you can help me :(
Image
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Re: Parallax problem, maybe a irrlicht bug?

Post by Virion »

I can't see the pic now on my company's PC as it's blocked by firewall. I'll take a look at it once i go back home.
Klunk
Posts: 264
Joined: Mon Jan 10, 2011 5:21 pm

Re: Parallax problem, maybe a irrlicht bug?

Post by Klunk »

looks like some kind of normalize error, possibly something normalized in the vertex shader then interpolated badly in the pixel shader (where it should be normalized but for performance gains it's not). You could Try subdividing the geometry more to reduce the interpolation errors or adding a few normalizes to the pixel shader (if you have access).
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Re: Parallax problem, maybe a irrlicht bug?

Post by shadowslair »

Your result seems more or less correct, plus I don`t think you changed the shader that much from the original. But I dont trust your mesh. You can try to create one Irr plane mesh and use it to be sure. Irrlicht plane normals are always pointing away from the surface:

Code: Select all

scene::IMesh* mesh = smgr->getGeometryCreator()->createPlaneMesh(core::dimension2df(100.0f, 100.0f), core::dimension2d<u32>(10, 10), &someMaterial, core::dimension2df(100, 100));
PS: Blaming irrlicht for your code adventures is a shame. :|
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
Justei
Posts: 47
Joined: Fri Aug 20, 2010 11:20 am

Re: Parallax problem, maybe a irrlicht bug?

Post by Justei »

shadowslair wrote:Your result seems more or less correct, plus I don`t think you changed the shader that much from the original. But I dont trust your mesh. You can try to create one Irr plane mesh and use it to be sure. Irrlicht plane normals are always pointing away from the surface:

Code: Select all

scene::IMesh* mesh = smgr->getGeometryCreator()->createPlaneMesh(core::dimension2df(100.0f, 100.0f), core::dimension2d<u32>(10, 10), &someMaterial, core::dimension2df(100, 100));
PS: Blaming irrlicht for your code adventures is a shame. :|
Well, it wasn't me that came to that conclusion ^^ it was actually a cpl of ppl and me that talked and appairently quite some ppl have had this exact problem and we figured it could be a bug :).
Image
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Re: Parallax problem, maybe a irrlicht bug?

Post by shadowslair »

Do you guys really think are the first ones to try parallax with Irrlicht, so you have disovered a bug? Where exactly is your unwanted behaviour? Are you sure you know what you are doing and what exactly is going on? There`s even a simplistic version in the examples, which works as it should be. So, unless proven the opposite, it`s definitely user mistake. Well, a group of users mistakes I guess. :)
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
Justei
Posts: 47
Joined: Fri Aug 20, 2010 11:20 am

Re: Parallax problem, maybe a irrlicht bug?

Post by Justei »

shadowslair wrote:Do you guys really think are the first ones to try parallax with Irrlicht, so you have disovered a bug? Where exactly is your unwanted behaviour? Are you sure you know what you are doing and what exactly is going on? There`s even a simplistic version in the examples, which works as it should be. So, unless proven the opposite, it`s definitely user mistake. Well, a group of users mistakes I guess. :)
I'm sure it is, and really hope it is, however no one I have talked to on IRC or anywhere seems to have a clue why this is happening :P There's a little difference between my project and the example and that is that the example has a lot smaller object than what I'm trying to use, and when I load that object and do the same, it works nicely, using the exact same code etc.

As far as I can tell its hopefully my mistake, because I would LOVE to see this working as it's something I REALLY want in my project, however it seems to bug out after a being applied to a huge object, since it works on part of it, but later totally bugs out.

I'm not trying to blame Irrlicht for this, I'm trying to figure out if it COULD be a engine bug. Since I have come across those before.
Image
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Parallax problem, maybe a irrlicht bug?

Post by CuteAlien »

To be fair - there can always be a bug in Irrlicht. I found more than one bug in places where I thought that can't be ;-) (for example several crashes which could be reproduced by typing into an editbox...)
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
Justei
Posts: 47
Joined: Fri Aug 20, 2010 11:20 am

Re: Parallax problem, maybe a irrlicht bug?

Post by Justei »

I tried redoing it with a planemesh instead of a object, and have the exact same bug, in some places the parallax bumping is perfect, looks AWESOME. and then in the edges of the model it looks like crap :/.

Tried changing the scales and whatnot, still am unable to get it to work :S...
If someone who actually KNOWS they can get this to work could try making a plane which is, pretty damn big, and apply parallax and NOT get this bug, then I would be very, very, very happy lol...

Edit: Question, could this have something to do with too big textures? Currently the textures we use are 3000x3000 px.
Image
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: Parallax problem, maybe a irrlicht bug?

Post by serengeor »

maybe the npot problems? try 2048x2048. And maybe try tilling textures like someone suggested before (so you wouldn't need to use such big textures).
Working on game: Marrbles (Currently stopped).
Justei
Posts: 47
Joined: Fri Aug 20, 2010 11:20 am

Re: Parallax problem, maybe a irrlicht bug?

Post by Justei »

serengeor wrote:maybe the npot problems? try 2048x2048. And maybe try tilling textures like someone suggested before (so you wouldn't need to use such big textures).
I tried doing that and even a texture as small as somehwere around 512px didn't work correctly, I'm using the textures that come with irrlicht so it's really odd...

This is my current code.

Code: Select all

 
scene::IMesh* earthMesh2 = smgr->getGeometryCreator()->createPlaneMesh(core::dimension2df(500.0f, 500.0f), core::dimension2d<u32>(1, 1), &material , core::dimension2df(1, 1));
        if (earthMesh2)
        {
            //perform various task with the mesh manipulator
            scene::IMeshManipulator *manipulator2 = smgr->getMeshManipulator();
 
            // create mesh copy with tangent informations from original earth.x mesh
            scene::IMesh* tangentSphereMesh2 =
                manipulator2->createMeshWithTangents(earthMesh2);
 
            // set the alpha value of all vertices to 200
            manipulator2->setVertexColorAlpha(tangentSphereMesh2, 200);
 
            sphere2 = smgr->addMeshSceneNode(tangentSphereMesh2);
 
            sphere2->setPosition(pos);
            sphere2->setRotation(vector3df(0,0,0));
            sphere2->getMaterial(0).SpecularColor.set(0,0,0,0);
            sphere2->setDebugDataVisible(EDS_NORMALS);
 
            //
            // load heightmap, create normal map from it and set it
            video::ITexture* earthNormalMap2 = driver->getTexture(bump.c_str());
            if (earthNormalMap2)
            {
                driver->makeNormalMapTexture(earthNormalMap2, 0.0f);
                //sphere2->setMaterialTexture(0,driver->getTexture("data/Textures/Level/crate.jpg"));
                sphere2->setMaterialTexture(1, earthNormalMap2);
                sphere2->setMaterialType(video::EMT_PARALLAX_MAP_SOLID);
            }
            //sphere2->getMaterial(0).MaterialTypeParam = 0.035f;
 
            // adjust material settings
            //sphere2->setMaterialFlag(video::EMF_FOG_ENABLE, true);
 
 
 
            // drop mesh because we created it with a create.. call.
            tangentSphereMesh2->drop();
        }
 
Image
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Re: Parallax problem, maybe a irrlicht bug?

Post by shadowslair »

Ah, I misread that you`re using the build-in EMT_PARALLAX_MAP_SOLID material. Pastebin version is not coloured and is harder to read. Thought you`re using your own shader all the time. My mistake. Never used the build-in shader materials, so I cannot comment on them. Indeed I won`t be surprised if it turns to be a bug. My apoligies. :wink:
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
Justei
Posts: 47
Joined: Fri Aug 20, 2010 11:20 am

Re: Parallax problem, maybe a irrlicht bug?

Post by Justei »

shadowslair wrote:Ah, I misread that you`re using the build-in EMT_PARALLAX_MAP_SOLID material. Pastebin version is not coloured and is harder to read. Thought you`re using your own shader all the time. My mistake. Never used the build-in shader materials, so I cannot comment on them. Indeed I won`t be surprised if it turns to be a bug. My apoligies. :wink:
Np m8, in any case, any way I twist and turn these textures, it wont work on a bigger scale. It seems that it will work if I use a LOT of smaller planes, however that's not really what I want :/...
Image
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: Parallax problem, maybe a irrlicht bug?

Post by serengeor »

Just made a quick test with your code + some other code to make it compile. Does it work for you and is this what you need?
Release.rar - 1.5 Mb

Move around with fps cam (was too lazy to position/rotate it myself :D )
Working on game: Marrbles (Currently stopped).
Klunk
Posts: 264
Joined: Mon Jan 10, 2011 5:21 pm

Re: Parallax problem, maybe a irrlicht bug?

Post by Klunk »

you can't expect a view based shader to work across a huge 4 vert plane, the view direction is calculated in the vertex shader then interpolated values passed
on the inbetween pixels in the pixel shader. With something where the uv look up is based on the view direction which is badly interpolated your going to get strange results, parallax shaders can look pretty odd (smearing around as the view changes) at the best of times. Subdivide the geometry to give the shader more verts to work with.
Post Reply