Page 3 of 16
Posted: Sun Oct 14, 2007 9:19 am
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 :wink:](./images/smilies/icon_wink.gif)
).
Posted: Sun Oct 14, 2007 11:01 am
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.
![Very Happy :D](./images/smilies/icon_biggrin.gif)
Posted: Sun Nov 18, 2007 12:15 pm
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 ?
Posted: Sun Nov 18, 2007 3:56 pm
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
Posted: Wed Nov 21, 2007 4:58 pm
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?
Posted: Wed Nov 21, 2007 5:34 pm
by BlindSide
Sounds like he is using "Multi Threaded DLL" or "Multi Threaded" wrongly in the Code Generation settings.
Posted: Wed Nov 21, 2007 8:37 pm
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
Posted: Wed Nov 21, 2007 11:29 pm
by hybrid
Wrong Irrlicht.dll
Posted: Thu Nov 22, 2007 12:01 am
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.
Try:
Code: Select all
pragma comment(lib,"irrlicht.lib");
Posted: Thu Nov 22, 2007 8:32 am
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
Posted: Sun Dec 09, 2007 3:47 pm
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:)
Posted: Sun Dec 09, 2007 6:09 pm
by dlangdev
cool, i'll give it a spin and report back later.
Posted: Sun Dec 09, 2007 10:26 pm
by christianclavet
Thanks Nadro. I'll really have to check this!
Posted: Wed Dec 19, 2007 10:59 am
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
![Smile :)](./images/smilies/icon_smile.gif)
Posted: Wed Dec 19, 2007 3:47 pm
by Nadro
Big thanks FuzzYspo0N for upload!
![Smile :)](./images/smilies/icon_smile.gif)