Adding lightmap to normalmapped material

PDX

18-07-2007 03:08:02

Hello,

In a previous post I alluded to how I'm trying to add a lightmap to a normalmapped oFusion material. I'm having some trouble with that process.

Basically, I figured I could take the shader I created for the torus in the normalmapping tutorial and add to it an oFusion pass based on the shader I created in the lightmapping tutorial. In this image:



...you can see the attributes from the lightmap tutorial's oFusion pass on the left, the oFusion technique from the normalmap tutorial in the middle, and where, within that technique, I added the oFusion pass labeled shadow_pass. If you were to click on shadow_pass you'd see the same attributes you see on the left.

On the bottom right you can see the results: instead of seeming like a modulate blend that makes all but the darkest spots transparent, the lightmap looks like a peeling layer of paint: it's layered over top of the normalmapped torus material like a poorly sorting polygon.

Does it seem like this should work?

Could it be a hardware issue?

I'm obviously taking a blunt approach to figuring this out (in that I'm just mashing two shaders together), but I'm not a programmer, and the way these shaders work is not obvious to me.

Any help would be greatly appreciated!

PDX

18-07-2007 07:15:16

Some searching turned up this thread:

http://www.ogre3d.org/phpBB2addons/viewtopic.php?t=1057&highlight=lightmaps

Which yielded this handy tid-bit from Lioric:

"1. The result you should have is a pass with two texture unit, not two passes

Lightmap is a multitexture technique, so yes, you should have a diffuse and a lightmap textures "

I was trying to do two passes before but now I've got it set instead to two texture units. With that, I can at least get the torus so that the lightmap looks translucent like it should.

Now a problem I'm running into is that the lightmap doesn't seem to make use of the UVs that I assign it to. I set it to use map channel 3, but it seems to be still using map channel 1. (Update: I copied the UVs from channel 3 to channel 2, and set the lightmap to use channel 2... It looks like that might have worked. Only I can't imagine why it would matter.)

Again, to sum, I'm trying to add a lightmap texture into what is essentially the material I created when doing the normal map tutorial, with the torus.

One thing I noticed is that I can only get anything resembling a lightmap when I add the texture unit to what's labeled in that tutorial as base_pass. At first I thought it made sense to add the lightmap's texture unit to the oFusion Pass named decal_pass, but that only turns everything black.

Am I missing something obvious? I've looked through the manual a bit, and searched the forums. If this blatantly obvious, and I should know better please let me know. I'm new, but willing to learn :).

Paulov

18-07-2007 12:07:38

HEllo.

Having lightmaped+normal maped material was one of my "dreams".

After spending tons of hours I´ve absolutely given up on using shaders.

If you are an artist: shaders=timelost.


I´ve used the tutorials shaders.
I´ve used the Monster shaders1.
Monster shaders 2.. etc.

And get nothing really usable. All have limitations that an artist can face.

And those softwares that create shaders graphically like the latest nvidia release and the other whose name cant remember, even if output HSLS shaders they still need to be modified to be runing inside ogre. And even if they run they will for sure give any time of limitation in OF.

The closest I´ve been from a nice artist friendly shader was Monster shader 1.
It was as easy as loading the shader and place the normal an difuse textures in theis correct position, and then everything woked. You could tune some parameters to make it shine or not, and there you had a nice shader. I had not lightmap support in the V.1.

In the V.2 the autor added lightmap support and implemented a number of improvements. But in OF it does not work, you get nothing but a white surface. You cant tweak the controls inside OF ....

another pack of hours lost.

---------------------------------------------------------------------

Time ago, there was a proposal of delivering a shader library, but this as far as I know has fall in the avys.

What an artist needs as "standard" nowadays is at least the posibility of combining in one material these techniques.

Lightmaping
Normal maping
Parallax maping
Specular maping

As far as I know Monster 2 whas able, but did not reach to try this as it does not work with OF. but after testing the Monster 1 have to say that the ressults could be impresive.

Modigying Monster 2 to make it runable in OF, would be a big step forward for artists.
Compatibilitly with those shader creations apps would be too.

Lioric

18-07-2007 15:23:27

You can add the LM to the "decal" pass shader using a simple 2-texture blend shader

Its easy to add LM to any shader, you need to add a sampler (a texture unit in the shader) and pass the UVs of the LM channel to this shader, then sample this texture and multiply with the diffuse texture pixel

The effect you are expriencing with the z-depth issues in the added pass is beacuse you cant mix fixed function pass (no shaders) with programable function pass (shadders), that is why in the the "base pass" the "AmbienhtTexture" shader is used (this shader simply uses the ambient light to color each vertex)

Evak

18-07-2007 16:33:35

there was talk of ShaderFX support avaliable for ofusion 2. That makes a lot of things a piece of cake for artists to create. Having worked with our programmers to get shader FX shaders to work in ogre has proven quite a chore, and not something I can do by myself, so I'm not sure how easy it would be to automate the process for something like Ofusion.

I really hope someone makes a .fx to ogre tool that actually works :).

PDX

18-07-2007 21:53:50

Lioric,

I had attempted to add a LM to the decal pass as you suggest, but perhaps I did something wrong.

What I did was add an oFusion TextureUnit to decal_pass. Then I went into the TextureUnit, and under Bitmap I loaded Plane02LightingMap.tga, which is the lightmap generated in the lightmap tutorial. This was the result:



It's black. As black as night. As black as my cold, cold heart.

Messing with the Color Blend Mode doesn't do much to change this... It either stays black or turns off whatever effect causes the blackness.

Is there something else I need to do to get a LM TextureUnit to work under the decal_pass?

You can see the settings I've got for the TextureUnit - does that all look right?

Thanks!

PDX

18-07-2007 22:25:24

In contrast to the example in the previous post, I am able to get something that looks like a lightmap working if I add the TextureUnit to the *base_pass*:



(This again is the lightmap texture from the lightmap tutorial, specifically the texture on the ground beneath the adobe house. )

For some reason, though, the base_pass doesn't seem like a good place for a lightmap.

The decal pass - as Lioric suggested - seems like a better place. However, as you can see in my previous post, when I add a lightmap to the decal pass it turns the same object black.