Bumpmap Fighting

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
User avatar
Marc
Gremlin
Posts: 182
Joined: Tue Jan 25, 2005 7:56 am
Location: Germany
Contact:

Bumpmap Fighting

Post by Marc »

I get a strange effect when I try to use bumpmapping in one of my own meshes in OpenGL.
It flickers somehow between these two states when moving around:

Image

It looks right in directx9 (like the 2nd shot of OpenGL).
This is not a constant mapping. It flickers when I move around. A bit like z-fighting.
I copied the material from the advanced example.
This is from a Geforce Ti4200. There are no problems when I apply a simple texture. What's wrong?


Ogre log:

Code: Select all

02:31:30: Creating resource group General
02:31:30: Registering ResourceManager for type Material
02:31:30: Registering ResourceManager for type Mesh
02:31:30: Registering ResourceManager for type Skeleton
02:31:30: Loading library OgrePlatform.dll
02:31:30: OverlayElementFactory for type Panel registered.
02:31:30: OverlayElementFactory for type BorderPanel registered.
02:31:30: OverlayElementFactory for type TextArea registered.
02:31:30: Registering ResourceManager for type Font
02:31:30: ArchiveFactory for archive type FileSystem registered.
02:31:30: ArchiveFactory for archive type Zip registered.
02:31:30: DevIL version: Developer's Image Library (DevIL) 1.6.5
02:31:30: DevIL image formats: bmp dib cut dcx dds gif ico cur jpg jpe jpeg lif mdl mng jng pcx pic pix png pbm pgm pnm ppm psd pdd psp pxr sgi bw rgb rgba tga vda icb vst tif tiff wal xpm raw 
02:31:30: Registering ResourceManager for type HighLevelGpuProgram
02:31:30: Loading library .\RenderSystem_Direct3D7
02:31:30: Direct3D7 Rendering Subsystem created.
02:31:30: ----- DirectDraw Detection Starts
02:31:30: Detected DirectDraw driver Primary Display Driver
02:31:30: Detected DirectDraw driver NVIDIA GeForce4 Ti 4200
02:31:30: Detected DirectDraw driver NVIDIA GeForce4 Ti 4200
02:31:30: ----- DirectDraw Detection Ends
02:31:30: Loading library .\RenderSystem_Direct3D9
02:31:30: D3D9 : Direct3D9 Rendering SubSystem created.
02:31:30: D3D9: Driver Detection Starts
02:31:31: D3D9: Driver Detection Ends
02:31:31: Loading library .\RenderSystem_GL
02:31:31: OpenGL Rendering Subsystem created.
02:31:31: Loading library .\Plugin_ParticleFX
02:31:31: Particle Emitter Type 'Point' registered
02:31:31: Particle Emitter Type 'Box' registered
02:31:31: Particle Emitter Type 'Ellipsoid' registered
02:31:31: Particle Emitter Type 'Cylinder' registered
02:31:31: Particle Emitter Type 'Ring' registered
02:31:31: Particle Emitter Type 'HollowEllipsoid' registered
02:31:31: Particle Affector Type 'LinearForce' registered
02:31:31: Particle Affector Type 'ColourFader' registered
02:31:31: Particle Affector Type 'ColourFader2' registered
02:31:31: Particle Affector Type 'ColourImage' registered
02:31:31: Particle Affector Type 'ColourInterpolator' registered
02:31:31: Particle Affector Type 'Scaler' registered
02:31:31: Particle Affector Type 'Rotator' registered
02:31:31: Loading library .\Plugin_BSPSceneManager
02:31:31: Registering ResourceManager for type BspLevel
02:31:31: Loading library .\Plugin_OctreeSceneManager
02:31:31: TerrainSceneManager: Registered a new PageSource for type Heightmap
02:31:31: Loading library .\Plugin_CgProgramManager
02:31:31: *-*-* OGRE Initialising
02:31:31: *-*-* Version 1.0.0 (Azathoth)
02:31:31: Added resource location 'Media' of type 'FileSystem' to resource group 'General'
02:31:31: Added resource location 'Media/fonts' of type 'FileSystem' to resource group 'General'
02:31:31: Added resource location 'Media/materials/scripts' of type 'FileSystem' to resource group 'General'
02:31:31: Added resource location 'Media/materials/textures' of type 'FileSystem' to resource group 'General'
02:31:31: Added resource location 'Media/models' of type 'FileSystem' to resource group 'General'
02:31:31: Added resource location 'Media/overlays' of type 'FileSystem' to resource group 'General'
02:31:31: Added resource location 'Media/particle' of type 'FileSystem' to resource group 'General'
02:31:31: D3D9 : RenderSystem Option: Anti aliasing = None
02:31:31: D3D9 : RenderSystem Option: Floating-point mode = Fastest
02:31:31: D3D9 : RenderSystem Option: Full Screen = No
02:31:31: D3D9 : RenderSystem Option: Rendering Device = NVIDIA GeForce4 Ti 4200
02:31:31: D3D9 : RenderSystem Option: VSync = No
02:31:31: D3D9 : RenderSystem Option: Video Mode = 1024 x 768 @ 32-bit colour
02:31:36: D3D9 : Shutting down cleanly.
02:31:36: *** Starting Win32GL Subsystem ***
02:31:36: GLRenderSystem::createRenderWindow "OGRE Render Window", 1024x768 windowed  miscParams: colourDepth=32 vsync=false 
02:31:36: Created Win32Window 'OGRE Render Window' : 1024x768, 32bpp
02:31:37: GL_VERSION = 1.5.2
02:31:37: GL_VENDOR = NVIDIA Corporation
02:31:37: GL_RENDERER = GeForce4 Ti 4200/PCI/SSE/3DNOW!
02:31:37: GL_EXTENSIONS = GL_ARB_depth_texture GL_ARB_imaging GL_ARB_multisample GL_ARB_multitexture GL_ARB_occlusion_query GL_ARB_point_parameters GL_ARB_point_sprite GL_ARB_shadow GL_ARB_shader_objects GL_ARB_shading_language_100 GL_ARB_texture_border_clamp GL_ARB_texture_compression GL_ARB_texture_cube_map GL_ARB_texture_env_add GL_ARB_texture_env_combine GL_ARB_texture_env_dot3 GL_ARB_texture_mirrored_repeat GL_ARB_texture_rectangle GL_ARB_transpose_matrix GL_ARB_vertex_buffer_object GL_ARB_vertex_program GL_ARB_vertex_shader GL_ARB_window_pos GL_S3_s3tc GL_EXT_texture_env_add GL_EXT_abgr GL_EXT_bgra GL_EXT_blend_color GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_compiled_vertex_array GL_EXT_Cg_shader GL_EXT_draw_range_elements GL_EXT_fog_coord GL_EXT_multi_draw_arrays GL_EXT_packed_pixels GL_EXT_paletted_texture GL_EXT_pixel_buffer_object GL_EXT_point_parameters GL_EXT_rescale_normal GL_EXT_secondary_color GL_EXT_separate_specular_color GL_EXT_shadow_funcs GL_EXT_shared_texture_palette GL_EXT_stencil_wrap GL_EXT_texture3D GL_EXT_texture_compression_s3tc GL_EXT_texture_cube_map GL_EXT_texture_edge_clamp GL_EXT_texture_env_combine GL_EXT_texture_env_dot3 GL_EXT_texture_filter_anisotropic GL_EXT_texture_lod GL_EXT_texture_lod_bias GL_EXT_texture_object GL_EXT_vertex_array GL_HP_occlusion_test GL_IBM_rasterpos_clip GL_IBM_texture_mirrored_repeat GL_KTX_buffer_region GL_NV_blend_square GL_NV_copy_depth_to_color GL_NV_depth_clamp GL_NV_fence GL_NV_fog_distance GL_NV_light_max_exponent GL_NV_multisample_filter_hint GL_NV_occlusion_query GL_NV_packed_depth_stencil GL_NV_pixel_data_range GL_NV_point_sprite GL_NV_register_combiners GL_NV_register_combiners2 GL_NV_texgen_reflection GL_NV_texture_compression_vtc GL_NV_texture_env_combine4 GL_NV_texture_rectangle GL_NV_texture_shader GL_NV_texture_shader2 GL_NV_texture_shader3 GL_NV_vertex_array_range GL_NV_vertex_array_range2 GL_NV_vertex_program GL_NV_vertex_program1_1 GL_SGIS_generate_mipmap GL_SGIS_multitexture GL_SGIS_texture_lod GL_SGIX_depth_texture GL_SGIX_shadow GL_SUN_slice_accum GL_WIN_swap_hint WGL_EXT_swap_control 
02:31:37: Supported WGL extensions: WGL_ARB_buffer_region WGL_ARB_extensions_string WGL_ARB_make_current_read WGL_ARB_multisample WGL_ARB_pbuffer WGL_ARB_pixel_format WGL_ARB_render_texture WGL_EXT_extensions_string WGL_EXT_swap_control WGL_NV_render_depth_texture WGL_NV_render_texture_rectangle 
02:31:37: ***************************
*** GL Renderer Started ***
***************************
02:31:37: Registering ResourceManager for type GpuProgram
02:31:37: RenderSystem capabilities
02:31:37: -------------------------
02:31:37:  * Hardware generation of mipmaps: yes
02:31:37:  * Texture blending: yes
02:31:37:  * Anisotropic texture filtering: yes
02:31:37:  * Dot product texture operation: yes
02:31:37:  * Cube mapping: yes
02:31:37:  * Hardware stencil buffer: yes
02:31:37:    - Stencil depth: 8
02:31:37:    - Two sided stencil support: no
02:31:37:    - Wrap stencil values: yes
02:31:37:  * Hardware vertex / index buffers: yes
02:31:37:  * Vertex programs: yes
02:31:37:    - Max vertex program version: arbvp1
02:31:37:  * Fragment programs: yes
02:31:37:    - Max fragment program version: fp20
02:31:37:  * Texture Compression: yes
02:31:37:    - DXT: yes
02:31:37:    - VTC: yes
02:31:37:  * Scissor Rectangle: yes
02:31:37:  * Hardware Occlusion Query: yes
02:31:37:  * User clip planes: yes
02:31:37:  * VET_UBYTE4 vertex element type: yes
02:31:37:  * Infinite far plane projection: yes
02:31:37:  * Hardware render-to-texture: yes
02:31:37:  * Floating point textures: no
02:31:37:  * Non-power-of-two textures: no
02:31:37:  * Volume textures: yes
02:31:37: Registering ResourceManager for type Texture
02:31:37: ResourceBackgroundQueue - threading disabled
02:31:37: Particle Renderer Type 'billboard' registered
02:31:37: Creating viewport on target 'OGRE Render Window', rendering from camera 'PlayerCam', relative dimensions L: 0.00 T: 0.00 W: 1.00 H: 1.00 ZOrder: 0
02:31:37: Viewport for camera 'PlayerCam', actual dimensions L: 0 T: 0 W: 1024 H: 768
02:31:37: Parsing scripts for resource group General
02:31:37: Parsing script 01_-_Default.material
02:31:37: Parsing script BumpMapping.material
02:31:38: Parsing script hud.material
02:31:38: Parsing script OgreCore.material
02:31:38: Parsing script smoke.material
02:31:38: Parsing script ant.material
02:31:38: Parsing script maprpgnew.material
02:31:38: Parsing script nest.material
02:31:38: Parsing script pickupreinforcement.material
02:31:38: Parsing script shotlaser.material
02:31:38: Parsing script Ogre.fontdef
02:31:38: Parsing script Explosion.particle
02:31:38: Parsing script hud.overlay
02:31:38: Texture: crosshair.png: Loading 1 faces(PF_A8B8G8R8,64x64x1) with 5 generated mipmaps from Image. Internal format is PF_A8R8G8B8,64x64x1.
02:31:38: Mesh: Loading gungravity.mesh.
02:31:38: Texture: dirt01.jpg: Loading 1 faces(PF_B8G8R8,96x96x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,128x128x1.
02:31:38: Mesh: Loading gunplasma.mesh.
02:31:38: Mesh: Loading gungrenade.mesh.
02:31:38: Texture: hudvaluespanel.png: Loading 1 faces(PF_A8B8G8R8,2x2x1) with 1 generated mipmaps from Image. Internal format is PF_A8R8G8B8,2x2x1.
02:31:38: Font TrebuchetMSBoldusing texture size 512x512
02:31:38: Info: Freetype returned null for character 160 in font TrebuchetMSBold
02:31:38: Texture: TrebuchetMSBoldTexture: Loading 1 faces(PF_BYTE_LA,512x512x1) with 0 generated mipmaps from Image. Internal format is PF_BYTE_LA,512x512x1.
02:31:38: Parsing script OgreDebugPanel.overlay
02:31:38: Texture: New_Ogre_Border_Center.png: Loading 1 faces(PF_A8B8G8R8,256x128x1) with 5 generated mipmaps from Image. Internal format is PF_A8R8G8B8,256x128x1.
02:31:38: Texture: New_Ogre_Border.png: Loading 1 faces(PF_A8B8G8R8,256x256x1) with 5 generated mipmaps from Image. Internal format is PF_A8R8G8B8,256x256x1.
02:31:38: Texture: New_Ogre_Border_Break.png: Loading 1 faces(PF_A8B8G8R8,32x32x1) with 5 generated mipmaps from Image. Internal format is PF_A8R8G8B8,32x32x1.
02:31:38: Parsing script stats.overlay
02:31:38: Finished parsing scripts for resource group General
02:31:38: Mesh: Loading maprpgnew.mesh.
02:31:38: Texture: grass_1024.jpg: Loading 1 faces(PF_B8G8R8,1024x1024x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,1024x1024x1.
02:31:38: Texture: oldbrick.jpg: Loading 1 faces(PF_B8G8R8,128x128x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,128x128x1.
02:31:38: Texture: parket.jpg: Loading 1 faces(PF_B8G8R8,128x128x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,128x128x1.
02:31:38: Texture: marble_04_ebps_128.jpg: Loading 1 faces(PF_B8G8R8,128x128x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,128x128x1.
02:31:39: Texture: MtlPlat2.jpg: Loading 1 faces(PF_B8G8R8,780x511x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,1024x512x1.
02:31:39: Texture: misty.jpg: Loading 1 faces(PF_B8G8R8,128x128x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,128x128x1.
02:31:39: Texture: NMBumpsOut.png: Loading 1 faces(PF_B8G8R8,256x256x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
02:31:39: Texture: nm.png: Loading 6 faces(PF_B8G8R8,128x128x1) with 5 generated mipmaps from multiple Images. Internal format is PF_X8R8G8B8,128x128x1.
02:31:39: Texture: RustedMetal.jpg: Loading 1 faces(PF_B8G8R8,512x512x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1.
02:31:39: Texture: terr_rock6.jpg: Loading 1 faces(PF_B8G8R8,256x256x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
02:31:39: Texture: andrew_wood.jpg: Loading 1 faces(PF_B8G8R8,128x128x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,128x128x1.
02:31:39: Texture: blobby.jpg: Loading 1 faces(PF_B8G8R8,256x256x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
02:31:39: Win32Input8: DirectInput Activation Starts
02:31:39: Win32Input8: Establishing keyboard input.
02:31:39: Win32Input8: Keyboard input established.
02:31:39: Win32Input8: Initializing mouse input in immediate mode.
02:31:39: Win32Input8: Mouse input in immediate mode initialized.
02:31:39: Win32Input8: DirectInput OK.
02:31:39: Mesh: Loading boxkarton.mesh.
02:31:39: Mesh: Loading shotgrenade.mesh.
02:31:39: Mesh: Loading shotlaser.mesh.
02:31:39: Texture: laser.png: Loading 1 faces(PF_B8G8R8,64x64x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,64x64x1.
02:31:39: Mesh: Loading boxply.mesh.
02:31:39: Mesh: Loading ant.mesh.
02:31:39: Texture: topping.png: Loading 1 faces(PF_B8G8R8,128x128x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,128x128x1.
02:31:39: Mesh: Loading nest.mesh.
02:31:39: Texture: marble_08_ao___128.jpg: Loading 1 faces(PF_B8G8R8,128x128x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,128x128x1.
02:31:39: Mesh: Loading pickupreinforcement.mesh.
02:31:39: Texture: reinforcement.png: Loading 1 faces(PF_B8G8R8,64x64x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,64x64x1.
02:31:39: Mesh: Loading explosionobject.mesh.
02:31:39: Texture: spot_shadow_fade.png: Loading 1 faces(PF_B8G8R8,128x128x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,128x128x1.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

It's probably depth fighting. You'll notice that in our bump mapping examples we always use a basic vertex program to transform the non-bumpmap passes too - this is to guarantee consistency and to avoid the depth fighting.
User avatar
Marc
Gremlin
Posts: 182
Joined: Tue Jan 25, 2005 7:56 am
Location: Germany
Contact:

Post by Marc »

sinbad wrote:It's probably depth fighting. You'll notice that in our bump mapping examples we always use a basic vertex program to transform the non-bumpmap passes too - this is to guarantee consistency and to avoid the depth fighting.
Do you mean this one?

Code: Select all

// A really basic ambient pass program, support for one texture coodinate set
vertex_program Ogre/BasicVertexPrograms/AmbientOneTexture cg
{
	source Example_BumpMapping.cg
	entry_point ambientOneTexture_vp
	profiles vs_1_1 arbvp1
}
I use it. Actually I just copied the example material and all the additional files (at least I think I copied all additional files needed).
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

The only other place I've observed flickering is if you use stencil shadows and align your light exactly along a large plane so that the shadow volume fights with it. I've had no issues with bump mapping otherwise.

Did you calculate tangent vectors for the mesh in question?

I'm not even sure I'm seeing what you mean in your screenshots. I was assuming you were talking about flickering on the surface, but now I see that there's a weird 'wedge' in the top screen. Can you be more specific about what it is you think looks wrong? If it's that wedge then that suggests something completely different - geometry corruption.
User avatar
Marc
Gremlin
Posts: 182
Joined: Tue Jan 25, 2005 7:56 am
Location: Germany
Contact:

Post by Marc »

I calculated tangent vectors. I wasn't sure if I need them for bumpmapping or not, so when I started to try bummapping I just put them in to be save.

I don't mean the bronish thing. That looks really strange somehow. But it's just some other kind of gun ;)

The problem I mean relates to the rustymetal with dots on it. As you can see, in the 2nd picture everything looks same bright while in the first picture it looks as if 1 vertex of each triangle has some brighter colorvalue or something like that. You can see these fading to nearly white. Actually the target fading color looks somewhat like the fog color I use, as you can see in the background on the left. But the triangles with the problems are far in front of the starting distance of the fog.
User avatar
DWORD
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 1365
Joined: Tue Sep 07, 2004 12:43 pm
Location: Aalborg, Denmark
Contact:

Post by DWORD »

It looks like the vertex normals are not correct in the first picture. Does it flicker, or just fade? :?
User avatar
Marc
Gremlin
Posts: 182
Joined: Tue Jan 25, 2005 7:56 am
Location: Germany
Contact:

Post by Marc »

Flicker. But depending on the pos of the cam. So it may be some really fast fading too. But when you say normals, once I had some similiar flickering with my first selfmade cube and it was because of the normals, too. But it flickered for both, OpenGl and DirectX.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

Are you scaling anything? This can throw normals out of whack.
User avatar
Marc
Gremlin
Posts: 182
Joined: Tue Jan 25, 2005 7:56 am
Location: Germany
Contact:

Post by Marc »

sinbad wrote:Are you scaling anything? This can throw normals out of whack.
No, I just load the mesh and that's it. If have to check if that's the reason again.

When I ahd the problem with the cube, I fixed it by manually fixing the normals in the xml file. They all had the length of 1.5x for some reason. It'll be hard to check that in this more complicated mesh ...

Perhaps it would be handy, at least for me, to have some normalizing switch in ogrexmlconvert, that scales every normal to a length of 1.
Post Reply