RTSS coloring problem question

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
Post Reply
User avatar
Mattan Furst
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 260
Joined: Tue Jan 01, 2008 11:28 am
Location: Israel

RTSS coloring problem question

Post by Mattan Furst » Tue Jul 13, 2010 12:12 pm

I have a problem where objects which should be semi-transparent are not drawn as such in the RTSS (Runtime shader system).

The problem goes as follows. I have a particle effect who's vertex buffer contains semi-transparent vertex colors. The material which controls the drawing of this effect is defined with emissive and diffuse vertex color tracking.
When drawing the effect without RTSS the effect is semi-transparent. when with the RTSS the effect is completely opaque.

This problem is actually caused because of 2 bugs:
  1. The emissive color default value is (0 0 0 1) instead of what the documentation say which is (0 0 0 0)
  2. The RTSS takes into account the alpha value of the emissive color. Which at least under these circumstances it should not. In fact as far as I can see in the fixed pipelife the alpha value is only modulated by the alpha of the diffuse color.
My question is this. Which bug do I fix (if at all)?
  1. Set the default value of emissive color to (0 0 0 0) - This is probably the simplest fix but might not be backward compatible.
  2. Only take into consideration the diffuse color when modulating the alpha color channel - I'm not sure this is always true. I'm not an expert on fixed pipelines.
  3. Both.
  4. Don't fix anything - Just put "emissive 0 0 0 0" in all such materials. This fixes the problem.
0 x
it's turtles all the way down

User avatar
Mattan Furst
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 260
Joined: Tue Jan 01, 2008 11:28 am
Location: Israel

Re: RTSS coloring problem question

Post by Mattan Furst » Tue Jul 13, 2010 3:45 pm

Update:

Just noticed something. both diffuse surface color and specular surface color are never used in the RTSS. Though in the fpp diffuse surface color is important in determining a materials alpha channel.
0 x
it's turtles all the way down

User avatar
Mattan Furst
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 260
Joined: Tue Jan 01, 2008 11:28 am
Location: Israel

Re: RTSS coloring problem question

Post by Mattan Furst » Wed Jul 14, 2010 8:10 am

I think I have a fix to the alpha problem.

I change the function implementation (on my local copy) of PerPixelLighting::addPSGlobalIlluminationInvocation in the RTSS.
in the beginning of the function I've added the lines:

Code: Select all

	if (mTrackVertexColourType & TVC_DIFFUSE)
	{
		curFuncInvocation = OGRE_NEW FunctionInvocation(FFP_FUNC_ASSIGN, groupOrder, internalCounter++); 
		curFuncInvocation->pushOperand(mPSDiffuse, Operand::OPS_IN, Operand::OPM_W);
		curFuncInvocation->pushOperand(mPSTempDiffuseColour, Operand::OPS_OUT, Operand::OPM_W);	
		psMain->addAtomInstance(curFuncInvocation);
	}
	else
	{
		curFuncInvocation = OGRE_NEW FunctionInvocation(FFP_FUNC_ASSIGN, groupOrder, internalCounter++); 
		curFuncInvocation->pushOperand(mDerivedSceneColour, Operand::OPS_IN, Operand::OPM_W);
		curFuncInvocation->pushOperand(mPSTempDiffuseColour, Operand::OPS_OUT, Operand::OPM_W);	
		psMain->addAtomInstance(curFuncInvocation);		
	}
At the rest of the code all other function calls which assign the value of mPSTempDiffuseColour have been limited to the x y and z values.

This seems to make the RTSS appear more like the FPP implementation.

@Nir
Can you check this and tell me what you think?
0 x
it's turtles all the way down

User avatar
trilobite
Silver Sponsor
Silver Sponsor
Posts: 135
Joined: Thu Jul 13, 2006 9:16 pm
Location: San Juan Capistrano, CA, USA

Re: RTSS coloring problem question

Post by trilobite » Sat Aug 28, 2010 5:20 am

I have noticed that with RTSS, my particles are opaque and are completely white.
No matter what I do to reconfigure the particle code or the material code I get the same result... no color and no transparency.
Does anyone have ideas as to the cause for this?

Here is an image of the problem...
Image
Here is the particle code...

Code: Select all

particle_system pb_engine_flame_2
{
	quota	200
	emit_emitter_quota	3
	material	exo_explorer/engine_flame_2
	particle_width	2
	particle_height	2
	cull_each	false
	renderer	billboard
	sorted	false
	local_space	true
	iteration_interval	0
	nonvisible_update_timeout	0

	emitter Point
	{
		angle	2
		colour	1 1 0.5 1
		colour_range_start	1 1 0.5 1
		colour_range_end	1 0.8 0.3 1
		direction	0 0 1
		emission_rate	40
		position	0 0 0
		velocity	0.5
		velocity_min	0.5
		velocity_max	4
		time_to_live	2
		time_to_live_min	2
		time_to_live_max	3
		duration	0
		duration_min	0
		duration_max	0
		repeat_delay	0
		repeat_delay_min	0
		repeat_delay_max	0
		name	
		emit_emitter	
	}


	affector ColourFader
	{
		red	-0.25
		green	-1
		blue	-1
		alpha	0
	}

}
and the material

Code: Select all

material exo_explorer/engine_flame_2
{
technique
	{
		pass
		{
			lighting off
			scene_blend add
			depth_write off

			texture_unit
			{
				texture flare.png
			}
		}
	}
}
0 x

al2950
OGRE Expert User
OGRE Expert User
Posts: 1212
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 80

Re: RTSS coloring problem question

Post by al2950 » Tue Aug 31, 2010 3:10 pm

Use these material setting instead;

Code: Select all

material exo_explorer/engine_flame_2
{
technique
   {
      pass
      {
         lighting off
         scene_blend add
         depth_write off
         diffuse vertexcolour

         texture_unit
         {
            texture flare.png
         }
      }
   }
}
Notice I added the line "diffuse vertexcolour". That should sort out your problem
0 x

User avatar
Nir Hasson
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 363
Joined: Wed Nov 05, 2008 4:40 pm
Location: TLV - Israel
Contact:

Re: RTSS coloring problem question

Post by Nir Hasson » Wed Sep 01, 2010 11:08 am

Notice I added the line "diffuse vertexcolour". That should sort out your problem
True - this is the only way to tell the RTSS to grab the vertex colours from the vertex stream.
It is used in the particle system sample materials as well.
0 x

User avatar
trilobite
Silver Sponsor
Silver Sponsor
Posts: 135
Joined: Thu Jul 13, 2006 9:16 pm
Location: San Juan Capistrano, CA, USA

Re: RTSS coloring problem question

Post by trilobite » Thu Sep 02, 2010 5:32 am

Notice I added the line "diffuse vertexcolour". That should sort out your problem
That solved it.
Thanks, al2950
0 x

User avatar
DanielSefton
Ogre Magi
Posts: 1235
Joined: Fri Oct 26, 2007 12:36 am
Location: Mountain View, CA
Contact:

Re: RTSS coloring problem question

Post by DanielSefton » Sun Nov 11, 2012 11:11 pm

Any ideas why using "diffuse vertexcolour" destroys performance on GLES 2.0? Like, my FPS is more than halved with it. This was not a problem without the RTSS on GLES 1.0.
0 x

Post Reply