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 messed up?

Author
Message
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 11th Oct 2011 13:37
This speaks for itself:



How can I make my plain object glow like that, no matter what angle it has?

TheComet

WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 11th Oct 2011 14:31
I added this and fixed it:



Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 13th Oct 2011 23:26
What does that command exactly do WLGfx? The help is very generic about it, every model has got normals don't they?

-In.Dev.X: A unique heavy story based shoot'em ~35%
-CoreFleet: An underground commander unit based RTS ~15%
-TailsVSEggman: An Sonic themed RTS under development for idea presentation to Sega ~15%
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 13th Oct 2011 23:40
When your moving vertices around without manually calculating the normals that command calculates all the normals for you. The normals of an object help with lighting it correctly.

In the code above TheComet creates a plain object and changes the vertices without setting the vertex normals.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
revenant chaos
DBPro Master
19
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 13th Oct 2011 23:50
Quote: "every model has got normals don't they?"
Nope, only certain object fvf's (flexible vertex format) have vertex normals.
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 14th Oct 2011 00:29
Awesome, so there was that command all the way and i have been working on codes to calculate normals manually. Cool.

-In.Dev.X: A unique heavy story based shoot'em ~35%
-CoreFleet: An underground commander unit based RTS ~15%
-TailsVSEggman: An Sonic themed RTS under development for idea presentation to Sega ~15%
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 14th Oct 2011 01:06
The problem is that he starts with a plane that is horizontal, with normals pointing straight up, then he repositions the vertices in the plane to form a vertical plane without adjusting the normals in the equivalent way.

The best way to do that, rather than adjust the vertices and their normals, is to simply rotate the plane around the x-axis, then FIX OBJECT PIVOT.

WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 14th Oct 2011 01:09
Yup, I've noticed there's not just me been playing around with vertexdata commands lately.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 14th Oct 2011 02:01
Now that the FVF (flexible vertex format) has been mentioned, anyone could let me know which is the one that has four vertices to build up a polygon instead of 6 (2 triangles)?

It's a nightmare, and possibly not the most efficient either, to make objects that way.

-In.Dev.X: A unique heavy story based shoot'em ~35%
-CoreFleet: An underground commander unit based RTS ~15%
-TailsVSEggman: An Sonic themed RTS under development for idea presentation to Sega ~15%
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 14th Oct 2011 02:20 Edited at: 14th Oct 2011 02:23
Normally DBP objects are set with FVF 274 (i believe, I use it), some use 378... Somewhere around here, I'll dig it out in a mo, there's a full explanation of the FVF format.

IanM's MAKE OBJECT NEW allows you to do that. I'm just adding some extra 3D object creation commands to a new plugin I'm working on. Some may find it useful, but it does exactly what you're saying Quel. 4 vertices instead of 6 and a cube using 8 vertices instead of 24.

Using 8 vertices on a cube does make the lighting look very different as it looks smoothed around sharp corners but useful for some things.

Sharing vertices in this way is actually more useful for terrain objects as once the normals are calculated the lighting look decent.

EDIT:

It doesn't explain much but it's a start as to where the numbers come from.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 14th Oct 2011 14:35
Thanks guys

@ quel



DBP uses a value of 338 by default, because it uses 36 bytes of data for each vertex.

FLOAT - x position of vertex
FLOAT - y position of vertex
FLOAT - z position of vertex
FLOAT - x normal of vertex
FLOAT - y normal of vertex
FLOAT - z normal of vertex
DWORD - diffuse of vertex
FLOAT - u value of texture
FLOAT - v value of texture

This all adds up to 36 bytes, and 3 vertices form 1 polygon. The FVF is 338 because it uses:

FVF_XYZ 0x002
FVF_NORMAL 0x010
FVF_DIFFUSE 0x040
FVF_TEX1 0x100

0x002 + 0x010 + 0x040 + 0x100 = 0x152 = 338

My modeling program uses an FVF value of 274, because it exports the model without the diffuse value. Again:

FVF_XYZ 0x002
FVF_NORMAL 0x010
FVF_TEX1 0x100

0x002 + 0x010 + 0x100 = 0x112 = 274

TheComet

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 14th Oct 2011 15:34
Quote: "DBP uses a value of 338 by default, because it uses 36 bytes of data for each vertex"

Not for a long time - it also uses 274 now.

Login to post a reply

Server time is: 2026-07-11 14:36:53
Your offset time is: 2026-07-11 14:36:53