irrCg v0.8 (Initial) - CgFX (Texture States, MultiPass etc.)
Thanks h.a.n.d. This improvment version is avaiable in trunk of IrrCg SVN.
OK, I can submit SSAO and PSSM examples (currently only binary + shader source). I should release final versions (full source code) of this examples soon with IrrCg 7.1.
In SSAO You can customize: radious, scale, modificator and multiplier (strengh of dark)
SSAO pass:
SSAO with textures:
You can download it from:
http://www.sendspace.com/file/j1bphn
OK, I can submit SSAO and PSSM examples (currently only binary + shader source). I should release final versions (full source code) of this examples soon with IrrCg 7.1.
In SSAO You can customize: radious, scale, modificator and multiplier (strengh of dark)
SSAO pass:
SSAO with textures:
You can download it from:
http://www.sendspace.com/file/j1bphn
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
-
- Posts: 914
- Joined: Fri Aug 03, 2007 12:43 pm
- Location: South Africa
- Contact:
Yes, of course. Your example with node rotating isn't good, for it You use POSITION from sementic and transform Matrices. You can look on example 01.BasicLighting, in this example camera position is usage by shader.h.a.n.d wrote:Hi @ all,
1. Is it possible to change some shader input parameters at runtime, after the new shader material has already been set?
2. If so, how do I do that with IrrCg?
i.e.: I want to rotate a light and every frame the shader should get the new position of this light.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
-
- Posts: 74
- Joined: Tue Jul 22, 2008 4:28 am
- Location: Los Angeles
I'm still having problems getting this to run. I tried following h.a.n.d.'s steps as well as I could. So here is everything I did, hopefully it illuminates where I'm going wrong:
Using Visual Studio 2008, Irrlicht 1.5:
1. I downloaded IrrCg_0.7, and downloaded and installed Nvidia Cg 2.1 and the November 2008 DirectX SDK.
2. I opened my current project, which runs fine. I copied both the IrrCg.h and IrrCg.cpp files into my source file directory/folder.
3. Under "include" in my project settings, I already had "../irrlicht-1.5/include" so I left that as it was. I also already had "../Microsoft DirectX SDK (November 2008)/include" so I left that there as well.
4. Under "include" in my project settings, I added in "../NVIDIA Corporation/Cg/Include"
5. Under "executable files" in my project settings, I added in "../NVIDIA Corporation/Cg/bin".. I noticed this folder had all the .dll files that Nadro put in his zip files so I didn't do anything with those dll files.
6. I did the "base" replacements indicated in h.a.n.d.'s post.
At this point I attempted to run the program to check if it would build. I got an error: Error 1 fatal error C1083: Cannot open include file: 'CD3D9Texture.h': No such file or directory c:\documents and settings\rj layton\desktop\thesis\mars\mars\irrcg.cpp 29
7. I changed the path to point to the Irrlicht/source folder where it could find those files. I got the same error with the include for the COpenGLTexture.h file, so I added it to that as well. So now my code looks like this:
So that's as far as I've gotten. Attempting to run the program again gets me a bunch of linker errors such as the following one:
Overall I get 34 unresolved externals, all in IrrCg.obj
I know I'm doing something wrong regarding the linking but I can't figure it out. Hopefully it's something simple...
Using Visual Studio 2008, Irrlicht 1.5:
1. I downloaded IrrCg_0.7, and downloaded and installed Nvidia Cg 2.1 and the November 2008 DirectX SDK.
2. I opened my current project, which runs fine. I copied both the IrrCg.h and IrrCg.cpp files into my source file directory/folder.
3. Under "include" in my project settings, I already had "../irrlicht-1.5/include" so I left that as it was. I also already had "../Microsoft DirectX SDK (November 2008)/include" so I left that there as well.
4. Under "include" in my project settings, I added in "../NVIDIA Corporation/Cg/Include"
5. Under "executable files" in my project settings, I added in "../NVIDIA Corporation/Cg/bin".. I noticed this folder had all the .dll files that Nadro put in his zip files so I didn't do anything with those dll files.
6. I did the "base" replacements indicated in h.a.n.d.'s post.
At this point I attempted to run the program to check if it would build. I got an error: Error 1 fatal error C1083: Cannot open include file: 'CD3D9Texture.h': No such file or directory c:\documents and settings\rj layton\desktop\thesis\mars\mars\irrcg.cpp 29
7. I changed the path to point to the Irrlicht/source folder where it could find those files. I got the same error with the include for the COpenGLTexture.h file, so I added it to that as well. So now my code looks like this:
Code: Select all
// Irrlicht Source Textures Headers
#ifdef IrrCgD3D9
#include "../irrlicht-1.5/source/Irrlicht/CD3D9Texture.h"
#endif
#include "../irrlicht-1.5/source/Irrlicht/COpenGLTexture.h"
So that's as far as I've gotten. Attempting to run the program again gets me a bunch of linker errors such as the following one:
Code: Select all
Error 42 error LNK2019: unresolved external symbol _cgCreateContext referenced in function "public: __thiscall IrrCg::ICgProgrammingServices::ICgProgrammingServices(class irr::IrrlichtDevice *)" (??0ICgProgrammingServices@IrrCg@@QAE@PAVIrrlichtDevice@irr@@@Z) IrrCg.obj
I know I'm doing something wrong regarding the linking but I can't figure it out. Hopefully it's something simple...
If You use Irrlicht 1.5 (or from SVN), You have to use IrrCg from SVN (first post). In all examples You have to replace:
to:
You needn't adding full path to Irrlicht sources in "#include..." entry, You should only add this source folder in project includes. I see You compile IrrCg as executable. You have to change project settings from executable to static library. That's all
Code: Select all
virtual void OnSetConstants(ICgServices* services,CGprogram Vertex,CGprogram Pixel,SMaterial Material)
Code: Select all
virtual void OnSetConstants(ICgServices* services,CGprogram Vertex,CGprogram Pixel,const SMaterial& Material)
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
-
- Posts: 74
- Joined: Tue Jul 22, 2008 4:28 am
- Location: Los Angeles
Okay, so I went back through and tried to do things in a new way. I'm still stuck, however.
I'm using Visual Studio 2008, Irrlicht 1.5. I downloaded the IrrCg from the SVN.
I copied the IrrCg.cpp and IrrCg.h files into their own folder and made a project with only those files in it. The project has the same settings as my game project, except I also put in the "Include" section the "../Irrlicht-1.5/source/Irrlicht" folder because IrrCg won't compile without it.
I set it to Release mode and changed the output to a static library like you suggested, Nadro
This produces a IrrCg.lib file and a IrrCg.obj file. At this point I'm a little confused.
Anyway, I grab the IrrCg.lib file (which is 2,134KB) and put it in the same folder as my Irrlicht.lib file, so I don't have to add any additional directories.
To test, I put it in my game project. The relevant code is:
At this point, the game still runs. I'm feeling optimistic, but I haven't done anything with IrrCg yet.
So here we go! I try just to initialize IrrCg with the following code:
... no luck! I get a bunch of errors! I've removed a bunch to save space because they're all the same type of error:
I'm a little confused because it keeps saying "IrrCg.obj" even though I haven't moved it like I did with IrrCg.lib. I'm really not too strong on compilers and stuff
So of course I run through the thread to try and figure out if I forgot anything. On page 4, Nadro suggests including the following:
I put that in my pragma comment stack...
Okay, so I take that one line out...
Okay... can't find cgD3D9.lib either... so of course the same error comes up with cgGL.lib too.
What I don't understand is why it can't find these files... though they are .dll files. Inside "C:\Program Files\NVIDIA Corporation\Cg\bin" there are a bunch of .dll files like Nadro included with his examples... cg.dll, cdD3D9.dll, cgGL.dll.... And I have this folder included in my "executable" section in project settings.
Anyway I feel really lost Hopefully all this documentation will lead to some help. Sorry for pestering, Nadro! I really appreciate the help.
I'm using Visual Studio 2008, Irrlicht 1.5. I downloaded the IrrCg from the SVN.
I copied the IrrCg.cpp and IrrCg.h files into their own folder and made a project with only those files in it. The project has the same settings as my game project, except I also put in the "Include" section the "../Irrlicht-1.5/source/Irrlicht" folder because IrrCg won't compile without it.
I set it to Release mode and changed the output to a static library like you suggested, Nadro
This produces a IrrCg.lib file and a IrrCg.obj file. At this point I'm a little confused.
Anyway, I grab the IrrCg.lib file (which is 2,134KB) and put it in the same folder as my Irrlicht.lib file, so I don't have to add any additional directories.
To test, I put it in my game project. The relevant code is:
Code: Select all
#include <irrlicht.h>
#include <Cg/cg.h>
#include "IrrCg.h"
// In the Irrlicht Engine, everything can be found in the namespace 'irr'.
using namespace irr;
// There are 5 sub namespaces in the Irrlicht Engine.
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
//irrcg namespace
using namespace IrrCg;
/ To be able to use the Irrlicht.DLL file, we need to link with the Irrlicht.lib.
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(lib, "IrrNewt.lib")
#pragma comment(lib, "IrrCg.lib")
#pragma warning(disable: 4800) //stupid boolean performance warning
#endif
So here we go! I try just to initialize IrrCg with the following code:
Code: Select all
//create the device
IrrlichtDevice* device = createDeviceEx(paramIrr);
if(!device)
return 1; //the device failed to create itself, so quit early
// Create Cg Programming Service
ICgProgrammingServices* GPU = new ICgProgrammingServices(device);
Code: Select all
1>IrrCg.lib(IrrCg.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
1>MSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
1>IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgGLDisableProfile
1>IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol __imp__cgD3D9BindProgram
1>IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgSetParameter3d
...
...
1>IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgSetParameter4i
1>C:\Documents and Settings\RJ Layton\Desktop\thesis\mars\Debug\mars.exe : fatal error LNK1120: 34 unresolved externals
So of course I run through the thread to try and figure out if I forgot anything. On page 4, Nadro suggests including the following:
Code: Select all
#pragma comment (lib,"cg.lib")
#pragma comment (lib,"IrrCg.lib")
#pragma comment (lib,"cgD3D9.lib")
#pragma comment (lib,"cgGL.lib")
Code: Select all
Error 40 fatal error LNK1104: cannot open file 'cg.lib'
Code: Select all
>IrrCg.lib(IrrCg.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
1>LINK : fatal error LNK1104: cannot open file 'cgD3D9.lib'
What I don't understand is why it can't find these files... though they are .dll files. Inside "C:\Program Files\NVIDIA Corporation\Cg\bin" there are a bunch of .dll files like Nadro included with his examples... cg.dll, cdD3D9.dll, cgGL.dll.... And I have this folder included in my "executable" section in project settings.
Anyway I feel really lost Hopefully all this documentation will lead to some help. Sorry for pestering, Nadro! I really appreciate the help.
You can found Cg libraries in NVIDIA Cg Toolkit of course. Probably You didn't install it, so You should reinstall Cg Toolkit.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
I went through the last postings and decided to setup an example
project with my working IrrCg (Win32 shared library).
It's an Eclipse project but you should be able to adapt it to VS2008 as well.
http://www.sendspace.com/file/l13d7h
Note: This is how to setup a project with an already compiled IrrCg library
with all dependencies (DirectX 9, Irrlicht-1.5/source/CD3D9Texture.cpp ...) and
unfortunately ONLY for Windows32 till now, but i guess unix/linux user are more familiar with compiling libs!
You dont have to use the included Cg-includes or libraries if you have the Cg-SDK
already on your system, but you have to include them, with your corresponding path, like I'll describe later.
The method I described some posts before is how to setup a project with the IrrCg.cpp and IrrCg.h files.
Folders:
cg - shader files for the example
Debug - compiled example
lib - the Cg and the IrrCg libraries and include files
media - example media files
src - the example .cpp
Setting up the include folders for the project:
1. lib/Cg/include
2. lib/IrrCg/include
3. Irrlicht-1.5/include
Setting up the libraries for the project:
Libraries (-l)
Irrlicht
IrrCg
Library search path (-L)
Irrlicht-1.5/bin/Win32-gcc
lib/IrrCg
I hope this will do it until the new version of IrrCg is ready to get puplic.
If you need more advise on this please post your questions.
h.a.n.d
project with my working IrrCg (Win32 shared library).
It's an Eclipse project but you should be able to adapt it to VS2008 as well.
http://www.sendspace.com/file/l13d7h
Note: This is how to setup a project with an already compiled IrrCg library
with all dependencies (DirectX 9, Irrlicht-1.5/source/CD3D9Texture.cpp ...) and
unfortunately ONLY for Windows32 till now, but i guess unix/linux user are more familiar with compiling libs!
You dont have to use the included Cg-includes or libraries if you have the Cg-SDK
already on your system, but you have to include them, with your corresponding path, like I'll describe later.
The method I described some posts before is how to setup a project with the IrrCg.cpp and IrrCg.h files.
Folders:
cg - shader files for the example
Debug - compiled example
lib - the Cg and the IrrCg libraries and include files
media - example media files
src - the example .cpp
Setting up the include folders for the project:
1. lib/Cg/include
2. lib/IrrCg/include
3. Irrlicht-1.5/include
Setting up the libraries for the project:
Libraries (-l)
Irrlicht
IrrCg
Library search path (-L)
Irrlicht-1.5/bin/Win32-gcc
lib/IrrCg
I hope this will do it until the new version of IrrCg is ready to get puplic.
If you need more advise on this please post your questions.
h.a.n.d
-
- Posts: 74
- Joined: Tue Jul 22, 2008 4:28 am
- Location: Los Angeles
Wow you guys, you're really great Thanks for helping me so much, I'm really trying hard to figure this out!
Nadro, I had installed Cg Toolkit, no problems there.
I've been having a friend try and help me with this, and when he went in and added the .lib files I mentioned above, he was able to get it to work (or at least initialize). I found out that he was including (in his include directories): "..\NVidia Corporation\Cg\include\Cg" in addition to ""..\NVidia Corporation\Cg\include" I added that in. That took care of the "Cannot find cg.lib" problems.
However, mine still didn't work. Once again the problem comes when I try and instantiate ICgProgrammingServices. Here's the error I get:
Entry Point Not Found
" The procedure entry point cgiCheckForInvalidProfileProgram could not be located in the dynamic link library cg.dll "
Any ideas on this problem?
Also, h.a.n.d, THANK YOU for your help! I haven't tried your solution yet because I feel like I'm pretty close with this method, but if it still doesn't work I will definitely give it a shot and let you know if I have any problems. You rock.
Nadro, I had installed Cg Toolkit, no problems there.
I've been having a friend try and help me with this, and when he went in and added the .lib files I mentioned above, he was able to get it to work (or at least initialize). I found out that he was including (in his include directories): "..\NVidia Corporation\Cg\include\Cg" in addition to ""..\NVidia Corporation\Cg\include" I added that in. That took care of the "Cannot find cg.lib" problems.
However, mine still didn't work. Once again the problem comes when I try and instantiate ICgProgrammingServices. Here's the error I get:
Entry Point Not Found
" The procedure entry point cgiCheckForInvalidProfileProgram could not be located in the dynamic link library cg.dll "
Any ideas on this problem?
Also, h.a.n.d, THANK YOU for your help! I haven't tried your solution yet because I feel like I'm pretty close with this method, but if it still doesn't work I will definitely give it a shot and let you know if I have any problems. You rock.
Your first problem:
If you include ..\NVidia Corporation\Cg\include\Cg
you have to write:
#include <cg.h>
in your program code.
If you include ..\NVidia Corporation\Cg\include
you have to write:
#include <Cg/cg.h>
in your program code.
Thats the difference ...
Your second problem sounds a little bit like an old NVIDIA Cg version.
Which version do you have?
http://developer.nvidia.com/object/cg_toolkit.html
http://developer.nvidia.com/object/cg_2_2_beta.html
Try to link the ..\NVidia Corporation\Cg\bin folder instead of the ..\NVidia Corporation\Cg\lib as the library path for Cg if you dont do this already.
Maybe you can upload a test project so we can check your settings on the fly.
h.a.n.d
If you include ..\NVidia Corporation\Cg\include\Cg
you have to write:
#include <cg.h>
in your program code.
If you include ..\NVidia Corporation\Cg\include
you have to write:
#include <Cg/cg.h>
in your program code.
Thats the difference ...
Your second problem sounds a little bit like an old NVIDIA Cg version.
Which version do you have?
http://developer.nvidia.com/object/cg_toolkit.html
http://developer.nvidia.com/object/cg_2_2_beta.html
Try to link the ..\NVidia Corporation\Cg\bin folder instead of the ..\NVidia Corporation\Cg\lib as the library path for Cg if you dont do this already.
Maybe you can upload a test project so we can check your settings on the fly.
h.a.n.d
I have a question: Why the heck isn't this part of Irrlicht yet?!
This thing has been around for over a year now, so what is keeping it back from getting merged into Irrlicht? Is it the extra dependency (if so, it is worth it) or is it the way it is implemented?
~DtD
On a side note, I didn't ever actually get IrrCg working because there was no code to fill alot of the stuff in IrrCgMaterial.h and I haven't gotten the chance to investigate it more, but Cg support in Irrlicht would be awesome!
This thing has been around for over a year now, so what is keeping it back from getting merged into Irrlicht? Is it the extra dependency (if so, it is worth it) or is it the way it is implemented?
~DtD
On a side note, I didn't ever actually get IrrCg working because there was no code to fill alot of the stuff in IrrCgMaterial.h and I haven't gotten the chance to investigate it more, but Cg support in Irrlicht would be awesome!
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
The integration uses (used?) a different approach for the integration than for other HL shaders. Moreover, it's in general a rather large addition. This needs enough time to assess the changes, work on possible adaptions, and document the changes. And finally, Irrlicht didn't make too many steps towards shaders. The latter might change in the near future, the free time may come or may not.
I thought so.
I've been reading Irrlicht's source and understanding it better. (Code Definition Window ftw!) So today I looked into how it manages all the video drivers and stuff. So I'm going to try to make a better more Irr-y implementation of IrrCg based off of it. I will probably fail miserably
~DtD
I've been reading Irrlicht's source and understanding it better. (Code Definition Window ftw!) So today I looked into how it manages all the video drivers and stuff. So I'm going to try to make a better more Irr-y implementation of IrrCg based off of it. I will probably fail miserably
~DtD