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
Wretched_Wyx
Orc
Posts: 498
Joined: Thu Mar 16, 2006 5:27 pm
Contact:

Re: A new feature in OGRE - CgFx support

Post by Wretched_Wyx »

So how would you reference the lights from the shader? Through say, the name of the light in the shader itself, or would the lights be numbered? I haven't actually toyed around with modifying materials via code too much yet, so this is a little over my head. I'm reading over some stuff, but I'm not sure it applies to this exactly.

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:

Re: A new feature in OGRE - CgFx support

Post by Praetor »

This is not CgFX specific at this point. This is just the general way Ogre manages lights.

Each object will have a list of lights affecting it. These are sorted based on a number of criterion. The shaders will reference lights by index. So if a shader wants to take in 3 lights it will often reference indices 0-2. These refer to the 1st, 2nd, and 3rd lights within the object's light list. So, when the lighting parameters are updated just before that object gets rendered, it updates those parameters based on the referenced index lookups into its local light list.

For much more manual control you can bypass this automated system. This would mean not using auto params for the shaders, but normal constants which you update yourself with light position, color, etc.
Game Development, Engine Development, Porting
http://www.darkwindmedia.com

User avatar
Wretched_Wyx
Orc
Posts: 498
Joined: Thu Mar 16, 2006 5:27 pm
Contact:

Re: A new feature in OGRE - CgFx support

Post by Wretched_Wyx »

Yes, the manual path is what I was looking for. But I'm a bit confused. If I make an Ogre scene without any lights, but made one in the mental mill shader... voila it has light. If I make a light in Ogre, it has no bearing on the shader. What I'm specifically wanting to do is, create a light that affects the shader, without having to make the light in mental mill.

I'm having a hard time finding any documentation on controlling this stuff manually, otherwise I probably wouldn't be asking. Eventually I want to have control of all the normal stuff- ambient light color, projections, light color, etc. So there is no other way to do this in a similar fashion that Ogre works with other shader/program/material scripts?

At any rate I need to understand controlling materials and shaders via code, as it will be quite useful even outside of the CgFX stuff. Again, I can't find any docs on it. A few mentions here and there, but none of it clear or concise.

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:

Re: A new feature in OGRE - CgFx support

Post by Praetor »

The mechanisms that tie lights to the CgFX shader definitions is definitely fragile. This is where the lack of standards is a problem. I have no doubt that I'm missing something there. The problem is that the CgFX file does a rather poor job of identifying things like lighting information. What's worse is that FXComposer and Mental Mill appear to have different conventions when it comes to naming.
Game Development, Engine Development, Porting
http://www.darkwindmedia.com

User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: Princeton, New Jersey, USA
x 13
Contact:

Re: Re:

Post by nikki »

jacmoe wrote:
nikki wrote:Are there any programs that export to cgfx, and support being run under Linux? mental mill does, but the artist edition doesn't. I'm looking for something hopefully free.

EDIT: I found QShaderEdit, gonna try it out now.
Had any luck getting it to run?
It bombs out when trying to compile cgfx..
I'd really like having a shadereditor in Linux. :)
It's working fine for me (till now at least), using Arch Linux, Qt 4.4. The default CgFX file it creates is bugged, it can't use the 'gl_*' variables, those are old. Just clear it and write your own simple shader (a 'one colour shader' or something) and check that it works.

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: A new feature in OGRE - CgFx support

Post by jacmoe »

I found that out too. A normal CG script compiles happily. Looks like the author confused GLSL with CG? :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: Princeton, New Jersey, USA
x 13
Contact:

Re: A new feature in OGRE - CgFx support

Post by nikki »

jacmoe wrote:I found that out too. A normal CG script compiles happily. Looks like the author confused GLSL with CG? :)
No, the older Cg versions had the 'gl_*' variables (and also semantics). Now you have only semantics.

User avatar
Curtaoa
Gnoblar
Posts: 15
Joined: Thu Jan 08, 2009 8:50 pm

Re: A new feature in OGRE - CgFx support

Post by Curtaoa »

Was very excited to see this functionality being developed, our artist was too!

Grabbed the latest SVN and started grinding, and had our artist do a test export. Didn't really work and I thought it might be helpful to post what we are working with, in case its a functionality problem.

http://northarc.com/~curt/asteroid.zip

There is the exported mesh and textures, using the glow_shader.cgfx with entity->setMaterialName( "glow_shader.cgfx" ) KINDA worked, but the overall texture was very blurry and unlit, even with scene ambient at white (current scene has a single point light centered on camera, which works well for other models).

Any help would be appreciated, this would really streamline our model exporting workflow.

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

Re: CgFx support in OGRE

Post by Assaf Raman »

Cg 2.1 February 2009 Release now available for download - here.
It may solve some of our issues.
Watch out for my OGRE related tweets here.

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:

Re: CgFx support in OGRE

Post by Praetor »

The best thing would be as Cg and CgFX develop they standardize some their non-standard annotations. I have not been updating this for some time now because I've been focusing on our mesh pipeline. When I get around to materials I'll probably take another look at this.
Game Development, Engine Development, Porting
http://www.darkwindmedia.com

tony
Gnoblar
Posts: 3
Joined: Fri Aug 29, 2008 4:12 pm

Re: A new feature in OGRE - CgFx support

Post by tony »

Curtaoa wrote:Was very excited to see this functionality being developed, our artist was too!

Grabbed the latest SVN and started grinding, and had our artist do a test export. Didn't really work and I thought it might be helpful to post what we are working with, in case its a functionality problem.

http://northarc.com/~curt/asteroid.zip

There is the exported mesh and textures, using the glow_shader.cgfx with entity->setMaterialName( "glow_shader.cgfx" ) KINDA worked, but the overall texture was very blurry and unlit, even with scene ambient at white (current scene has a single point light centered on camera, which works well for other models).

Any help would be appreciated, this would really streamline our model exporting workflow.
Hi, I tried what you show here, but I get an error that is not material because there is not this what you've tried? We worked, any information I would be very helpful.
Thank you very much and best regards ...

Danseven
Gnoblar
Posts: 2
Joined: Wed Jul 01, 2009 11:04 pm

Re: CgFx support in OGRE

Post by Danseven »

I tried but didnt work,

entity->setMaterialName( "glow_shader.cgfx" )

where is svn adress, demos or basic project?

Do you have a example, project or a code working? You can make a tutorial step by step.

Thank you

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:

Re: CgFx support in OGRE

Post by Praetor »

I have no examples or tutorials. This support is still experimental and all my tests were purely local. I never got it to the point where I was happy with its reliability. I may come back to this at some point when I swing back around to looking into content pipelines again.
Game Development, Engine Development, Porting
http://www.darkwindmedia.com

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

Re: CgFx support in OGRE

Post by Assaf Raman »

Try the glass demo from mental mill Artist Edition, it worked for me in the past.
Watch out for my OGRE related tweets here.

brurpo
Gnoblar
Posts: 1
Joined: Thu Jul 02, 2009 9:38 pm

Re: CgFx support in OGRE

Post by brurpo »

well I can't get this to work.
Can you guys please tell us the SVN address?

User avatar
boyamer
Orc
Posts: 459
Joined: Sat Jan 24, 2009 11:16 am
Location: Italy
x 6

Re: CgFx support in OGRE

Post by boyamer »

so cgFX support is full supported?

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: CgFx support in OGRE

Post by jacmoe »

No. It's still very experimental.
Read the rest of this topic and you'll see that the main problem is Cg's and CgFx's lack of standard annotations.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

cyrfer
Orc
Posts: 424
Joined: Wed Aug 01, 2007 8:13 pm
Location: Venice, CA, USA
x 7

Re: CgFx support in OGRE

Post by cyrfer »

What's the status of CgFx support? Is this on pause because it depends on other features? I see support for CgFx as the best way to get nice materials out of tools and into OGRE since I've found a number of programs that export CgFx (Shader FX, FX Composer). I can definitely help with testing, but I doubt I'll have time to help with development. I hope that tools support continues to be a priority for OGRE. I don't see any tool right now that gets shaders out of a designer tool and into OGRE, so this one seems like a great tool to support. :)
Last edited by cyrfer on Thu Dec 03, 2009 1:42 am, edited 1 time in total.

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

Re: CgFx support in OGRE

Post by Assaf Raman »

A better CgFX support is not planned. The team has done as much as it can with this feature for now. We will welcome any patch – but none of us plan to work on this as far as I know.

Can you give specific cases that are needed by you?
Personally I believe the right place to integrate new shaders is to add them to the RT shader system, the big problem with the shader outputs of the tools you wrote about is that the outputted shaders are not flexible – using the output directly will only work for very specific cases. When you add a shader to the RT shader system – you are able to modify the sense without changing the shader code and you get fog\lighting\texture mapping and much more for free. Give it a try.
Watch out for my OGRE related tweets here.

cyrfer
Orc
Posts: 424
Joined: Wed Aug 01, 2007 8:13 pm
Location: Venice, CA, USA
x 7

Re: CgFx support in OGRE

Post by cyrfer »

Hi Asaaf,
Thanks for your contributions to this project.
Can you give specific cases that are needed by you?
in 3DS Max, I would like to design a shader in Shader FX, assign a material using this shader to a mesh, and export everything, load the mesh with OGRE, all without any hand editing anything. Because Shader FX exports to CgFX, it seems like support for CgFX would be very helpful.
We will welcome any patch – but none of us plan to work on this as far as I know.
Ok, I'll keep this in mind. I wanted it for my current project, but I don't have the budget to do it right now. I will consider contributing for my next project.
the big problem with the shader outputs of the tools you wrote about is that the outputted shaders are not flexible
As far as I can tell, shaders created by those tools are as flexible as if they were written by hand. I'm confused by this statement.
Personally I believe the right place to integrate new shaders is to add them to the RT shader system
I don't know what is the "RT shader system".

Thanks for the response!

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

Re: CgFx support in OGRE

Post by Assaf Raman »

Look at this thread for RT shader system.
Watch out for my OGRE related tweets here.

xte
Gnoblar
Posts: 4
Joined: Mon Feb 22, 2010 2:31 pm

Re: CgFx support in OGRE

Post by xte »

Hi,

I'm trying to use the CgFxScriptLoader, but I'm getting stuck with linker errors using visual studio 2008 sp1.

I downloaded and built ogre 1.7rc1 without problems, I could compile and run a simple application using the appwizard.

I'm not sure about what is the right way to use the plugin. I basically include "Plugins/CgProgramManager/OgreCgFxScriptLoader.h", add the "Plugin_CgProgramManager_d.lib" (in debug mode) to the additional dependencies, and try to create an Ogre::CgFxScriptLoader object.

But none of the methods of CgFxScriptLoader can be linked. I'm (obviously) new to ogre and can't figure out what I should do to get it to work. I guess its a simple library problem but...

If anyone can help it would be greatly appreciated! And If someone can post a working project using CgFxScriptLoader it would be great.

Thank you.

Here is what visual studio says when trying to call getSingleton() (or anything else from CgFxScriptLoader):

Code: Select all

1>Linking...
1>ogretest.obj : error LNK2019: unresolved external symbol "public: static class Ogre::CgFxScriptLoader & __cdecl Ogre::CgFxScriptLoader::getSingleton(void)" (?getSingleton@CgFxScriptLoader@Ogre@@SAAAV12@XZ) referenced in function "protected: virtual void __thiscall ogretest::createScene(void)" (?createScene@ogretest@@MAEXXZ)
1>bin\Debug\ogretest.exe : fatal error LNK1120: 1 unresolved externals

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

Re: CgFx support in OGRE

Post by Assaf Raman »

Hi, what do you want to do with the CgFx plugin? What is your use?
Watch out for my OGRE related tweets here.

xte
Gnoblar
Posts: 4
Joined: Mon Feb 22, 2010 2:31 pm

Re: CgFx support in OGRE

Post by xte »

Hi!

Basically I need to get into an ogre application some shaders created with a tool like fxcomposer or renderMonkey and loadable in 3ds max.

I was going to try to code a .fx or .cgfx to .material converter, but I found this extension and would like to see if it can be useful for us.

The main purpose of this is to be able to preview shaders in 3ds max before getting them in ogre.

Ofusion looks dead and is not really an option unfortunately.

Thanks for your time! :)

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

Re: CgFx support in OGRE

Post by Assaf Raman »

What type of shaders do you need there? Bump map? Light map? What?
Watch out for my OGRE related tweets here.

Post Reply