First, I must warn you : I'm really new to shaders, so please be kind if my question seems stupid to you. I don't know what shaders can and cannot do (although I've understood they can do quite a lot).
Here's the problem : I'm working on a versus fighting game, World of Ideas (you can download the first beta and its source code HERE) and I'd like to use both lightmaps and normal maps at the same time.
I can't do it with Irrlicht only, as each material cannot have more than 2 textures (diffuse map + lightmap OR diffuse map + normal map), so I'm stuck with this dilemma :
- Top picture is lightmapped.
- Bottom picture is normal mapped.
(Don't worry about stairs -they are not textured yet- and the windows near the roof -they are not correctly drawn-, this level is not finished yet)
Is there a way to use both at the same time using a clerverly written shader ? If so, how ?
Lightmap and Parallax map at the same time using shaders ?
Lightmap and Parallax map at the same time using shaders ?
World of Ideas : an Irrlicht-powered versus fighting game
-
- Posts: 377
- Joined: Fri Oct 28, 2005 10:28 am
- Contact:
Ok, but how should I do this ?Baal Cadar wrote:The shader doesn't even have to be very clever. As lightmap application is trivial. If your lightmap is modulative, all you have to do is to multiply the result of lighting and normal mapping with the lightmap texel.
1- Using Irrlicht's default NORMAL_MAP material type, getting the result (normal mapped texel) and feed it to a lightmap shader. But how can I do this ? This would require 2 material types for the same material.
2- Creating a new shader that normal maps and lights at the same time. But such a shader would require 3 textures (diffuse + lightmap + normal map), something Irrlicht can't do. Or is there a way to force a third texture (not stored in the material's texture1 and texture2) into a shader ?
World of Ideas : an Irrlicht-powered versus fighting game
-
- Posts: 377
- Joined: Fri Oct 28, 2005 10:28 am
- Contact:
You've just brightened my day.Baal Cadar wrote:Next version of irrlicht will support four textures.
World of Ideas : an Irrlicht-powered versus fighting game
Hehe there are many patches out there for multiple textures already any way
i happened to have a lightmap and normals shader which works very smothly with irrlicht.
this is how it works:
-i take the diffuse texture(texture layer 0) and then bump map it by applying one of two "filters" to a compy of it using the same sampler
filter one is just a filter that colors it purple(yes this works and provides very fast bumpmaps with no extra texture ram overhead)
filter two(optional) i do sevral loops on the diffuse each one with a slight offset(more like a real normal map genewrator would do.
the first method is allot faster but may produce artifacts in some extreme cases
see i dont feed irrlicht any bumpmap info i just take the textures it loads by it self then i use them to generate bumpmaps on the fly
this is part of the irr cinema project which i hope to finish some day lol
i happened to have a lightmap and normals shader which works very smothly with irrlicht.
this is how it works:
-i take the diffuse texture(texture layer 0) and then bump map it by applying one of two "filters" to a compy of it using the same sampler
filter one is just a filter that colors it purple(yes this works and provides very fast bumpmaps with no extra texture ram overhead)
filter two(optional) i do sevral loops on the diffuse each one with a slight offset(more like a real normal map genewrator would do.
the first method is allot faster but may produce artifacts in some extreme cases
see i dont feed irrlicht any bumpmap info i just take the textures it loads by it self then i use them to generate bumpmaps on the fly
this is part of the irr cinema project which i hope to finish some day lol
OK, I'm about to test that feature, thing is that I have yet to write the code for this test.
Not sure how the shader code will be written, though this thread is giving me a hint on how it is going to be done. See for details http://www.gamedev.net/community/forums ... _id=325590
Here is the mapping:
Texture 0 = Diffuse = Sampler1
Texture 1 = Lightmap = Sampler2 = generated by Giles
Texture 2 = DOT3 Normal = Sampler3 = generated by nvidia dot3 tool
My main concern is the lightmap. Will the lightmap fragment be compatible with the diffuse and normal fragment?
Thanks.
Not sure how the shader code will be written, though this thread is giving me a hint on how it is going to be done. See for details http://www.gamedev.net/community/forums ... _id=325590
Here is the mapping:
Texture 0 = Diffuse = Sampler1
Texture 1 = Lightmap = Sampler2 = generated by Giles
Texture 2 = DOT3 Normal = Sampler3 = generated by nvidia dot3 tool
My main concern is the lightmap. Will the lightmap fragment be compatible with the diffuse and normal fragment?
Thanks.
OK, I did some research into this and it looks like the vertex shader will have the following input.
To make that happen, I will have to setup a Gile[s] file export to B3D and then load it to Irrlicht. From there I will be calling...
Which I think will probably not work right away.
Now, what do I need to get this going?
Thanks.
Code: Select all
struct VertexIn {
float4 position : Position;
float2 texCoord : TexCoord;
float3 tangent : Tangent;
float3 binormal : Binormal;
float3 normal : Normal;
float2 lmCoord : TexCoord1; //Lightmap
};
Code: Select all
smgr->getMeshManipulator()->createMeshWithTangents(mesh->getMesh(0));
Now, what do I need to get this going?
Thanks.