setShadowTextureCasterMaterial and transparent caster

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.
User avatar
lf3thn4d
Orc
Posts: 478
Joined: Mon Apr 10, 2006 9:12 pm
x 12

Post by lf3thn4d »

ok. sorry to buzz. me sits quietly and wait. :P
User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
x 4
Contact:

Post by tuan kuranes »

Sinbad applied the patch to CVS.
User avatar
Red5_StandingBy
Greenskin
Posts: 109
Joined: Mon Jun 26, 2006 1:06 pm
Location: Turkey

Post by Red5_StandingBy »

I got the latest version today. Yes, now it is working for me :)

Thanks a lot.
MaxDM
Gnoblar
Posts: 10
Joined: Thu Jun 14, 2007 4:48 pm

Post by MaxDM »

Little bug here
Technique copy constructor dosn't copy shadow materal properties,
and many functions like Material::clone, return new material without
shadow material.
It fixed simply:

Code: Select all

Technique& Technique::operator=(const Technique& rhs)
    {
        mName = rhs.mName;
		this->mIsSupported = rhs.mIsSupported;
        this->mLodIndex = rhs.mLodIndex;
		this->mSchemeIndex = rhs.mSchemeIndex;

		//START OF NEW CODE
		this->mShadowCasterMaterial=rhs.mShadowCasterMaterial;
		this->mShadowCasterMaterialName=rhs.mShadowCasterMaterialName;
		this->mShadowReceiverMaterial=rhs.mShadowReceiverMaterial;
		this->mShadowReceiverMaterialName=rhs.mShadowReceiverMaterialName;
		//END OF NEW CODE

		// copy passes
		removeAllPasses();
		Passes::const_iterator i, iend;
		iend = rhs.mPasses.end();
		for (i = rhs.mPasses.begin(); i != iend; ++i)
		{
			Pass* p = new Pass(this, (*i)->getIndex(), *(*i));
			mPasses.push_back(p);
		}
        // Compile for categorised illumination on demand
        clearIlluminationPasses();
        mIlluminationPassesCompilationPhase = IPS_NOT_COMPILED;
		return *this;
    }
User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
x 4
Contact:

Post by tuan kuranes »

Can you post a patch on Ogre sourceforge tracker to make sure it's not lost in forum and sinbad can apply it easily ?
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 »

Got it, thanks.
User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
x 4
Contact:

Post by tuan kuranes »

just checked playpen testTextureShadowsTransparentCaster() but it didn't work.

Ogre.log states :
Compiler error: unknown error in Example.material 950 token "shadow_caster_material" is not recognized
...951...
...1067...
...1068 ...
...1184 ...
...1185...
Seems Material Compiler waits for 'shadow_caster_material_name' instead of 'shadow_caster_material' and 'shadow_receiver_material_name' instead of 'shadow_receiver_material'

Btw, Shoggoth Wiki Notes doesn't give any info on this.
User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
x 4
Contact:

Post by tuan kuranes »

Everything works in latest shoggoth, but script template inheritance using texture variables.


@Praetor: I tried script proposed above but it didn't work (shadow_caster_material unrecognised). Tried nearly everything since and cannot find anything.

Any Idea to make that work ?
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 »

Hrm, everything looks ok in the code, weird. I've been using this feature myself for OgreSpeedTree but I build the materials in code rather than script. Will take a look...
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 »

Seems fine to me, this parses successfully:

Code: Select all

material base
{
	technique A
	{
		scheme A_Scheme

		shadow_caster_material Testing
		shadow_receiver_material Testing
	}
	technique B
	{
		scheme B_Scheme
	}
}
It's nonsense, but the parser process it correctly. And like I say, I'm using this feature (from code) in OgreSpeedTree.

[edit]Fixed the manual though, that was still referring to shadow_caster_material_name
User avatar
Praetor
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3335
Joined: Tue Jun 21, 2005 8:26 pm
Location: Rochester, New York, US
x 3
Contact:

Post by Praetor »

Can you give an example of a script not working?
User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
x 4
Contact:

Post by tuan kuranes »

What doesn't work is "texture aliasing across that shadow_caster_material link" so that you can just inherit main material and doesn't have to make ugly material duplicates when you're not using same alpha texture.

What doesn't work is what praetor posted above,
as it drops a 'unknown token' which is somewhat confusing as it breaks in compiler code near "missing argument" checking )

Code: Select all

material SomeShadowCasterMaterialName
{
    technique
   {
        pass
       {
            texture_unit $myAlpha
           {}
       }
}
material AlphaMaterialTemplate
{
    technique
   {
       // standard colour passes in here
        pass
       {
           texture_unit $myDiffuse
           {}
           texture_unit $myNormal
           {}
            texture_unit $myAlpha
           {}
       }
        shadow_caster_material SomeShadowCasterMaterialName : SomeShadowCasterMaterialName{}   
   }
}

material myTransparentMat : AlphaMaterialTemplate
{
    set $myDiffuse blah_diffuse.dds
    set $myNormal blah_normal.dds
    set $myAlpha blah_alpha.dds
} 

What I'm currently doing to make it work :

Code: Select all


set $myAlpha ""

material SomeShadowCasterMaterialName
{
     technique
   {
        pass
       {
            texture_unit $myAlpha
           {}
       }
}
material AlphaMaterialTemplate
{
    technique A
   {
        shadow_caster_material SomeShadowCasterMaterialName 
		
       // standard colour passes in here
        pass 
       {
           texture_unit $myDiffuse
           {}
           texture_unit $myNormal
           {}
            texture_unit $myAlpha
           {}
       }
   }
}


material mySomeShadowCasterMaterialName
{
    set $myAlpha blah_alpha.dds
}
material myTransparentMat : AlphaMaterialTemplate
{
   technique A
   {
		shadow_caster_material mySomeShadowCasterMaterialName 
   }
    set $myDiffuse blah_diffuse.dds
    set $myNormal blah_normal.dds
    set $myAlpha blah_alpha.dds
} 
User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
x 4
Contact:

Post by tuan kuranes »

@Praetor: Did you get it working ?
User avatar
Praetor
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3335
Joined: Tue Jun 21, 2005 8:26 pm
Location: Rochester, New York, US
x 3
Contact:

Post by Praetor »

Oh this totally slipped through the cracks, sorry. Thanks for the example because I know exactly what is wrong.

The variable definitions are not being shared across the shadow_caster_material keyword. So you're setting the $myAlpha variable on a subclass of AlphaMaterialTemplate. The only connection being the shadow_caster_material stuff.

I'm not sure if conceptually sharing the variables is good or not. What happens if multiple materials reference the same shadow caster material but with different variables?

In terms of implementation, since I just noticed this again I don't know how hard it would be. Let me look into it.
User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
x 4
Contact:

Post by tuan kuranes »

I'm not sure if conceptually sharing the variables is good or not. What happens if multiple materials reference the same shadow caster material but with different variables?
That was the beauty of your solution, each material needing a shadow caster modified would instantiate a material from the template with the variable set accordingly.
shadow_caster_material InstantiedShadowCasterMaterialName : templateShadowCasterMaterialName{}
User avatar
Praetor
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3335
Joined: Tue Jun 21, 2005 8:26 pm
Location: Rochester, New York, US
x 3
Contact:

Post by Praetor »

Code: Select all

shadow_caster_material SomeShadowCasterMaterialName : SomeShadowCasterMaterialName{}  
I skimmed over that line sorry. The only thing will be that you'll need to use a different name, more like

Code: Select all

shadow_caster_material SomeOtherShadowCasterMaterialName : SomeShadowCasterMaterialName{}  
That way it is instantiated as a different material from the template and any other users of the template.

Right now I don't think this is how shadow_caster_material works. As it is, it is just a property that takes a material name period. It will need to be changed to be a full sub-object of techniques which instantiates new materials and can be inherited etc. Luckily that isn't a difficult change. The variable sharing may be.
Post Reply