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
Brocan
Orc
Posts: 441
Joined: Tue Aug 01, 2006 1:43 am
Location: Spain!!
x 8

Post by Brocan »

Assaf Raman wrote:This doesn't work yet.
I hope I will post something working soon.
I am almost there in getting some basic samples working.
Waiting then :D

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 »

Got the basic to work, here is the glass demo from mental mill Artist Edition:
Image

I just used the exported cgfx file from mental mill Artist Edition without any change to the cgfx file and without creating any new file.

I will post commit really soon.
Watch out for my OGRE related tweets here.

User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 99
Contact:

Post by Wolfmanfx »

Nice work

Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
x 1
Contact:

Post by Vectrex »

oh cool. Didn't know about this

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

Post by Brocan »

Very very very nice.

My mental mill shaders are waiting :D

Good work :D

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 »

If you will post some cgfx shaders and the textures they need - I will be able to test them and make sure they work.
Watch out for my OGRE related tweets here.

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

Post by Brocan »

Assaf Raman wrote:If you will post some cgfx shaders and the textures they need - I will be able to test them and make sure they work.
Sorry, but my shaders are very basic, based on the examples. I'm learning mental mill now :(

BTW if I make a good shader be sure that I will post it :D

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 »

That is fine. I will check the samples that come with it.
Watch out for my OGRE related tweets here.

User avatar
SiENcE
Goblin
Posts: 231
Joined: Thu May 11, 2006 3:07 pm
Location: Berlin
Contact:

Post by SiENcE »

You can try the samples from the NVIDIA Shader Library - CgFX.

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 commited to 1.8 the CgFx script loader as part of the Cg program manager plugin.
This loader loads files with the extension cgfx from the OGRE resource pool and creates ogre material and cg programs as according to what exists in the cgfx file.
The name of the material that is created is similar to the name of the cgfx file - so for a file named "glass.cgfx" it will be "glass.cgfx".
I tested this code with exporting some of the samples that come with "mental mill (R) Artist Edition" (you get it free with FX Composer 2.5).
Most of the hard code is written - the main feature that is missing are:
1. All sort of pass state translations - like alpha blend and such.
2. More standard documentation.
3. Error logging and exception handling.

I really worked hard on this feature; I guess about 7 full days.
I will be really happy if the community will share nice cgfx shaders by posting the shaders and textures (and possibly the relevant source code).

This code is my gift to the community for the Jewish holyday season.
Watch out for my OGRE related tweets here.

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

Post by Brocan »

Downloading ;)

Thanks :D

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 »

I'm checking it out now. Welcome gift indeed. Can you explain a little bit about item #1? What needs to be done. I might be poking around at it this week.

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 »

@Praetor: I created most of what it needed to convert cgfx states to ogre states - there are switch case statements for everything – and also “getValueâ€
Watch out for my OGRE related tweets here.

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 »

This is one of the best gift to community - thanks Assaf. I am downloading 1.7 just to test this out.
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
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 »

Ok, I see what's going on. Lots to fill in. I'm not sure how some of those options will map to materials. But, might as well just get started filling in what can be filled in. I imagine the most common options will be trivial to link up and should give us pretty decent coverage.

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

Post by Brocan »

I have a question, how are the lights mapped to ogre?

Because i have loaded the examples provided by MentalMill (I have just exported it to cgfx) but the examples that have a light, don't run well in ogre.

I have created a point light and nothing.

Paralax example of mental mill into ogre:

ImageImage


With a simple phong shader:

ImageImage

The phong shader
[EDIT by AssafRaman]I changed the long code quote to a file link - I don't allow such long code pastes in my threads, upload to google pages and give a link to such code[/EDIT]

Note: the ogrehead is where i have the point light
Last edited by Brocan on Wed Sep 24, 2008 2:59 pm, edited 2 times in total.

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 »

I've been looking at the mappings and implementing a few (without really testing these mappings yet...)

The lights I don't think can be mapped to Ogre in any way. Basically CgFx is stepping into the scene management arena with lights being bound to shaders.

In your parallax example, can you try manually creating an Ogre light in the scene? It's guaranteed that some options and settings in CgFx simply won't have natural mappings into Ogre.

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 know about this issue, I didn't have time to look at it yet.
Watch out for my OGRE related tweets here.

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

Post by Brocan »

Praetor wrote:The lights I don't think can be mapped to Ogre in any way. Basically CgFx is stepping into the scene management arena with lights being bound to shaders.
Yeah, i'm sure of that.

In my photos i have a ogre light point created where the ogrehead is. :wink:

Edit: Ah, ok Assaf, i thought that was a problem in my computer :D
Edit2: I don't remember googlepages :oops: to upload the code, sorry :D

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 »

Here is the model I am using for testing (if anyone needs this kind of test mesh...)
Image
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 »

Btw., the last commit regarding this feature broke compilation under linux:

Code: Select all

../../../PlugIns/CgProgramManager/include/OgreCgFxScriptLoader.h:1472: error: expected ‘,’ or ‘...’ before ‘ogreProgramType’
../../../PlugIns/CgProgramManager/include/OgreCgFxScriptLoader.h:1472: error: ISO C++ forbids declaration of ‘GpuProgramType’ with no type
../../../PlugIns/CgProgramManager/include/OgreCgFxScriptLoader.h:1473: error: ‘GpuProgramParametersSharedPtr’ has not been declared
../../../PlugIns/CgProgramManager/include/OgreCgFxScriptLoader.h:1474: error: ‘GpuProgramParametersSharedPtr’ has not been declared
../../../PlugIns/CgProgramManager/include/OgreCgFxScriptLoader.h:1477: error: ‘GpuProgramParametersSharedPtr’ has not been declared
../../../PlugIns/CgProgramManager/include/OgreCgFxScriptLoader.h:1478: error: ‘GpuProgramParametersSharedPtr’ has not been declared
../../../PlugIns/CgProgramManager/include/OgreCgFxScriptLoader.h:1479: error: ‘GpuProgramParametersSharedPtr’ has not been declared
../../../PlugIns/CgProgramManager/include/OgreCgFxScriptLoader.h:1480: error: ‘GpuProgramParameters’ has not been declared
../../../PlugIns/CgProgramManager/include/OgreCgFxScriptLoader.h:1480: error: expected ‘,’ or ‘...’ before ‘&’ token
OgreCgFxScriptLoader.cpp:2784: error: prototype for ‘void Ogre::CgFxScriptLoader::parseCgProgram(_CGpass*, Ogre::Pass*, Ogre::GpuProgramType)’ does not match any in class ‘Ogre::CgFxScriptLoader’
../../../PlugIns/CgProgramManager/include/OgreCgFxScriptLoader.h:1472: error: candidate is: void Ogre::CgFxScriptLoader::parseCgProgram(_CGpass*, Ogre::Pass*, int)
OgreCgFxScriptLoader.cpp:2881: error: prototype for ‘void Ogre::CgFxScriptLoader::parseCgProgramParameters(_CGpass*, Ogre::GpuProgramParametersSharedPtr)’ does not match any in class ‘Ogre::CgFxScriptLoader’
../../../PlugIns/CgProgramManager/include/OgreCgFxScriptLoader.h:1473: error: candidate is: void Ogre::CgFxScriptLoader::parseCgProgramParameters(_CGpass*, int)
OgreCgFxScriptLoader.cpp:2927: error: prototype for ‘void Ogre::CgFxScriptLoader::parseCgProgramParameter(_CGparameter*, Ogre::GpuProgramParametersSharedPtr, const Ogre::String&)’ does not match any in class ‘Ogre::CgFxScriptLoader’
../../../PlugIns/CgProgramManager/include/OgreCgFxScriptLoader.h:1474: error: candidate is: void Ogre::CgFxScriptLoader::parseCgProgramParameter(_CGparameter*, int, const Ogre::String&)
OgreCgFxScriptLoader.cpp:3360: error: prototype for ‘const bool Ogre::CgFxScriptLoader::cgSemanticToOgreAutoConstantType(const char*, Ogre::GpuProgramParameters::AutoConstantType&)’ does not match any in class ‘Ogre::CgFxScriptLoader’
../../../PlugIns/CgProgramManager/include/OgreCgFxScriptLoader.h:1480: error: candidate is: const bool Ogre::CgFxScriptLoader::cgSemanticToOgreAutoConstantType(const char*, int)
OgreCgFxScriptLoader.cpp:3576: error: prototype for ‘bool Ogre::CgFxScriptLoader::parseAutoConstantParam(_CGparameter*, Ogre::GpuProgramParametersSharedPtr, const Ogre::String&)’ does not match any in class ‘Ogre::CgFxScriptLoader’
../../../PlugIns/CgProgramManager/include/OgreCgFxScriptLoader.h:1479: error: candidate is: bool Ogre::CgFxScriptLoader::parseAutoConstantParam(_CGparameter*, int, const Ogre::String&)
OgreCgFxScriptLoader.cpp:3601: error: prototype for ‘void Ogre::CgFxScriptLoader::parseFloatCgProgramParameter(CGtype, _CGparameter*, Ogre::GpuProgramParametersSharedPtr, const Ogre::String&)’ does not match any in class ‘Ogre::CgFxScriptLoader’
../../../PlugIns/CgProgramManager/include/OgreCgFxScriptLoader.h:1477: error: candidate is: void Ogre::CgFxScriptLoader::parseFloatCgProgramParameter(CGtype, _CGparameter*, int, const Ogre::String&)
OgreCgFxScriptLoader.cpp:3677: error: prototype for ‘void Ogre::CgFxScriptLoader::parseIntCgProgramParameter(CGtype, _CGparameter*, Ogre::GpuProgramParametersSharedPtr, const Ogre::String&)’ does not match any in class ‘Ogre::CgFxScriptLoader’
../../../PlugIns/CgProgramManager/include/OgreCgFxScriptLoader.h:1478: error: candidate is: void Ogre::CgFxScriptLoader::parseIntCgProgramParameter(CGtype, _CGparameter*, int, const Ogre::String&)
Maybe someone can fix this, as I don't feel very home in that region of OGRE ;).

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 »

How can I compile and get this type of errors on windows?
Watch out for my OGRE related tweets here.

User avatar
captnoord
Halfling
Posts: 42
Joined: Wed Apr 30, 2008 11:01 am

Post by captnoord »

maybe cygwin?
To be or not to be that is the question that dazzles us for centuries, now modern science have found the answer: 0x2B | ~0x2B == 0xFF
Image

User avatar
sparkprime
Ogre Magi
Posts: 1137
Joined: Mon May 07, 2007 3:43 am
Location: Ossining, New York
x 13
Contact:

Post by sparkprime »

Last time I tried to compile ogre under cygwin g++, the linker segfaulted. After some manual hackery, I got it to link but there were subtle bugs that I was tied up with for days before realising it was the compiler's fault. I definitely don't recommend using cygwin's g++ for serious dev work.

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

Post by SunSailor »

Assaf Raman wrote:How can I compile and get this type of errors on windows?
I can't tell you, as I'm currently compiling the HEAD under linux only, maxbe the error doesn't even occure under windows. My recommendation would be to set up a VM with OpenSuSE (The distribution I'm enforced to use on the computer I compiled it on) and try it there. That's the most easy way to reproduce it I can think of (beside the download, but I guess, you're well connected).

Post Reply