Parallax mapping messing with totally unreleated textures

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!
Post Reply
Dott. Agasa
Posts: 11
Joined: Sat Jun 30, 2007 6:50 pm

Parallax mapping messing with totally unreleated textures

Post by Dott. Agasa »

Hello, i'm asking for help on an elusive and seemingly irrational bug that bugs me.
First, some background:
I'm writing an adventuregame engine based on irrlicht (for the graphics) and game monkey (for the scripting).
It's pretty meaningless to post code becouse i should write some tonnes of it to explain the things right, but i posted the most interesting parts here in the pastebin: http://pastebin.com/fdb310ac
I needed to implement parallax mapping and other materials for my models, dynamically from the .
I have some arrays that contain PG (player/NPC) structures, and object (in the sense of "a door" like object, not the C++ sense) structures, that contain a mesh, a node and some additional things. further, i have a single node and a single mesh that are the loaded room, an array of textures for access within scripts, and some assorted other things like collision models etc.
I wrote a bunch of subs to bind (that is, to make avaible to use in the scripting language) for game monkey.
The problem is, i done a bunch of subs for manipulating materials generally for all this assorted meshes and nodes and i wanted to test parallax mapping on rooms but got strange problems...
As soon as i enable the parallax on the room node, all my textures, and i mean all of them, gui, cursor, all, of them, get "fused" with the bump texture of the model, like it was theyr alpha channel. it's
if you want some explanation for the poorly commented and messy code, i'm more than willing to give it.
for your reference, each sub starts with a bunch of GM_CHECK_INT_PARAM(variablename, IDnumber) or similar, that is a macro that checks the script passed argument with that ID is (in this case) an integer, and puts it in a variable with that name. GM_CHECK_NUM_PARAMS(paramnum) checks if the number of script passed argument is equal to paramnum. Both macros return an error if the conditions are not met, and GM_CHECK_NUM_PARAMS is optional if you want an whatever-number-of-arguments-function.
objchar is the first parameter of the called sub from script, and is a flag that gets 1 if the array is the one of objs, 0 if the selected thing is a pg, and whatever else for the currently loaded room.
selnum is the array number, if you selected a pg or obj. it does not mean anything if you selected the loaded room.
selmat, is the selected material and sellay is the selected layer.
only the material type screws things up. other material properties does not influence the bug.
i call the setup for the texture one time in global init then i setup room, obviously, every time that room is loaded. if i put that material type for the room, that is EMT_PARALLAX_MAP_SOLID, it screws things.
when i disable parallax mapping, or change room (thus, reloading all and disabling parallax mapping) the problems vanishes and every texture returns to normal. if i disable manually (that is, calling a script on the fly using a hotkey that i set up) the parallax mapping, setting the room to EMT_SOLID, the problem vanishes too.
using a moving light, that flies in circle, i seen the "shadows" blended on the textures in the gui oscillate in intensity following the moving of the light. they seem an alpha blend copy of the parallax map. if i rotate the player and the camera follows, i see the "shadows" oscillate, blink, get completely black, and, sometimes, vanish and all behaves normally until i move again.

this problems are obviously linked with the parallax map. i just cannot pinpoint what problem is there. it's pretty irrational.

I hereby post some screenshots to help you. thank you for reading all of that, and excuse me for my poor english. i hope that someone is generous enough to help me, i'm in a pinch.

EDIT: i tried EMT_LIGHTMAP, EMT_LIGHTMAP_ADD and EMT_DETAIL_MAP. Altrough they tinge the mesh with respectively different eerie blue and cyan colors, they dont give any problems with other textures.

SCREENSHOTS:

Here i'm in a room other than the parallax-problems one and it'all normal. i post it for reference:
Image

Here i'm in the problematic room, and you see the gui and the cursor are blended with the parallax map:
Image

Here i'm in the problematic room, and the camera is rotated-positioned in a "lucky" position where all appears normal, until...
Image

...i rotate the camera again and all the gui gets PITCH BLACK. help me...
Image
Last edited by Dott. Agasa on Sat May 10, 2008 6:47 pm, edited 2 times in total.
Frosty Topaz
Posts: 107
Joined: Sat Nov 04, 2006 9:42 pm

Post by Frosty Topaz »

Sounds like some texture memory is getting shared where it shouldn't. Have you tried other 2 layer materials such as detail/light mapped ones? It would be interesting to see how those behave.
Frosty Topaz
=========
It isn't easy being ice-encrusted aluminum silicate fluoride hydroxide...
Dott. Agasa
Posts: 11
Joined: Sat Jun 30, 2007 6:50 pm

Post by Dott. Agasa »

following your advice, i tried EMT_LIGHTMAP, EMT_LIGHTMAP_ADD and EMT_DETAIL_MAP. Altrough they tinge the mesh with respectively different eerie blue and cyan colors, they dont give any problems with other textures.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Which version of Irrlicht and which driver (OpenGL or D3D9) do you use? There had been some render state bugs in the past, so upgrading to 1.4 might help in case you use older versions.
Dott. Agasa
Posts: 11
Joined: Sat Jun 30, 2007 6:50 pm

Post by Dott. Agasa »

i use OpenGL on a custom 1.3.1 irrlicht build with some bugs (like billboardtext permanency) corrected. On a OT note, i'm afraid that 1.4 my break my code. what are the API breaking differences?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The differences are basically different syntax for some things (e.g. material access) and method signature changes (which affects mostly custom scene nodes). The animation system has changed a lot, so you have to change animation settings (e.g. frame loop settings).
Dott. Agasa
Posts: 11
Joined: Sat Jun 30, 2007 6:50 pm

Post by Dott. Agasa »

ok, thank you VERY much hybrid-sama, i'll move on to 1.4 ...in the near future. to admit the truth, 1.4 scared me a little. in the meantime someone can help me?
Dott. Agasa
Posts: 11
Joined: Sat Jun 30, 2007 6:50 pm

Post by Dott. Agasa »

to my utmost regret, i must resume the topic, as the problem has not been resolved due to other problems arising, mostly with sound, and other life problems. i updated some parts of my engine hoping it would solve it, to no avail (i tried to solve problems with allocated textures...). please report if anyone of you had similar experiences and how you solved them... please, help me.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

You missed out the most important detail, what video card do you have?
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Dott. Agasa
Posts: 11
Joined: Sat Jun 30, 2007 6:50 pm

Post by Dott. Agasa »

Nvidia GeForce 8800 GTS.

changed it recently, no effect. before, i had Nvidia GeForce 7600 GT.

The demo of this shader that comes with irr works perfectly with either cards.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

If you look in the NVidia shader library (On their website in the developer section), there are some alternative parallax mapping shaders you can try.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Dott. Agasa
Posts: 11
Joined: Sat Jun 30, 2007 6:50 pm

Post by Dott. Agasa »

forgot to mention previously: when i apply the parallax shader the texture does not seem parallaxed at all. it looks like a lightmap. you can see it in the screenshots.
Post Reply