Lightmap and Parallax map at the same time using shaders ?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Agar
Posts: 22
Joined: Wed May 03, 2006 7:14 pm
Location: France
Contact:

Lightmap and Parallax map at the same time using shaders ?

Post by Agar »

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.

Image
(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 ?
World of Ideas : an Irrlicht-powered versus fighting game
Baal Cadar
Posts: 377
Joined: Fri Oct 28, 2005 10:28 am
Contact:

Post by Baal Cadar »

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.
No offense :)
Agar
Posts: 22
Joined: Wed May 03, 2006 7:14 pm
Location: France
Contact:

Post by Agar »

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.
Ok, but how should I do this ?

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
Baal Cadar
Posts: 377
Joined: Fri Oct 28, 2005 10:28 am
Contact:

Post by Baal Cadar »

Definitly 2.
Next version of irrlicht will support four textures.
No offense :)
Agar
Posts: 22
Joined: Wed May 03, 2006 7:14 pm
Location: France
Contact:

Post by Agar »

Baal Cadar wrote:Next version of irrlicht will support four textures.
You've just brightened my day. :D
World of Ideas : an Irrlicht-powered versus fighting game
omaremad
Competition winner
Posts: 1027
Joined: Fri Jul 15, 2005 11:30 pm
Location: Cairo,Egypt

Post by omaremad »

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
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

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.
Image
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

You realise this thread is 2 years old right? ;)

and what do you mean by fragments being compatible?

I would imagine you could have a different set of texture coords for the light map as the lightmap may cover more geometry than the diffuse/normal map, is that what you mean?
Image Image Image
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

OK, I did some research into this and it looks like the vertex shader will have the following input.

Code: Select all

struct VertexIn {
	float4 position : Position;
	float2 texCoord : TexCoord;
	float3 tangent  : Tangent;
	float3 binormal : Binormal;
	float3 normal   : Normal;
	float2 lmCoord  : TexCoord1;    //Lightmap
};
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...

Code: Select all

smgr->getMeshManipulator()->createMeshWithTangents(mesh->getMesh(0));
Which I think will probably not work right away.

Now, what do I need to get this going?

Thanks.
Image
Post Reply