irrCg v0.8 (Initial) - CgFX (Texture States, MultiPass etc.)

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
offmonreal
Posts: 6
Joined: Sat Feb 09, 2008 7:12 am
Contact:

Build examples Mingw

Post by offmonreal »

Library compiled, but when you try to compile example
an error linking

Code: Select all

IrrCg.cpp||undefined reference to `glDisable@4'|
IrrCg.cpp||undefined reference to `glBindTexture@8'|
IrrCg.cpp||undefined reference to `cgCreateContext'|
IrrCg.cpp||undefined reference to `cgDestroyContext'|
IrrCg.cpp||undefined reference to `cgGLRegisterStates'|
IrrCg.cpp||undefined reference to `cgGLGetManageTextureParameters'|
IrrCg.cpp||undefined reference to `cgGetProfile'|
IrrCg.cpp||undefined reference to `cgGLIsProfileSupported'|
IrrCg.cpp||undefined reference to `cgGLGetLatestProfile'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 0 warnings ===|
I tried to connect the GL library and compilation flags - not helped
The user not speaking GOOD on EN
someguy99
Posts: 38
Joined: Sun Oct 11, 2009 11:20 am

Post by someguy99 »

FOR EVERYONE WHO CANT DOWNLOAD, MIRROR (0.7):
http://www.wikiupload.com/download_page.php?id=184019
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

Hi, I finally decided to play a bit with IrrCg, so I complied it and started editing the first example program -Basic lighting. After getting familliar with the code and watching the results I have some questions about it: (hopefully I won`t get beaten for that :lol: )

1) Looks like the light position given is in object`s local space. Here`s what I did to make it work right for my test:

Code: Select all

// in PerPixelLightingCallBack
lightPosition = cgGetNamedParameter(Pixel, "lightPosition");
vector3df p = vector3df(-200,0,0); // my object`s position 
vector3df v = node4->getPosition(); // my light node position (flyCircle animated)
vector3df r = v-p; // some result position
services->setParameter3f(lightPosition, r.X, r.Y, r.Z);
but this is only for one node. How can I make it work for all nodes where applied, since this is some lame way doing this?

2) The code applies per pixel lighting material for one light. Can I make my node be affected by many lights same time- like a level node lit by many lights?

3) Can I adjust the light range and attenuation? I want to get sth like this: http://www.3ddrome.com/articles/cgshaders.php (poor me- recently spamming some shader links ^^)- the picture at the bottom. My "scene" is the cube left from the elephant (backface culling disabled), but scaled 20x and the light is moving in circle in it, which gives me weird results when light passes by the origin of the cube (because it`s in it all the time and it lights the positive x side only).

4) Calling "setMaterialTexture()" gets totally ignored. Can I have texture and lighting same time? Multitexturing maybe?

Thanks, Nadro for creating this nice binding. I may try implementing it in my app if I manage to use it and am pleased with my test results. :)
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

http://www.racer.nl/tutorial/howto_full ... haders.htm

does full screen shader work with irrcg?
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Post by Nadro »

Hi,

Of course irrCg is compatible with any shaders up to SM 3.0, so You can add attenuation, multitexturing, use fullscreen shaders etc.

@shadowslair
Do You use EnableTexture in shader callback and register(sN) for any texture in shader code? eg:
C++ (in callback)

Code: Select all

DecalMap = cgGetNamedParameter(Pixel, "DecalMap");
services->EnableTexture( DecalMap,Material.getTexture(0));

NormalMap = cgGetNamedParameter(Pixel, "NormalMap");
services->EnableTexture( NormalMap,Material.getTexture(1));
Cg:

Code: Select all

uniform sampler2D DecalMap : register(s0),
uniform sampler2D NormalMap : register(s1),
What with send light position and similar data to shader? You can do it in the same way as in standard Irrlicht callback for HLSL/GLSL.

BTW. I use irrCg + Cg shaders in Buggy Race and You can see in this project shadows, lighting, terrain splatting, bloom etc, so irrcg has the same features as native hlsl/glsl in Irrlicht.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
tinhtoitrangtay
Posts: 70
Joined: Tue Oct 28, 2008 12:59 pm

Post by tinhtoitrangtay »

How can complied code with Visual Studio 2008
tinhtoitrangtay
Posts: 70
Joined: Tue Oct 28, 2008 12:59 pm

Post by tinhtoitrangtay »

Hi, Nardo
I am sorry now i fix some problem IrrCg can run on VC 2008 no problem, but i have question i wanna merge IrrCg to Irrlicht but it don't work. You can help me fix problem. Thanks

Error:

------ Rebuild All started: Project: 01.BasicLighting_vc9, Configuration: Release Win32 ------
Deleting intermediate and output files for project '01.BasicLighting_vc9', configuration 'Release|Win32'
Compiling...
main.cpp
Linking...
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
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
main.obj : error LNK2001: unresolved external symbol _cgGetNamedParameter
IrrCg.lib(IrrCgMaterial.obj) : error LNK2001: unresolved external symbol _cgGetNamedParameter
main.obj : error LNK2001: unresolved external symbol __imp__createDevice
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol __imp__cgD3D9SetManageTextureParameters
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgGetProfileString
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgGLDisableProfile
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol __imp__cgD3D9BindProgram
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgSetParameter3d
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol __imp__cgD3D9IsProfileSupported
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgGLSetMatrixParameterfc
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgGetLastListing
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgSetParameter1d
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgGLBindProgram
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol __imp__cgD3D9LoadProgram
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol __imp__cgD3D9SetDevice
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol __imp__cgD3D9RegisterStates
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgCreateContext
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgGLLoadProgram
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgSetParameter4d
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgGLSetTextureParameter
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgGLGetManageTextureParameters
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgGetErrorString
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgSetParameter3f
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgGLEnableTextureParameter
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgSetParameter1f
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol __imp__cgD3D9GetLatestVertexProfile
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgGLSetManageTextureParameters
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol __imp__cgD3D9SetTextureParameter
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgSetParameter2d
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgGetProfile
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol __imp__cgD3D9SetUniform
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgDestroyContext
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgSetParameter2f
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgGLGetLatestProfile
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgSetParameter4f
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgSetParameter1i
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol __imp__cgD3D9GetLatestPixelProfile
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgSetParameter2i
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgSetParameter3i
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgGLRegisterStates
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgGLEnableProfile
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgGetError
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgCreateProgram
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgSetParameterSettingMode
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol __imp__cgD3D9GetManageTextureParameters
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
libcpmtd.lib(stdthrow.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgGLIsProfileSupported
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgCreateProgramFromFile
IrrCg.lib(IrrCg.obj) : error LNK2001: unresolved external symbol _cgSetParameter4i
libcpmtd.lib(xdebug.obj) : error LNK2001: unresolved external symbol __malloc_dbg
libcpmtd.lib(xdebug.obj) : error LNK2001: unresolved external symbol __free_dbg
..\..\bin\Win32-VisualStudio\01.BasicLighting.exe : fatal error LNK1120: 50 unresolved externals
Build log was saved at "file://c:\HOCTAPLT\irrlicht\examples\01.BasicLighting\Release\BuildLog.htm"
01.BasicLighting_vc9 - 53 error(s), 1 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Post by Nadro »

Version 0.7.1 of irrCg released!
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Post by Nadro »

Today I send on irrCg SVN server initial v0.8. I added in this version support for CgFX (with texture states, multi passes etc). You can download binary version of CgFX example from this link:
http://nadro.net46.net/IrrCg/CgFX_Example.zip
All sources (with this example) are avaiable of course on SVN.

Cheers,
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

Post by 3DModelerMan »

Yes! now I can use some of the shaders from the Nvidia shader library. Great job Nadro.
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
tinhtoitrangtay
Posts: 70
Joined: Tue Oct 28, 2008 12:59 pm

Post by tinhtoitrangtay »

Thank Nadro
But i can problem when i try convert to MSVC and i have some error

Code: Select all

------ Rebuild All started: Project: 25.BasicLighting, Configuration: Release Win32 ------
Deleting intermediate and output files for project '25.BasicLighting', configuration 'Release|Win32'
Compiling...
main.cpp
.\main.cpp(201) : error C2259: 'PerVertexLightingCallBack' : cannot instantiate abstract class
        due to following members:
        'void irr::IrrCg::ICgShaderConstantSetCallBack::OnSetConstants(irr::IrrCg::ICgServices *,const CGeffect &,const CGpass &,const CGprogram &,const CGprogram &,const irr::video::SMaterial &)' : is abstract
        ..\..\include\IrrCg.h(276) : see declaration of 'irr::IrrCg::ICgShaderConstantSetCallBack::OnSetConstants'
.\main.cpp(206) : error C2259: 'PerPixelLightingCallBack' : cannot instantiate abstract class
        due to following members:
        'void irr::IrrCg::ICgShaderConstantSetCallBack::OnSetConstants(irr::IrrCg::ICgServices *,const CGeffect &,const CGpass &,const CGprogram &,const CGprogram &,const irr::video::SMaterial &)' : is abstract
        ..\..\include\IrrCg.h(276) : see declaration of 'irr::IrrCg::ICgShaderConstantSetCallBack::OnSetConstants'
Build log was saved at "file://c:\HOCTAPLT\devIrr\examples\25.BasicLighting\Release\BuildLog.htm"
25.BasicLighting - 2 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Post by Nadro »

Hi,

In examples 01-03, You must change function:

Code: Select all

virtual void OnSetConstants(ICgServices* services,CGprogram Vertex,CGprogram Pixel,const SMaterial &Material)
to new v0.8 structure:

Code: Select all

virtual void OnSetConstants(ICgServices* Services,const CGeffect& Effect,const CGpass& Pass,const CGprogram& Vertex,const CGprogram& Fragment,const SMaterial& Material)
PS. If You try compile irrCg on Windows You have to remember about add this definitions to Your VC++ project settings:

Code: Select all

IrrCgWindows // Windows support
IrrCgD3D9 // D3D9 support
IrrCgOGL // OpenGL support
Cheers,
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Valmond
Posts: 308
Joined: Thu Apr 12, 2007 3:26 pm

Post by Valmond »

Wow, great going!

I'll check this out when I'm back from holidays!
userdima
Posts: 22
Joined: Wed Jun 04, 2008 8:30 pm

using nvidia shader

Post by userdima »

Sorry, I'm completely new in shader programing, I have one problem. I tried to use IrrCg with one of the CgFx files from nvidia shaders library (ddGodRays). I modified cgfx example and got black square in the middle of the screen. Maybe there are some errors in callback code? Here it is:

Code: Select all

        matrix4 Matrix;

        param = cgGetNamedEffectParameter(Effect, "gWvpXf");
        Matrix = Services->getDevice()->getVideoDriver()->getTransform(ETS_PROJECTION);
        Matrix *= Services->getDevice()->getVideoDriver()->getTransform(ETS_VIEW);
        Matrix *= Services->getDevice()->getVideoDriver()->getTransform(ETS_WORLD);
        cgSetMatrixParameterfr(param, Matrix.pointer());

        param = cgGetNamedEffectParameter(Effect, "gWorldXf");
        Matrix = Services->getDevice()->getVideoDriver()->getTransform(ETS_WORLD);
        cgSetMatrixParameterfr(param, Matrix.pointer());

        param = cgGetNamedEffectParameter(Effect, "gViewIXf");
        Matrix = Services->getDevice()->getVideoDriver()->getTransform(ETS_VIEW);
		Matrix.getInverse(Matrix);
        cgSetMatrixParameterfr(param, Matrix.pointer());

        param = cgGetNamedEffectParameter(Effect, "gWorldITXf");
        Matrix = Services->getDevice()->getVideoDriver()->getTransform(ETS_WORLD);
	Matrix.getInverse(Matrix);
	Matrix.getTransposed(Matrix);
        cgSetMatrixParameterfr(param, Matrix.pointer());
And begining of the shader code:

Code: Select all

// transform object vertices to world-space:
float4x4 gWorldXf : World < string UIWidget="None"; >;
// transform object normals, tangents, & binormals to world-space:
float4x4 gWorldITXf : WorldInverseTranspose < string UIWidget="None"; >;
// transform object vertices to view space and project them in perspective:
float4x4 gWvpXf : WorldViewProjection < string UIWidget="None"; >;
// provide tranform from "view" or "eye" coords back to world-space:
float4x4 gViewIXf : ViewInverse < string UIWidget="None"; >;
What have I missed?
rootroot1
Posts: 44
Joined: Wed Nov 25, 2009 6:42 pm
Location: Odessa, Ukraine

Hello, Nadro !!!!!

Post by rootroot1 »

Greetings Nadro !!!!!!!!!!!!!!!!!!

Your wrapper is great !!!!!!!!!!!!!!!!!!!

But where I can find ISceneNodeAnimatorList class,
where is the header ??

I really need CgFX from your latest trunk !!!! :cry: :cry:

Thanks in Advance !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Post Reply