Normal Map Lighting - help
- RyanN
- Halfling
- Posts: 82
- Joined: Thu Aug 19, 2004 6:41 am
- Location: Victoria, Australia
- Contact:
Normal Map Lighting - help
i've applied normal maps to a small test room with a detailed character inside, the room has a light source coming from the top yet the materials normal mappings only seem to light from the ambient setting. Why won't it light from the light source direction? the light source is being setup in a .scene file, is there a difference between using a .scene file and straight c++ code in the exe to initialise the light?
thanks in advance!
thanks in advance!
- sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67
- Contact:
You probably haven't generated tangent vectors for your mesh. See the wiki here http://ogrewiki.digitalsentience.com/in ... umpMapping
- RyanN
- Halfling
- Posts: 82
- Joined: Thu Aug 19, 2004 6:41 am
- Location: Victoria, Australia
- Contact:
- semicolon
- Halfling
- Posts: 94
- Joined: Sun Jul 04, 2004 4:42 pm
- Location: Bangkok, Thailand
- Contact:
- sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67
- Contact:
I'm not sure what a 'tangent edge' is 
Did you check your log? There are a couple of possible things:
1. If it's additive shadows, OGRE has to partition up your material definition into ambient, per-light and decal sections. It's pretty good at this, but sometimes you have to give it a hint if you use multiple passes by being specific. We talk about this in the manual. If you used the materials which came with the OGRE demo it's not that.
2. I'm not sure what the .scene loader you're using is doing with the geometry. Normal mapping requires an 'object space light' position, which can be bound automatically (again, see the demos) but is derived based on the object origin. It's possible that the manipuation that your viewer is doing is throwing that off.
If in doubt, try a simple entity in the same scene with that material and see what it does, to derive whether it's material or geometry that's causing the problem.
Did you check your log? There are a couple of possible things:
1. If it's additive shadows, OGRE has to partition up your material definition into ambient, per-light and decal sections. It's pretty good at this, but sometimes you have to give it a hint if you use multiple passes by being specific. We talk about this in the manual. If you used the materials which came with the OGRE demo it's not that.
2. I'm not sure what the .scene loader you're using is doing with the geometry. Normal mapping requires an 'object space light' position, which can be bound automatically (again, see the demos) but is derived based on the object origin. It's possible that the manipuation that your viewer is doing is throwing that off.
If in doubt, try a simple entity in the same scene with that material and see what it does, to derive whether it's material or geometry that's causing the problem.
- RyanN
- Halfling
- Posts: 82
- Joined: Thu Aug 19, 2004 6:41 am
- Location: Victoria, Australia
- Contact:
thanks for your help sinbad, i will test a few things and see what happens, however as a test peter seemed to get it working on a different scene but once we tried to 'copy' the technique across it didn't work and we can't figure out whats the difference between them. The problem seem to be that its not getting the lights world position; its basically a copy/paste of the 'advanced-material' code from the demos.
One other question: can the specular highlight be adjusted to have a smaller hightlight? what setting controls this function, is it the light source them selves or the shader code? also can current bumpmap shader support a black/white specular map to define the hightlight levels?
One other question: can the specular highlight be adjusted to have a smaller hightlight? what setting controls this function, is it the light source them selves or the shader code? also can current bumpmap shader support a black/white specular map to define the hightlight levels?
- sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67
- Contact:
It's the specular power function. This is represented as 'shininess' in the fixed function pipeline, in our specular normal mapping shaders we use a fixed power because we wanted the shaders to be compatible with ps_1_x, which does not support variable powers. If you use ps_2_0 or above you can use the pow() function to make it variable, otherwise just change these lines in the fragment program:
Note that because the loop control variables are constant Cg expands that into a constant statement, it's not run like that on the GPU (and can't be in ps_1_x).
Code: Select all
for (int i = 0; i < 3; ++i)
specFactor *= specFactor;
- RyanN
- Halfling
- Posts: 82
- Joined: Thu Aug 19, 2004 6:41 am
- Location: Victoria, Australia
- Contact:
- sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67
- Contact:
See the 'max_lights' pass option.only problem i have is can the normal map lighting be restricted to X amount of lights?
Commonly known as a 'gloss map', yes - all you need is a greyscale texture mapped with the same coordinates and modulate the specularity based on that.I guess that it would be a 'global' shininess for that particular shader, using a 'specular level' texture layer would proberly be better.
- RyanN
- Halfling
- Posts: 82
- Joined: Thu Aug 19, 2004 6:41 am
- Location: Victoria, Australia
- Contact:
- sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67
- Contact:
- RyanN
- Halfling
- Posts: 82
- Joined: Thu Aug 19, 2004 6:41 am
- Location: Victoria, Australia
- Contact:
- RyanN
- Halfling
- Posts: 82
- Joined: Thu Aug 19, 2004 6:41 am
- Location: Victoria, Australia
- Contact:
is there something wrong or is there something i need to do to see shader effects through a semi-transparent texture. Currently i have a plain non-shader, semi-transparent texture with a reflective texture combined to make a glass texture however when i look through the window any other texture that uses a shader doesn't show up, ie: just a plain colour on the mesh im looking at, any ideas?
also in regaurds to the 'limit amount of lights' thing, i tried it but it didn't seem to work, how is applied to the shader?
yet another question, how does the projective texture shader work? is the projected texture appiled to the mesh or the material thats applied to the object, how does it throw the texture/shadow? (the demos don't help too much on this effect so any help would be awesome!)
also in regaurds to the 'limit amount of lights' thing, i tried it but it didn't seem to work, how is applied to the shader?
yet another question, how does the projective texture shader work? is the projected texture appiled to the mesh or the material thats applied to the object, how does it throw the texture/shadow? (the demos don't help too much on this effect so any help would be awesome!)
- sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67
- Contact:
1. Use scene_blend <whatever> and depth_write off in your pass. This applies equally to shader materials
2. Limiting the number of lights only works if your pass iterates per light - please see the manual for details
3. It generates texture coordinates in the target object. The projection has to be linked with a frustum and is set on the texture unit, but only takes effect when you use that material when rendering a mesh.
2. Limiting the number of lights only works if your pass iterates per light - please see the manual for details
3. It generates texture coordinates in the target object. The projection has to be linked with a frustum and is set on the texture unit, but only takes effect when you use that material when rendering a mesh.
- RyanN
- Halfling
- Posts: 82
- Joined: Thu Aug 19, 2004 6:41 am
- Location: Victoria, Australia
- Contact:
thanks for the reply sinbad! One other thing i would like to add is that getting normal maps to work is really inconsistant, i've got the scene with the character working with normal maps, another scene with a house had normal maps applied yet they flickered depending on the angle i was looking but the normals did light from light source direction and another scene with only one normal map that does work but it won't light from the direction of light source.
The house scene was had to figure out but after cleaning out the material file of duplicated materials it stopped flickering however the normal map stopped lighting from the light source, what is going on? at least with the flickering it lit the normal map.......
3. is the fustrum the camera/spotlights view/spot cone? is the preojective texture shader only used for lights?, ie: Doom3 flashlight style or any light source with a detailed projection map. Could this shader be used for projected mesh shadows?, ie: HL2 objects or usually a masked texture had a projected shadow ie: OFP (the trees and shrubs). Peter could explain it better if don't understand what im going on about
The house scene was had to figure out but after cleaning out the material file of duplicated materials it stopped flickering however the normal map stopped lighting from the light source, what is going on? at least with the flickering it lit the normal map.......
3. is the fustrum the camera/spotlights view/spot cone? is the preojective texture shader only used for lights?, ie: Doom3 flashlight style or any light source with a detailed projection map. Could this shader be used for projected mesh shadows?, ie: HL2 objects or usually a masked texture had a projected shadow ie: OFP (the trees and shrubs). Peter could explain it better if don't understand what im going on about
- PeterNewman
- Greenskin
- Posts: 128
- Joined: Mon Jun 21, 2004 2:34 am
- Location: Victoria, Australia
- Contact:
Your saying I understand what your going on about? 
I really have no idea what is happening with his models. It looks like he somehow has multiple materials applied to the same mesh, and depending on what angle you look at them, you get either the fixed-function material (plain textre) or a variant on the pixel shader material (sudden brightness changes etc).
I quickly checked his materials and it doesn't seem he ismixing fixed-function and shader passes. Ogre.log isnt reporting any errors about a material referrring to a program that isnt defined, and every pass has programs. (Is a vertex program alone enough to kick it into the other pipeline? From the examples, which work, I'd say yes.)
Unfortunately I haven't had time to take his scene and really dig in to it, I'm guessing from the sidelines here. Stupid deadlines.
I really have no idea what is happening with his models. It looks like he somehow has multiple materials applied to the same mesh, and depending on what angle you look at them, you get either the fixed-function material (plain textre) or a variant on the pixel shader material (sudden brightness changes etc).
I quickly checked his materials and it doesn't seem he ismixing fixed-function and shader passes. Ogre.log isnt reporting any errors about a material referrring to a program that isnt defined, and every pass has programs. (Is a vertex program alone enough to kick it into the other pipeline? From the examples, which work, I'd say yes.)
Unfortunately I haven't had time to take his scene and really dig in to it, I'm guessing from the sidelines here. Stupid deadlines.
- RyanN
- Halfling
- Posts: 82
- Joined: Thu Aug 19, 2004 6:41 am
- Location: Victoria, Australia
- Contact:
- RyanN
- Halfling
- Posts: 82
- Joined: Thu Aug 19, 2004 6:41 am
- Location: Victoria, Australia
- Contact:
- sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67
- Contact:
- RyanN
- Halfling
- Posts: 82
- Joined: Thu Aug 19, 2004 6:41 am
- Location: Victoria, Australia
- Contact:
- Banania
- Gremlin
- Posts: 150
- Joined: Wed Oct 20, 2004 2:35 pm
- Location: Paris, France
- Contact:
strange. I'll check it. I am not sure anyone had really used it before though.
EDIT: should be working. I haven't tried but the command line seems to be generated just fine. Can you check your listener window ? The OgreXMLConverter command line is printed at the end.
EDIT: should be working. I haven't tried but the command line seems to be generated just fine. Can you check your listener window ? The OgreXMLConverter command line is printed at the end.
Last edited by Banania on Wed Jan 19, 2005 11:20 pm, edited 1 time in total.
Banania
- RyanN
- Halfling
- Posts: 82
- Joined: Thu Aug 19, 2004 6:41 am
- Location: Victoria, Australia
- Contact:
- Banania
- Gremlin
- Posts: 150
- Joined: Wed Oct 20, 2004 2:35 pm
- Location: Paris, France
- Contact:
- RyanN
- Halfling
- Posts: 82
- Joined: Thu Aug 19, 2004 6:41 am
- Location: Victoria, Australia
- Contact:
- Banania
- Gremlin
- Posts: 150
- Joined: Wed Oct 20, 2004 2:35 pm
- Location: Paris, France
- Contact: