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
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

You may need to send transposed matrices or switch from matrix*vector to vector*matrix. Output a solid Red colour in your PS to see if projection is correct (unless you're background is Red :wink: ).
jingquan
Posts: 222
Joined: Sun Aug 20, 2006 4:10 am
Contact:

Post by jingquan »

Yes, it worked, thanks.

Here's the code again:

Code: Select all

   float4 lightPosition; // Object Space
   float3 eyePosition;  // Object space 
   float4x4 WorldViewProj;

void vsmain(float4 Position: POSITION, 
   float3 Normal: NORMAL, 
   float2 Uv: TEXCOORD0,
   float3 Tangent: TEXCOORD1,
   float3 Binormal: TEXCOORD2,

   out float4 oPosition: POSITION, 
   out float2 oUv: TEXCOORD0, 
   out float3 oLightDir: TEXCOORD1, // Tangent Space
   out float3 oEyeDir: TEXCOORD2, // Tangent Space
   out float3 oHalfAngle: TEXCOORD3 // Tangent Space

) 
{  
   oPosition = mul(Position, WorldViewProj); 

   oUv = Uv;
   float3 LightDir = normalize(lightPosition.xyz -  (Position * lightPosition.w));
   float3 EyeDir = eyePosition - Position.xyz; 
    
   float3x3 TBN = float3x3(Tangent, Binormal, Normal); 
    
   // Transformacja do Tangent Space
   LightDir = normalize(mul(TBN, LightDir)); 
   EyeDir = normalize(mul(TBN, EyeDir)); 

   oLightDir = LightDir; 
   oEyeDir = EyeDir; 
   oHalfAngle = normalize(EyeDir + LightDir); 
}

   float3 LightDiffuse;
   sampler2D DecalMap: register(s0);
   sampler2D NormalMap: register(s1);
   sampler2D SpecularMap: register(s2);
   /* Parallax Mapping
   uniform sampler2D HeightMap,*/
   
   

void psmain(float2 Uv: TEXCOORD0,
   float3 LightDir : TEXCOORD1,
   float3 EyeDir : TEXCOORD2,
   float3 HalfAngle : TEXCOORD3,
   out float4 oColor : COLOR)
{
   float2 TexCoord;

   /* Parallax Mapping
   float Height = tex2D (HeightMap, Uv).r;
   Height = Height * 0.04 - 0.02;
   float3 Eye = normalize (EyeDir);
   TexCoord = (Height * Eye.xy) + Uv;
   */
   // else
   TexCoord = Uv;

   float3 Normal = 2.0 * tex2D (NormalMap, TexCoord).rgb - 1.0;
   Normal = normalize (Normal);

   // Œwiat³o rozproszenia
   float3 Diffuse = max (dot (LightDir, Normal), 0.0) * LightDiffuse;
   float3 DecalColor = tex2D (DecalMap, TexCoord).rgb;

   float3 SpecularColor = tex2D(SpecularMap, TexCoord).rgb;

   float Specular = max (dot (HalfAngle, Normal), 0.0);
   Specular = pow (Specular, 8.0);

   oColor = float4 (DecalColor * Diffuse + Specular * SpecularColor, 1.0);
}
The rendermonkey solution: www.orandysoftware.com/user_files/normal.zip

Now comes the pixel bit. In rendermonkey, half of the cube displayed the diffues color like a gradient instead of the textures. I tried loading it in irrlicht and the cube has the specularmap as the diffuse texture, with bumpmap (it seems there's a constant light).

Could someone test to see if it's the shader's problem or the callbacks.

Loads of thanks. :D
Steel Style
Posts: 168
Joined: Sun Feb 04, 2007 3:30 pm
Location: France

Post by Steel Style »

HUm I have 3 five error, 3 conflict between msvprtd.lib and chernolbylShaderFREE.lib , and one error about extern. How can I do ?
L1zb3th
Posts: 15
Joined: Thu Jul 26, 2007 1:27 am

Post by L1zb3th »

I LOVE YOU !

now i can write my desired CG editor and kick in the ass the FxComposer, it's too damned heavy =P
umhhh, i saw that cg.dll compiles the program, but enabling it in Irrlicht ?
umhh, i saw it too complicated, Irrlicht design is not too plugin based...
now i will have my own editor yeahhh

Au Revoir =P
My Gramathicalz horrorz are precalkulated, zo Zhut Up !
_______
Bah, actually my english is poor, but...
forget it xDDDD
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Post by Nadro »

Steel Style wrote:HUm I have 3 five error, 3 conflict between msvprtd.lib and chernolbylShaderFREE.lib , and one error about extern. How can I do ?
Have You got problem with compile examples? Have You got properly configure Code::Blocks with MS Platform SDK? Maybe You have bad configure project in MS Visual 2005? What Errors You have got in compilation procces?
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Sounds like he is using "Multi Threaded DLL" or "Multi Threaded" wrongly in the Code Generation settings.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Steel Style
Posts: 168
Joined: Sun Feb 04, 2007 3:30 pm
Location: France

Post by Steel Style »

Actually I don't work even more on my code before compile yours and I have this error. I use MVS 2005

Erreur 1 error LNK2019: symbole externe non résolu "class irr::IrrlichtDevice * __cdecl irr::createDevice(enum irr::video::E_DRIVER_TYPE,class irr::core::dimension2d<int> const &,unsigned int,bool,bool,bool,class irr::IEventReceiver *,char const *)" (?createDevice@irr@@YAPAVIrrlichtDevice@1@W4E_DRIVER_TYPE@video@1@ABV?$dimension2d@H@core@1@I_N22PAVIEventReceiver@1@PBD@Z) référencé dans la fonction _main main.obj
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Wrong Irrlicht.dll
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Its a linker error, not run-time, and its for an unresolved external (If my spanish is any good). So I think he just forgot to link the irrlicht lib. :oops:

Try:

Code: Select all

pragma comment(lib,"irrlicht.lib");
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Steel Style
Posts: 168
Joined: Sun Feb 04, 2007 3:30 pm
Location: France

Post by Steel Style »

So thx, during this thread I download Nvidia Cg, turn the compilation on MultiThread Debug (MTd) then I add the link for the irrlicht lib. And Finally I get Irrlicht 1.4.

@Blindside: Thanks, sometimes easy things are those which are forget . (Bad english) PS :It was French :p
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Post by Nadro »

Version 0.5 of Cg Binding for Irrlicht was done! Project has got new name - "IrrCg". With current version You can easy create Cg Shader, similar to create Irrlicht standard shaders per Callback, because it is full integrated with Irrlicht functions:) Now You can use Cg Shaders per Irrlicht Material. You can easy convert HLSL Irrlicht Shaders to Cg Shaders. I update all examples to new interface, so You can see than use Cg in Irrlicht is VERY, VERY EASY! First post update for downloads;) I'm waiting for comments:)
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

cool, i'll give it a spin and report back later.
Image
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Post by christianclavet »

Thanks Nadro. I'll really have to check this!
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

hey nadro, i updated the link in ur space here,

http://nadro.owned.co.za/IrrCg_v0_5.zip


for anyone here it is too. i HATE the stupid share file services :)
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Post by Nadro »

Big thanks FuzzYspo0N for upload! :)
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Post Reply