Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Lighting problem with dynamic generated object

Author
Message
Westmere
16
Years of Service
User Offline
Joined: 12th Mar 2010
Location: Germany
Posted: 13th Dec 2010 17:16
Hello all,

I am currently having a little problem and I hope I can find help here.

For a little game I am currently working on I need dynamicaly generated 3D objects. The way I\'ve been going about this is by calculating the corner points and \"making\" a lot of triangles to build up the object.

I then melt them all by using Vertexdata commands to form the final object. This actually works how I need it, at least when I look at the form. Lighting however is a totally different matter.

There are two lights above and slightly to the sides of the camera. When I turn the object to look directly at it\'s front end it appears like something flat and blue (blue is the color it has). When I turn it around it appears completely unlit. A side view will have a transition between lit and unlit which doesn\'t seem to have anything to do with it\'s form. I\'ve added pictures in a zip-file so you can see what I mean. I also added a wireframe screen shot. The backdrop is just a random picture to give it a back drop for testing.

I do not move the camera nor the lights. I just turn the object.

Applying specular properties does not affect it noticably, applying a skysphere will cause the entire object to flicker in different colors of the picture used. I mean the ENTIRE object has just ONE of these colors and flickers to a completely different one when turned. (WTH?)

I also tried using the metal.fx from the pelican demo on it as an experiment. It looked like the object was cutting throught the backdrop revealing another picture (from the reflection) behind it.

Here are some code snippets to show you some of the steps the program does (can\'t post everything as the entire thing is at ~3000 lines of code, just this one gives me a headache:



I Also tried changing the UV texture coordinates in the vertex data stuff but (maybe) since I had not idea what they should be that also didn\'t change a thing. Might also be because the object is untextured and just uses one color.

If I place a sphere right at the position of the object the sphere will be nicely lit and shaded. So I\'m guessing the problem has something to do with the way the object is generated.

Does anyone here have enough knowledge about this stuff to be able to tell me what could happen or how I could fix this?
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 13th Dec 2010 19:23
Do you fix the normals?

My signature is NOT a moderator plaything! Stop changing it!
Westmere
16
Years of Service
User Offline
Joined: 12th Mar 2010
Location: Germany
Posted: 13th Dec 2010 22:48


Now that you are saying it, it actually all makes sense. I guess I was so set on those UV coordinates that I didn't even think about the normals.

A simple
fixed it all...

Now the reflections also look good. Thank you very much.
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 14th Dec 2010 19:18
Yay! Glad I could help!

My signature is NOT a moderator plaything! Stop changing it!

Login to post a reply

Server time is: 2026-07-21 07:03:43
Your offset time is: 2026-07-21 07:03:43