Strange Artifacts On Exported Materials

agoratim

09-09-2006 17:00:30

Hey folks,
I've been more or less unable to successfully use any advanced material features (bump mapping, etc) with any materials that I have exported from oFusion. I've basically been running through the basic torus tutorial trying to get things working but every time I try to load an exported mesh in-engine I get these weird artifacts behind the object. Screenshots are below as well as the material file.

I'm using the latest version of oFusion with Max 8 and we're using the Dagon source code. Is there anything I could be doing wrong when I load my entities? Any parameters I need to setup for my scene before loading? Is it possible I'm using the wrong shaders (at the moment I'm using the ones I copied from the oFusion install)?

Thanks for the help.

The following is the object as viewed in oFusion. Nice normals and all that...


This is the object when loaded in-engine. Notice the lack of normals and the weird artifact behind the object.


material Torus01
{
technique
{
pass
{
iteration once_per_light
ambient 0.7 0.7 0.7 1
diffuse 0.7 0.7 0.7 1
specular 0.9 0.9 0.9 1 20

vertex_program_ref Examples/BumpMapVPSpecular
{
param_named_auto lightPosition light_position_object_space 0
param_named_auto eyePosition camera_position_object_space
param_named_auto worldViewProj light_position_object_space 0
}

fragment_program_ref Examples/BumpMapFPSpecular
{
param_named_auto lightDiffuse light_diffuse_colour 0
param_named_auto lightSpecular light_specular_colour 0
}

texture_unit
{
texture_alias 0
texture timtest_normal.tga
}

texture_unit
{
texture_alias 1
cubic_texture nm.dds combinedUVW
tex_coord_set 1
tex_address_mode clamp
}

texture_unit
{
texture_alias 2
cubic_texture nm.dds combinedUVW
tex_coord_set 2
tex_address_mode clamp
}
}

pass
{
lighting off
scene_blend modulate

vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
{
param_named_auto worldViewProj worldviewproj_matrix
param_named ambient float4 255 255 255 0
}

texture_unit
{
texture_alias 0
texture checkerboard_numbered_blue.gif
}
}

}

}

Lioric

09-09-2006 18:46:24

In the vertex program ref parameter worldViewProj of the Pass0 (the bump mapping pass) , its should be "worldviewproj_matrix" as its value

I will review this

Why you are not using the ambient pass?

agoratim

11-09-2006 23:18:08

Lioric,

I'm a little confused by what you mean about 'not using the ambient pass'. This material file is what was exported from oFusion and I haven't really messed with it since. I was essentially following the first bump mapping tutorial, perhaps I missed a step somewhere?

I'll give the worldviewproj_matrix change a shot and let you know how it goes.

Thanks for the help!

Lioric

11-09-2006 23:32:38

You are using a BumpMap pass and a Decal pass, so your object wont be affected by the ambient light, nor use the optimization technique that when the object is partially visible in the view, just the visible pixels will be processed

But it wont affect your result if you dont need this

The wrong shader parameters issue were fixed last week, and a hotfix will be provided in the next days

agoratim

13-09-2006 02:22:29

So I had a chance to switch from worldviewproj to worldviewproj_matrix which took care of some of the problem. The issue now is that whenever my view changes either from a mouse move or translating around the scene I can see only the normal map; no texture is mapped to the image.

I also figured out why we had turned the ambient pass off which was because it produced it's own set of artifacts. Screenshots and revised material file are below. Any ideas? The only thing that seems to help with this is turning off either depth check or depth write but both of those cause even worse issues (crazy non-culled faces, etc).

Also, that's great news about the hot fix! Keep up the good work.

Thanks


material Torus01
{
technique
{
pass
{
ambient 0.588235 0.588235 0.588235 0
diffuse 0.588235 0.588235 0.588235 0
specular 0.00784314 0.00784314 0.00784314 0 0
}

pass
{
iteration once_per_light
ambient 0.7 0.7 0.7 1
diffuse 0.7 0.7 0.7 1
specular 0.9 0.9 0.9 1 20

vertex_program_ref Examples/BumpMapVPSpecular
{
param_named_auto lightPosition light_position_object_space 0
param_named_auto eyePosition camera_position_object_space 0
param_named_auto worldViewProj_matrix light_position_object_space 0
}

fragment_program_ref Examples/BumpMapFPSpecular
{
param_named_auto lightDiffuse light_diffuse_colour 0
param_named_auto lightSpecular light_specular_colour 0
}

texture_unit
{
texture_alias 0
texture timtest_normal.tga
}

texture_unit
{
texture_alias 1
cubic_texture nm.dds combinedUVW
tex_coord_set 1
tex_address_mode clamp
}

texture_unit
{
texture_alias 2
cubic_texture nm.dds combinedUVW
tex_coord_set 2
tex_address_mode clamp
}
}

pass
{
lighting off
scene_blend modulate

vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
{
param_named_auto worldViewProj worldviewproj_matrix
param_named ambient float4 255 255 255 0
}

texture_unit
{
texture_alias 0
texture checkerboard_numbered_blue.gif
}
}

}

}


The following render in engine looks fine...


However, whenever I move about the scene the regular texture disappears and all I get is the normal map. Could this be something I'm doing/not doing in code?


If I turn the ambient pass on I get the following renders. The first is in oFusion and the second is in engine.

Lioric

13-09-2006 04:25:22

For the ambient pass issues, you need the same vertex program as the decal pass

When you use programmable pipeline, all your passes has to use it, no pass can use the fixed pipeline while others uses the programmable pipeline, specially in OpenGL

agoratim

13-09-2006 12:37:02

Cool. Thanks for the hand-holding Lioric. You've been extremely helpful. Everything seems to be working wonderfully now. For anyone that is curious my final material file is at the bottom of this post.

One bug to report regarding the ambient pass though. I'm assuming this is part of the same bug in which some of the param_named_auto parameters are exported incorrectly so you may already know about it.

The exporter seems to not want to export the ambient pass if I turn on the vertex program for it. I get the error message below when I export and from then on, no matter what I do to the pass (turning it on/off, turning the vertex program on/off), it will fail to produce a material file at all. The mesh is still exported but no material file. The same occurs if I load a saved max scene with the vertex program active. I have to resave the scene without the vertex program on, restart max, export and then modify the materials file manually.

== Exporting Objects ==
Exporting Object: Box01
Object has 1 texture sets
Compiling material Torus01
New texture unit timtest_normal.tga
New texture unit nm.dds
New texture unit nm.dds
New texture unit checkerboard_numbered_blue.gif
Caught exception in compilemesh()
Please report it
Exporting Object: Camera01.Target


material Torus01
{
technique
{
pass
{
ambient 0.588235 0.588235 0.588235 0
diffuse 0.588235 0.588235 0.588235 0
specular 0.00784314 0.00784314 0.00784314 0 0
emissive 0 0 0 0

vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
{
param_named_auto worldViewProj worldviewproj_matrix
param_named ambient float4 255 255 255 0
}
}

pass
{
iteration once_per_light
ambient 0.7 0.7 0.7 1
diffuse 0.7 0.7 0.7 1
specular 0.9 0.9 0.9 1 20

vertex_program_ref Examples/BumpMapVPSpecular
{
param_named_auto lightPosition light_position_object_space 0
param_named_auto eyePosition camera_position_object_space 0
param_named_auto worldviewproj_matrix light_position_object_space 0
}

fragment_program_ref Examples/BumpMapFPSpecular
{
param_named_auto lightDiffuse light_diffuse_colour 0
param_named_auto lightSpecular light_specular_colour 0
}

texture_unit
{
texture_alias 0
texture timtest_normal.tga
}

texture_unit
{
texture_alias 1
cubic_texture nm.dds combinedUVW
tex_coord_set 1
tex_address_mode clamp
}

texture_unit
{
texture_alias 2
cubic_texture nm.dds combinedUVW
tex_coord_set 2
tex_address_mode clamp
}
}

pass
{
lighting off
scene_blend modulate

vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
{
param_named_auto worldViewProj worldviewproj_matrix
param_named ambient float4 255 255 255 0
}

texture_unit
{
texture_alias 0
texture checkerboard_numbered_blue.gif
}
}

}

}

Lioric

13-09-2006 16:43:25

As noted above, this was fixed, expect the hotfix in the next days