CgFx support in OGRE

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
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post by Assaf Raman »

Can you have a go fixing it yourself and giving back a patch?
Watch out for my OGRE related tweets here.

User avatar
SunSailor
Gnoll
Posts: 699
Joined: Sun Jan 02, 2005 5:45 pm
Location: Velbert, Germany
x 2
Contact:

Post by SunSailor »

Hardly, I can have a look at it, but as I'm absolutely not in that topic, I can't guarrantee you anything.
Edit: What I can tell from here is, that GpuProgramType isn't defined at that point, can it be, that there is a header file included in platform dependent parts only?

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post by Assaf Raman »

I just compiled with CodeBlocks and gcc with no problem on windows.

I am not going to create the environment needed to solve this issue – sorry.

This is an issue that can be solved quickly if someone with the same compile environment as you will try to solve it.

So – you can try to solve it yourself or wait for this someone to have the time to do it.

Another option for you is to remove CgFxScriptLoader and the reference for it from the project.
Watch out for my OGRE related tweets here.

User avatar
SunSailor
Gnoll
Posts: 699
Joined: Sun Jan 02, 2005 5:45 pm
Location: Velbert, Germany
x 2
Contact:

Post by SunSailor »

Ok, leave HEAD broken, not my project... But don't say, I didn't offer my help.

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post by Assaf Raman »

Thanks for the notice and help.
Watch out for my OGRE related tweets here.

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post by Assaf Raman »

After thinking more about the last post I decided to clear out a few things that are perhaps not as obvious as I was thinking.

First – the head can sometimes be broken – it is the active development branch – and is broken because of it from time to time.

Secondly – The issue you described will be fixed by the time 1.8 will come out or broken code will be removed but in no case we will release an official broken version.

When you want to work with the latest code – you take the chance that some new features are not fully developed.
Watch out for my OGRE related tweets here.

CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 57
Contact:

Post by CABAListic »

I just took a quick look, the problem is that in the OgreCgFxScriptLoader.h the enum GpuProgramType is unknown (and probably a bunch of other stuff). All those nasty error lines go away if you simply add

Code: Select all

#include "OgreGpuProgram.h"
to the file. I'll assume that header is automatically pulled in from somewhere under Windows...

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post by Assaf Raman »

Thanks CABAListic.

I have committed this fix. Anyone that had the compile issue on linux can update and retry to compile.
Watch out for my OGRE related tweets here.

User avatar
SunSailor
Gnoll
Posts: 699
Joined: Sun Jan 02, 2005 5:45 pm
Location: Velbert, Germany
x 2
Contact:

Post by SunSailor »

Shure, HEAD is the development version, that this can be broken is not the deal. If someone offers his help, because he has a setup, where the bug is reproduceable, he should be taken serious and one should take this offer, at least, that is how it is handled here in my company. We are always happy, if one of our users serves the solution on a plate of silver, we don't put them down with blames and ignorance.
And thanks, CABAListic, I already found that out, too, but didn't react, as help doesn't seem to be very welcome here.

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post by Assaf Raman »

@SunSailor: from what you wrote it seems that you got offended.
If that is the case I want to apologize – I never meant to insult you in any way.
You offered your help and I tried to ask you to go ahead and help – but from some reason (perhaps a language or other communication barrier) my point didn’t go through.
Let’s not continue on this issue – I will try to be more sensitive in the future.
Watch out for my OGRE related tweets here.

User avatar
xadhoom
Minaton
Posts: 973
Joined: Fri Dec 28, 2007 4:35 pm
Location: Germany
x 1

Post by xadhoom »

Hi!

How is the status of this importer regarding lighting and pass issues?
Is there also some kind of documentation available?

Thanks for sharing!

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post by Assaf Raman »

lighting is still not done.
documentation is this thread for now.
Watch out for my OGRE related tweets here.

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post by Assaf Raman »

I found out why most of the bump\normal maps cgfx from "mental mill (R) Artist Edition" didn’t work in OGRE, turns out that you need to have tangent and binormal as part of the vertex buffer for the model to work.

After I added them – the cgfx files look like they should.

Here are sample screenshots (with no ambient light):
Image
Image

I added tangent and binormal to my sample model and to the ogre head model.
Here is the ogre head with tangent and binormal.
Here is the cgfx test model with tangent and binormal.

I also fixed a small endless loop bug – so get the latest code from the SVN.
Watch out for my OGRE related tweets here.

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post by Assaf Raman »

OGRE can create the tangents for you for an existing mesh using code like this (used in many samples):

Code: Select all

		MeshPtr m = MeshManager::getSingleton().load("ogrehead.mesh", 
			ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
		unsigned short src, dest;
		if (!m->suggestTangentVectorBuildParams(VES_TANGENT, src, dest))
		{
			m->buildTangentVectors(VES_TANGENT, src, dest);
		} 
I used my own code because I wanted also the binormal, perhaps I wasted my time writing it, but here it is if anyone ever wants it:
void addTangentAndBinormalToMeshByNormal( String meshName )
Watch out for my OGRE related tweets here.

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post by Assaf Raman »

I added all the light support I can with the existing shader constant types.
Code is in the SVN.

The following code (red directional light from above):

Code: Select all

		mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));
		Vector3 dir(-1, -1, 0.5);
		dir.normalise();
		Light* l = mSceneMgr->createLight("light1");
		l->setDiffuseColour(ColourValue::Red);
		l->setSpecularColour(ColourValue::Red);
		l->setType(Light::LT_DIRECTIONAL);
		l->setDirection(dir);
Gets me the following screenshot:
Image
Watch out for my OGRE related tweets here.

Stickymango
Hobgoblin
Posts: 540
Joined: Wed Nov 17, 2004 4:36 pm
Location: Middlesbrough, England

Post by Stickymango »

I'm getting the following error when loading the cg_ProgramManager plugin:

Code: Select all

10:13:03: OGRE EXCEPTION(7:InternalErrorException): Unable to Set create State: CG ERROR : The parameter used is invalid. in CgFxScriptLoader::CgStateListener::init at ..\src\OgreCgProgramManagerDll.cpp (line 66)
I'm trying to use this with 1.6.0 should that be okay, any idea what the problem might be?

User avatar
Brocan
Orc
Posts: 441
Joined: Tue Aug 01, 2006 1:43 am
Location: Spain!!
x 8

Post by Brocan »

Great, i will checkout the svn, compile and try this night :D

User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2702
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 47

Post by syedhs »

Stickymango wrote: I'm trying to use this with 1.6.0 should that be okay, any idea what the problem might be?
I think that should be okay, as the changes are only done within CG plugin - I am doing it myself. You will have to copy over OgreString.cpp/.h though, as there is an additional member function for StringUtil which is used by new CG plugin.
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post by Assaf Raman »

Stickymango wrote:I'm getting the following error when loading the cg_ProgramManager plugin:

Code: Select all

10:13:03: OGRE EXCEPTION(7:InternalErrorException): Unable to Set create State: CG ERROR : The parameter used is invalid. in CgFxScriptLoader::CgStateListener::init at ..\src\OgreCgProgramManagerDll.cpp (line 66)
I'm trying to use this with 1.6.0 should that be okay, any idea what the problem might be?
You are using the latest 1-6 code from the SVN and getting this error?
(This is unrelated to this thread, right? but I do want to help you...)
[EDIT1] I see some problems there(1-6), I will try to fix and update the SVN later, I will post when I done that. [/EDIT1]
[EDIT2] No - the problem in 1-6 were releated to the ParticleGS when you run dx9, can you explain how I can create the same problem you have on my computer? [/EDIT2]
Watch out for my OGRE related tweets here.

Stickymango
Hobgoblin
Posts: 540
Joined: Wed Nov 17, 2004 4:36 pm
Location: Middlesbrough, England

Post by Stickymango »

What I did was download svn version into new folder, copied cgpluginmanager folder into my stable 1.6.0 folder, built the plugin then copied the dll to my application folder and ran...

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post by Assaf Raman »

Do you get the same problem also in the OGRE samples there?
Watch out for my OGRE related tweets here.

Stickymango
Hobgoblin
Posts: 540
Joined: Wed Nov 17, 2004 4:36 pm
Location: Middlesbrough, England

Post by Stickymango »

Yes. I tried copying the updated OgreString files and rebuilding OgreMain and still the same :?

Stickymango
Hobgoblin
Posts: 540
Joined: Wed Nov 17, 2004 4:36 pm
Location: Middlesbrough, England

Post by Stickymango »

Found out what the problem was, I had an old version of the cg.dll from OGRE 1.2/4, I downloaded the latest cg toolkit and it now works fine :)

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post by Assaf Raman »

I am happy that it works for you.
If find any problem or create nice shaders that you want to share with us post them here.
Watch out for my OGRE related tweets here.

ShadowFire
Gnoblar
Posts: 13
Joined: Tue Jul 29, 2008 2:59 pm

Ogre 1.6 support

Post by ShadowFire »

Hey, I just wanted to let you know that when building the current svn against 1.6 it complains about not having stringutil::replace all, I'm only using 2.0 and not 2.1 so I commented out line 170 of OgreCgProgram.cpp. We could probably just put a helper function in there to do the same thing to maintain 1.6 compatibility and usage with cg 2.1. What do you think?

EDIT - looks like this was already noted above, sorry for the repeat

Post Reply