[Solved] Ogre 1.9 ES 2.0 RTSS Material Problems

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
technique
Halfling
Posts: 91
Joined: Fri Oct 22, 2010 10:46 pm
x 8

[Solved] Ogre 1.9 ES 2.0 RTSS Material Problems

Post by technique »

I switched my App to the latest Ogre 1.9 stable release and i found a material bug using the RTSS. For the developing i m using a Windows machine and the same RTSS setup as for the Android-Builds.
Both are related to the material scripts. Have a look on the screenshot below.

Problem:
I m using two different texture for trees, based on the same script but using different alpha rejection values. The leaf didn't work as the transparent areas were filled with another texture.

Code: Select all

material fir // WORKING!
{
    receive_shadows on
	technique
	{
		pass
		{
			diffuse 0.8 0.8 0.8 1.0
			ambient 0.8 0.8 0.8 1.0
			
			scene_blend alpha_blend
			alpha_rejection greater 196
				
			texture_unit
			{	       			

				texture fir.png
			}
		}
	}
}

material leaf  // NOT WORKING!
{
    receive_shadows on
	technique
	{
		pass
		{
			diffuse 0.8 0.8 0.8 1.0
			ambient 0.8 0.8 0.8 1.0
			
			scene_blend alpha_blend
			alpha_rejection greater 254 // DIFFERENT
				
			texture_unit
			{	       	
				texture leaf.png
			}
		}
	}
}
Attachments
problems.jpg
problems.jpg (38.93 KiB) Viewed 1851 times
Last edited by technique on Sun Dec 01, 2013 9:13 pm, edited 2 times in total.
Image
Kingdoms Defender offers Tower Defense action with breathtaking 3-D graphics for your mobile Android device.

Give it a try:
Free-Version:
http://play.google.com/store/apps/detai ... ender_free

Full-Version:
http://play.google.com/store/apps/detai ... msdefender
User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126
Contact:

Re: Ogre 1.9 ES 2.0 RTSS Material Problems

Post by masterfalcon »

You're going to need to use your own shader for that material. The reason being that ES 2 doesn't have alpha test. So you'll need you use discard in the fragment shader.
technique
Halfling
Posts: 91
Joined: Fri Oct 22, 2010 10:46 pm
x 8

Re: Ogre 1.9 ES 2.0 RTSS Material Problems

Post by technique »

okay, but why did it work for the fir-material?
Should'nt the RTSS create all the needed shader for full material-script compatibility (e.g. emulate the fixed function pipeline)?

*update*
According to the thread: http://www.ogre3d.org/forums/viewtopic.php?f=21&t=71155 - its not recommended to use discard in any form on mobile devices. A standard alpha blending without depth test looks bad.. any suggestings whats to do?
Image
Kingdoms Defender offers Tower Defense action with breathtaking 3-D graphics for your mobile Android device.

Give it a try:
Free-Version:
http://play.google.com/store/apps/detai ... ender_free

Full-Version:
http://play.google.com/store/apps/detai ... msdefender
technique
Halfling
Posts: 91
Joined: Fri Oct 22, 2010 10:46 pm
x 8

Re: Ogre 1.9 ES 2.0 RTSS Material Problems

Post by technique »

I wrote my own shader for alpha-rejection as documented here >> http://www.ogre3d.org/forums/viewtopic.php?f=10&t=79623.

After testing the performance i could not measure any difference. In both ways (using my custom alpha-rejection compared to the standard rtss implementation) i got about 62 fps! I m only using the discard fragment shader for the alpha-rejection entitys and it seem there is no performance impact for this case at all!

Thank you for your help - i got now nice rendered trees on my phone!
Attachments
perfect.png
perfect.png (130.62 KiB) Viewed 1788 times
Image
Kingdoms Defender offers Tower Defense action with breathtaking 3-D graphics for your mobile Android device.

Give it a try:
Free-Version:
http://play.google.com/store/apps/detai ... ender_free

Full-Version:
http://play.google.com/store/apps/detai ... msdefender
Post Reply