Alpha problem in material

The place for artists, modellers, level designers et al to discuss their approaches for creating content for OGRE.
albertogre
Gnoblar
Posts: 3
Joined: Fri May 18, 2012 4:02 am

Alpha problem in material

Post by albertogre »

Hello all, I´m noobie in this topic, so I will try to explain the best I can do it.
The situation is the next: I have exported a model from max to mesh and material format (using ogremax). The problem is the material file don´t have every pass and neither textures that the model is using, only the diffuse image is written in the material file. In max the model is viewing perfectly without problems.

When I use OgreMax WinViewer I see this image:
forzudo.png
The model have 3 different images (diffuse, specular and alpha).
I want the belt from the character is fine and no so weird as now with these black background.

I have been changing the material file until this point:

Code: Select all

material skinForzudo
{
	technique
	{
		pass
		{			
			texture_unit
			{
				texture Forzudo_Spec.tga
			}
			
			texture_unit
			{
				texture Forzudo_Opac.tga        
				colour_op alpha_blend
			}
			 
			texture_unit
			{
				texture Forzudo_Diff.tga
				colour_op_ex blend_current_alpha src_texture src_current
			}
		}
	}
}
First, I use a specular texture, after apply a alpha texture and finally a diffuse texture. I don´t know how to fix the problem with the belt.
I hope someone can help me with it soon.

Greetings,
Albert
You do not have the required permissions to view the files attached to this post.
User avatar
mkultra333
Gold Sponsor
Gold Sponsor
Posts: 1894
Joined: Sun Mar 08, 2009 5:25 am
x 116

Re: Alpha problem in material

Post by mkultra333 »

I think maybe you want seperate passes for the alpha-blended parts, rather than texture_ops in the one pass. Check the manual: http://www.ogre3d.org/docs/manual/manua ... C_Contents

From the Scripts material passes section on the scene_blend parameter: http://www.ogre3d.org/docs/manual/manual_16.html#SEC45
Sets the kind of blending this pass has with the existing contents of the scene. Wheras the texture blending operations seen in the texture_unit entries are concerned with blending between texture layers, this blending is about combining the output of this pass as a whole with the existing contents of the rendering target. This blending therefore allows object transparency and other special effects. There are 2 formats, one using predefined blend types, the other allowing a roll-your-own approach using source and destination factors.
So do multiple passes, and set the pass scene_blend to alpha_blend for the belt pass.
"In theory there is no difference between practice and theory. In practice, there is." - Psychology Textbook.
albertogre
Gnoblar
Posts: 3
Joined: Fri May 18, 2012 4:02 am

Re: Alpha problem in material

Post by albertogre »

Hi mkultra333,

if I add three pass to the material the final result is the same. Here the code

Code: Select all

material skinForzudo
{
	technique
	{
		pass
		{						
			texture_unit
			{
				texture Forzudo_Spec.tga
			}					
		}
		
		pass
		{
			scene_blend alpha_blend
			texture_unit
			{
				texture Forzudo_Opac.tga        								
			}		
		}
		
		pass
		{
			texture_unit
			{
				texture Forzudo_Diff.tga
				colour_op_ex blend_current_alpha src_texture src_current
			}
		}
		
	}
}
User avatar
mkultra333
Gold Sponsor
Gold Sponsor
Posts: 1894
Joined: Sun Mar 08, 2009 5:25 am
x 116

Re: Alpha problem in material

Post by mkultra333 »

I don't use fixed function much, so I'm not an expert and might not be able to help.

First question, does Forzudo_Opac.tga have an alpha channel with the right info?
Second, why are you using "colour_op_ex blend_current_alpha src_texture src_current" in the third pass?

Which texture actually has the belt buckle on it?
"In theory there is no difference between practice and theory. In practice, there is." - Psychology Textbook.
albertogre
Gnoblar
Posts: 3
Joined: Fri May 18, 2012 4:02 am

Re: Alpha problem in material

Post by albertogre »

Hello, here the 3 textures that material uses.
Forzudo_Spec.jpg
Forzudo_Opac.jpg
Forzudo_Diff.jpg
Order: specular, opacity and diffuse.

Sorry, but the original images are jpg and not tga. Another person gave me the max with these textures and so I don´t know how the jpg has been created. However, as I said, in max every is fine but the ogremax exporter dont export correctly the material...

I take the expresion "colour_op_ex blend_current_alpha src_texture src_current" from this tutorial

Unless I get to fix the material, then I will try to do with shaders.
You do not have the required permissions to view the files attached to this post.
User avatar
mkultra333
Gold Sponsor
Gold Sponsor
Posts: 1894
Joined: Sun Mar 08, 2009 5:25 am
x 116

Re: Alpha problem in material

Post by mkultra333 »

Ok, AFAIK you won't be able to get alpha blending or alpha testing in the fixed function pipeline if none of your textures have an alpha channel. I'm not sure how you'd get specular either. You'll notice in that tutorial that the texture used to do the mixture doesn't create holes in the render, it simply controls blending between two other textures. So it isn't what you need.

The first step to at least get diffuse with alpha blending would be to create a 4 channel TGA image, put the diffuse above into the RGB channel and the alpha into the Alpha channel. Then you could do your material with just one pass that was alpha tested. Say the new image is called SkinPlusAlpha.tga. Your material would be

Code: Select all

material skinForzudo
{
   technique
   {
      
      pass
      {
         scene_blend alpha_blend
         texture_unit
         {
            texture SkinPlusAlpha.tga                                
         }      
      }
}
(I think, I haven't tested.)

But it isn't ideal to start with jpegs as the source since you've already introduced compression artifacts. Better to get the originals.

I'm not sure how you do specular with fixed function pipeline. If you really want better control over materials (including getting alpha without necessarily having alpha channels) then you might want to look into shader programming.
"In theory there is no difference between practice and theory. In practice, there is." - Psychology Textbook.