hlsl shader help [SOLVED!]
Are you trying to do something like Doom3?
This image is from one of my past bug reports so ignore the weird stuff - the main subject is the Marine character in the centre. http://irrlicht.sourceforge.net/phpBB2/ ... highlight=
I had the four diffusemap/heightmap/normalmap/glossmap combined onto the character, it I remember correctly, but I'll have to retrieve the project from my backups to see how far I got. I remember that the "new" animation system was being planned so I stopped work on this.
This image is from one of my past bug reports so ignore the weird stuff - the main subject is the Marine character in the centre. http://irrlicht.sourceforge.net/phpBB2/ ... highlight=
I had the four diffusemap/heightmap/normalmap/glossmap combined onto the character, it I remember correctly, but I'll have to retrieve the project from my backups to see how far I got. I remember that the "new" animation system was being planned so I stopped work on this.
Irrlicht Demos: http://irrlicht.sourceforge.net/forum/viewtopic.php?f=6&t=45781
Also you can try and put specular mask in alpha channel of
diffuse texture (for example) so something, instead of (in pixel shader):
do :
EDIT: Just saw it doesnt affect output, it looks like it mising something like
on last line:
C *= colorMap*surfColor*specCol;
diffuse texture (for example) so something, instead of (in pixel shader):
Code: Select all
//specular color
float4 specCol = specularColor*specMap;
Code: Select all
//specular color
float4 specCol = specularColor*colorMap.a;
on last line:
C *= colorMap*surfColor*specCol;
OMG, now I FINALLY know why. I had forgotten about
until i browsed through belfegor's code. Oh man.....
Last time, I was using TGM's 4light normalmap shader which doesn't require tangents to be built in irrlicht, and since then forgotten about this.
Thank you everyone for your great help, I had learnt alot of stuff about shaders and vertexes.
BTW, I fixed the specularmap and updated the code in my first post.
Code: Select all
createMeshWithTangents()
Last time, I was using TGM's 4light normalmap shader which doesn't require tangents to be built in irrlicht, and since then forgotten about this.
Thank you everyone for your great help, I had learnt alot of stuff about shaders and vertexes.
BTW, I fixed the specularmap and updated the code in my first post.
-
- Posts: 6
- Joined: Wed Oct 17, 2007 6:27 pm
- Location: Germany
- Contact:
i have a little question, and i don't want to create a new thread.
i would like to load a effect file. there are the functions to load a material from a file, e.g.:
my problem is now, i have a fx-file. in this file, there are structs, variables, and functions. finally, there is a technique:
is that possible to load such a "system" or must do i have fragments?
i would like to load a effect file. there are the functions to load a material from a file, e.g.:
Code: Select all
addHighLevelShaderMaterialFromFiles
Code: Select all
Technique Low
{
Pass P1
{
Cullmode = CCW;
VertexShader = compile vs_1_1 VertexShader_Low();
PixelShader = NULL;
}
}
mfg
DevilSnake
DevilSnake
Someone made a patch some months ago so that Effect files could be used. You'd need to search the forums for it.
The tricky thing about Effect files is that they can hold device state - changing state "behind Irrlicht's back" may lead to Irrlicht's internal device state becoming out-of-sync. You can have the DX9 Effect interface save state, but that in itself may reduce performance.
The tricky thing about Effect files is that they can hold device state - changing state "behind Irrlicht's back" may lead to Irrlicht's internal device state becoming out-of-sync. You can have the DX9 Effect interface save state, but that in itself may reduce performance.
Irrlicht Demos: http://irrlicht.sourceforge.net/forum/viewtopic.php?f=6&t=45781
I did it with small edit in CD3D9Driver class, something like (might forgat correct names):
and then (for example when you make custom scene node) in render function:
Code: Select all
void CD3D9Driver::preCustomRender()
{
setVertexShader((E_VERTEX_TYPE)666);
set3DRenderMode();
}
and
void CD3D9Driver::setVertexShader(E_VERTEX_TYPE newType)
{
if(newType != LastVertexType)
LastVetexType = newType;
...
case 666:
break;
...
}
Code: Select all
void render()
{
...
Driver->setMaterial(Material);
Driver->preCustomRender();//call this so it doesnt break things up
D3DXMATRIXA16 World(AbsoluteTransformation.pointer());
...
Effect->SetTechnique(...);
Effect->SetVector(...);
Effect->SetMatrix("World", &World);
Effect->CommitChanges();
....
}
Hello,
Actually I've got another problem: The light vector seems to be out of sync when I rotate the mesh in the x and y vector. The z vector works however. I'm sure there's something to do with the vertex shader, and I can't get it right with any formular. Here's the orginal vertex shader:
BTW, I've got a question. The mesh's normals that uses the shader isn't smooth. Perhaps it's caused by irrlicht tangents?
Thanks again.
Actually I've got another problem: The light vector seems to be out of sync when I rotate the mesh in the x and y vector. The z vector works however. I'm sure there's something to do with the vertex shader, and I can't get it right with any formular. Here's the orginal vertex shader:
Code: Select all
v2f vsmain(in a2v In)
{
v2f Out = (v2f)0;
Out.worldNormal = mul(In.normal, worldIT).xyz;
Out.worldTangent = mul(In.tangent, worldIT).xyz;
Out.worldBinormal = mul(In.binormal, worldIT).xyz;
//can use either positive or negative y format normal maps
//comment out this if statement to save 6 instructions!
//Out.worldTangent = -Out.worldTangent;
float3 worldSpacePos = mul(In.position, world);
Out.lightVec = lightPosition - worldSpacePos;
Out.texCoord.xy = In.texCoord;
Out.eyeVec = viewInv[3].xyz - worldSpacePos;
Out.position = mul(In.position, wvp);
return Out;
}
Thanks again.
-
- Posts: 6
- Joined: Wed Oct 17, 2007 6:27 pm
- Location: Germany
- Contact:
i, i've a second question. that question concerns the world-view-projetion matrix.
i have always written:
all = world * view * projection;
but in irrlicht, that doesn't run. here, i have to write:
all = projection * view * world;
what's the reason for this "occurence"?
thanks for helping
i have always written:
all = world * view * projection;
but in irrlicht, that doesn't run. here, i have to write:
all = projection * view * world;
what's the reason for this "occurence"?
thanks for helping
mfg
DevilSnake
DevilSnake
As i said you can not achive good results from irrlicht current vertex typesjingquan wrote:BTW, I've got a question. The mesh's normals that uses the shader isn't smooth. Perhaps it's caused by irrlicht tangents
(at least i have not seen that anybody has do it).
Yes, in irrlicht you must do it that way.DevilSnake wrote:but in irrlicht, that doesn't run. here, i have to write:
all = projection * view * world;
what's the reason for this "occurence"?
Bump, sry I still cannot figure out how to correct the lighting on a rotating mesh.jingquan wrote:Hello,
Actually I've got another problem: The light vector seems to be out of sync when I rotate the mesh. I'm sure there's something to do with the vertex shader, and I can't get it right with any formular. Here's the orginal vertex shader:
Thanks again.Code: Select all
v2f vsmain(in a2v In) { v2f Out = (v2f)0; Out.position = mul(In.position, wvp); float3 tangent = float3(abs(In.normal.y) + abs(In.normal.z), abs(In.normal.x), 0); float3 binormal = float3(0, abs(In.normal.z), abs(In.normal.x) + abs(In.normal.y)); Out.worldNormal = mul(In.normal, worldIT).xyz; Out.worldTangent = mul(tangent, worldIT).xyz; Out.worldBinormal = mul(binormal, worldIT).xyz; Out.texCoord.xy = In.texCoord; float3 worldSpacePos = mul(In.position, world); Out.lightVec = lightPosition - worldSpacePos; Out.eyeVec = viewInv[3].xyz - worldSpacePos; return Out; }