Weird normal calculation

ShadowWolf
06-21-2006, 06:13 PM
Thanks to ardman, frisker and Moohasha for the help with getting the lights working. But now there is a new problem which I sort of know how to solve but it seems to be alot of work for such a simple thing (as I see it now) so I want to make sure before I proceed.

1) Look at the 2 pictures below. I think it should be pretty obvious what's wrong there. In the picture where the light is drawn correctly the light direction is Vector3(0, -1, 0), however, in the other picture the direction is Vector3(-1, -1, 0). The light is straight above the room at all times. What I have seen so far, with an effect file I could get a pixel shader to do somekind of normaltranslation for me, obviously rotating it in the correct direction automatically, obviously removing that strange.... gradient. Is there an easier way to accieve this fix (looking at an fx file is enough to make me want to leave this)?

2) Thinking about the future of this test, an effect file would obviously be the right thing to use because that seems to be the only way to draw shadows and reflections? Correct?

ardman
06-22-2006, 01:00 AM
Any chance we can see the code for your FX file and how your implementing it in your code?

ShadowWolf
06-22-2006, 03:38 AM
Any chance we can see the code for your FX file and how your implementing it in your code?

There is no fx file :D feel free to suggest what it might look like :)

ShadowWolf
06-22-2006, 09:28 AM
Actually, nevermind this, or if you are certain of whats wrong then please tell me but atm. I think I know where the problem is. The problem with lights still remain:

point and spot lights do not work at all unless I create the device using SoftwareVertexProcessing. With HardwareVertexProcessing only the directional light works. I have Radeon 9800 Pro, it supports DX9 and all it's features so I do not know why this happens. Could be a programming error in the original dx9 dlls, the ones we use for development that is because normal dx9 games work without ANY problems. This problem could be hardware related, and I will not try to solve this issue now because of the big steps I must now take in my life. Things are chaning and programming is on priority 2 for now on until things calm down again.

RcSepp
07-10-2006, 08:32 AM
Just one idea (don't know if I understood your problem right):
If you took the normals from arrays or anything like that, you maybe could have mixed up which normal preserves to which vertex on a triangle.
I had that problem just a minute ago :) and that helped

ShadowWolf
07-21-2006, 05:12 AM
Just one idea (don't know if I understood your problem right):
If you took the normals from arrays or anything like that, you maybe could have mixed up which normal preserves to which vertex on a triangle.
I had that problem just a minute ago :) and that helped

Thanks for the idea. AFAIK there is no array used for this because I do the room "construction" like this:

1) Load room tiles from a file
2) Build (pre-calculate) matrixes for all meshes using the info in the tile map
3) Calculate the normal (using CalculateNormals) of each mesh and store it in the mesh itself

I think an array would make my room look like the 2nd image all the time but as long as the light stays directly above the room it looks like it does in the 1st image. Once I tilt, rotate or pan the light it goes nuts.

As you can see, I move the meshes into their correct places before I calculate the normals, so I guess that lines out the idea of the normals beeing calculated while the mesh is still at 0,0,0 (which would make them look pretty much like the ones in image 2). Oh and, even if the normals were calculated at 0,0,0 , these lights are dynamical right? Atleast the point light is.

I don't think the 3d editor I'm using (anim8or (www.anim8or.com)) is able to calculate normals or save them into a 3ds file (which should be able to store normals, right?). If I could do that I could try that just in case the built in function is buggy or I'm using it incorrectly.

RcSepp
08-23-2006, 01:39 AM
Event if the normal calculation isn't buggy, I know it wouldn't be the most professional way, but why not try to go through all normals after calculation with a self made function. It shouldn't take long because it's pure mathematik and sometimes this methode gets me to find a little bug in my code (for example a missing - ).

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum