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 / Object Triangle change brightness ??

Author
Message
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 2nd Sep 2011 02:28 Edited at: 2nd Sep 2011 02:32
Hi there. I made a cylinder with triangles to have more control to vertex. I have made 36 triangles and made meshes and joined them all to make a single mesh. I gave UV to all triangles first,and the cylinder looks OK, but depending on the camera angle, or mesh position, it changes brightness which gives an undesirable appearance.
I tried lots of things....seting object emissive , seting object normals and what not, and I can't figure out what's wrong with it


I hide light 0 and put one light on camera position, and the object get lit from 300º to 0º and from 0º to 60º . Any idea ?




Cheers.

I'm not a grumpy grandpa
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 2nd Sep 2011 02:34
When I was messing about with my random level generation code, I found that my faces were the wrong way round but I didn't notice til after everything was done. I turned the culling off and I found I needed to reverse all faces.

Warning! May contain Nuts!
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 2nd Sep 2011 02:39
I have tried with set object cull obj,0 and the cylinder are made with 18 triangles plus 18 triangles adjusting UV.

Cheers.

I'm not a grumpy grandpa
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 2nd Sep 2011 02:44
I noticed that lighting doesn't affect the other sides of a face that's not culled. How did you get on?

Warning! May contain Nuts!
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 2nd Sep 2011 02:59
Try

set object light obj, 0



chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 2nd Sep 2011 03:09
The two cylinder are the same object, but one of them is rotated 180º


Quote: "Try

set object light obj, 0 "



@Indicium WORKS !! unbelievable but true

Thanks for the help friends !!

Cheers

I'm not a grumpy grandpa
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 2nd Sep 2011 03:12
I'm glad I could help.

Indi.

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 2nd Sep 2011 03:15
I found another problem...now the object is always lit even with no light and ambient light 0....but better than nothing

Thanks any way

Cheers.

I'm not a grumpy grandpa
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 2nd Sep 2011 03:17
Yeah I guess that isn't great. :/ It's the best I can think of. It isn't an issue in my game because I set my light levels using the vertexdata diffuse command.

Sorry I couldn't be more help.

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 2nd Sep 2011 03:19
Maybe this time object emmisive will work?

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 2nd Sep 2011 03:23
Quote: "Sorry I couldn't be more help."


Don't worry ..thanks for you help.


Quote: "Maybe this time object emmisive will work?"


I had tried that and didn't work. Finally I have found a solution

set object ambient 1,1

Cheers.

I'm not a grumpy grandpa
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 2nd Sep 2011 03:49
What happens when you save them as X and reload them?

Benjamin
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 2nd Sep 2011 04:43
Try altering the scale of the object, it might have some impact.



Support a charitable indie game project!
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 2nd Sep 2011 07:28
When I created mine from scratch I used the 'Set Object Normals' to calculate the normals. I didn't alter any of the lighting. The same goes for the triangles.
Just a quick snippet but outside the function I used

Hope you get it working man...

Warning! May contain Nuts!
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 2nd Sep 2011 11:55 Edited at: 2nd Sep 2011 11:57
Hi again.
@Pincho Paxton
After making lots of proves, the object keep flashing when it turns.I have saved as .x as .dbo and when I load it makes the same.

@Benjamin.
I have done that, and perhaps when I scale the object to big, help a bit, but I habe to scale the whole map with the rest of objects.


@WLGfx
At the moment, what I have done, is seting object light to 0 as Indicium said, and the object looks ok, but even switching off lights, the object will be lit...the same occur when seting object emissive and set object ambient.

Here I have a rar file with both .x and dbo if someone want to try.

Use this piece of code to see what I meant. Use any image with the object.



Cheers.

I'm not a grumpy grandpa
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 2nd Sep 2011 16:50
Just checked out the object. All the faces are inverted. You will need to reverse the order of the vertices when you're building your face list with the indices. (I just swapped two of mine over)

Also without texturing the object it will appear black because you haven't set the vertex diffuse values. I just added color object 1,0xffffff to brighten it up.

The faces orientation will need swapping though, as I said above I just swapped two of the three values over and it worked...

Warning! May contain Nuts!
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 2nd Sep 2011 17:11
Quote: "You will need to reverse the order of the vertices when you're building your face "


Do you mean that if I made my triangle with 1,2,3 ...I should do it like 3,2,1 and the same for all of them ?

I will try that thanks.

Cheers.

I'm not a grumpy grandpa
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 2nd Sep 2011 17:16 Edited at: 2nd Sep 2011 17:17
Yep, fingers crossed that solves your problem, mine were store as v1, v2, v3 but instead of creating the faces in that order I had to create the face using v1, v3, v2.

It wasn't such a big problem because I knew at the time that if that happened I could simply do that. When I tried yours, just like mine, I set the culling and found that was the case.

IanM's make object new command has opened up a lot of possibilities.

EDIT: Lighting seems to affect the frontside of the face properly. The other side always seems darker for me.

Warning! May contain Nuts!
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 2nd Sep 2011 17:22
Quote: " fingers crossed that solves your problem"


I tried that as you suggest, but didn't work with the light, I had to calculate the whole UV for that faces and now I have to start again

Thanks anyway , I will keep trying to solve.

Cheers.

I'm not a grumpy grandpa
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 2nd Sep 2011 17:28
The UV coords you shouldn't have to re-calculate. It's only the face orientation going from clockwise to counter clockwise that makes the difference. The vertex UV's stay the same. You could try not having set any lighting in your test scene or object, set the diffuse to white on your object, and then just add a single light near the camera.

Have a look at this code, it's complete and works 100%.



My objects are light perfect even though I've not set any lighting on them. I've used a single scene light.

Warning! May contain Nuts!
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 2nd Sep 2011 18:07
Ok then, I'll try that, I wouldn't like to get stucked with this handicap

Cheers.

I'm not a grumpy grandpa
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 3rd Sep 2011 00:33 Edited at: 3rd Sep 2011 00:34
It doesn't matter the order I make the object triangle, it keeps doing the same.I have not apply any UV yet, and the object change brightness even with the light in the same position of the camera.

@WLGfx
Could you apply your function to just one triangle ?, I'm gonna get rid of this system





Cheers.

I'm not a grumpy grandpa
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 3rd Sep 2011 13:22
That's strange, I wasn't expecting that:

I made two triangles with culling but for some reason it does do the same.

Light 0 is the ambient light, so I added a separate light.

I'm going to investigate this a little further. The result isn't right and what I was expecting so you're right there...

Warning! May contain Nuts!
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 3rd Sep 2011 13:23
Fixed: re-calculated the normals and it works!!!



Warning! May contain Nuts!
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 3rd Sep 2011 13:38 Edited at: 3rd Sep 2011 14:15
@WLGfx

Really works with the trick of two objects per face . That`s better than nothing Thanks .

EDITED

I have been trying to make all triangle at once, and every row has five objects . I make a secuence 1,2,8 -2,3,9- 3,4,10- etc. and when row ends I jump to the next row, but triangles 6,11,16,21 are not made in the place I expected. I know that is my fault but I can' fide a solution , and must be a stupid thing.

Here's what I do.



Cheers.

I'm not a grumpy grandpa
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 3rd Sep 2011 14:17
This creates one object:



Warning! May contain Nuts!
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 3rd Sep 2011 14:25
Sorry , I was editing my last post above. Now it works as it must do . It's just a question to apply the same to all the rest of my triangles in my model Thanks. What is driving me crazy is the example I posted above


Cheers.

I'm not a grumpy grandpa
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 3rd Sep 2011 14:33


I've set var d to go from 0 to 5 instead of 1 to 6...

Warning! May contain Nuts!
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 3rd Sep 2011 14:41 Edited at: 3rd Sep 2011 14:43
@WLGfx

Works !! . I'm a noob. I'm getting too old ,and many hours in front of my PC...I'm gonna go blind.

Thanks again.
Cheers.

I'm not a grumpy grandpa
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 3rd Sep 2011 14:44
LOL... Too old??? I've been programming now for 30 years...

I'm still waking up and I've got to get some coding done...

Warning! May contain Nuts!
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 3rd Sep 2011 15:00
So you must be as old as I am
This was my first "PC" Amstrad CPC464 (1984)





http://www.neoteo.com/retroinformatica-amstrad-cpc464-1984

Cheers.

I'm not a grumpy grandpa
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 3rd Sep 2011 15:47


Vic-20 3.5k Ram (I had a 16k ram pack)

That was before I got a ZX Spectrum 48k

Warning! May contain Nuts!
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 3rd Sep 2011 15:51 Edited at: 3rd Sep 2011 18:16
I started 1980 with a zx80, and 1981 with a speccy.

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 3rd Sep 2011 16:21
So we are all over 50+

Cheers.

I'm not a grumpy grandpa
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 3rd Sep 2011 17:47
Oh gods no! I'm a year away from 40... I've given up having birthdays now. I started when I was 9.

I'm not yet a grumpy grandpa

Warning! May contain Nuts!
JackDawson
14
Years of Service
User Offline
Joined: 12th Jul 2011
Location:
Posted: 3rd Sep 2011 17:53
Wow, I remember the ole Vic-20's. Used to program to my hearts content during that time period in the early 1980's. ( Gotta love Peeks and Pokes ). I also loved the Commodore 64 and 128 as well. I remember with the Vic-20 making a circut board that allowed me to hook up a Tape Recorder and use it as my hard drive to store my games I created. Lots of fun back then.. man.. the good ole days.

I remember having to build my own electronics back in the 1970s as well. My first thing I created was a Heathkit radio back in 1977. And in 1978 it was the Heathkit H-8. It was the first computer I ever got my hands on. I was 8 years old at that time.



"Son, I crap bigger then you !"
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 3rd Sep 2011 18:19
I'm 48. I've worked in the game industry on the Amiga computer as a graphic artist. I worked on Dragon Breed, Rtype-2, Robozone, Predator 2, Armalyte and The Simpsons.

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 5th Sep 2011 02:51 Edited at: 5th Sep 2011 02:54
Hi again. I came with the same code above that make 50 triangles, and every two triangles form a face. First I made a grid of objects to have the reference of the vertex of every triangle, so I made six rows of six objects ... 36 in total. Then with a for next I made all triangles between reference grid.

Now I have a problem when trying to texture correctly all of triangles. I'v done it, but in a noob way, and works, but I'm trying to make that in other automatically way.Take a look to this piece of code, and use any image to see what I mean.

if I make it so like a noob:
if d=5 then d=0:f=f+6

if i>0 then d2=1
if i>5 then d2=2
if i>10 then d2=3
if i>15 then d2=4
if i>20 then d2=5
render image on the left.

if I make so:

if d=5 then d=0:f=f+6:d2=d2+1
render image on the right



Being just 5*5 , is not a problem making that as a noob, but imagine that we need 50*50, I don't want to write 50 lines of code .I can't find where to inc the var .Someone can help?

I slowed down the code to see better the construction



Cheers.

I'm not a grumpy grandpa
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 5th Sep 2011 03:26
It would be so much easier to store the info in an array. Or to use and X and Y nested loop to set up the object.



It looks like your code could get confusing the larger the area your covering...

Warning! May contain Nuts!
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 5th Sep 2011 03:36
Quote: "It would be so much easier to store the info in an array. Or to use and X and Y nested loop to set up the object"


Yess if it was a scuare face, but the object is made of triangles, and when we texture a triangle, we have to play with the UV.


Cheers.

I'm not a grumpy grandpa
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 5th Sep 2011 03:46
I'm actually developing my current terrain using a similar method, converting a 2d array height map. I'll have the code soon so you can check it out.

Warning! May contain Nuts!
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 5th Sep 2011 04:05
Ok , when you get it ready . What I need now is find a solution into the bucle FOR NEXT to rig the whole image at once, if not I'll will use someother method.

Cheers.

I'm not a grumpy grandpa
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 5th Sep 2011 05:07
I've just posted it in my other post http://forum.thegamecreators.com/?m=forum_view&t=189029&b=1&msg=2254663#m2254663 with the entire proto type code...

Warning! May contain Nuts!
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 5th Sep 2011 14:18 Edited at: 5th Sep 2011 14:21
@WLGfx
Yesterday night, I was to tired and didn't try what you suggest about storing the info in an array. This morning I tried that, and I realized that both variables increment the same, and that was not good, as we have five rows of five pictures each.

so we start in:
1 2 3 4 5

and when we reach to 5, we have to jump to next row , so if a=5 then b=1 but when a=6 then b=2

finally I found the problem





We can convert all to dbo, and when we load it again, the object will be properly textured and we can rescale texture and blend textures to it

Thanks for your help
Cheers.

I'm not a grumpy grandpa
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 5th Sep 2011 14:39 Edited at: 5th Sep 2011 14:40
Automatic...



EDIT: Oh you figured it out.

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 5th Sep 2011 14:59
Quote: "Oh you figured it out.

if count > 5
inc number
d2= number
count = 1
endif
inc count"


It doesn't work to me with your formula but I found a solution





Cheers.

I'm not a grumpy grandpa
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 5th Sep 2011 15:58 Edited at: 5th Sep 2011 16:00
You didn't notice count = 6 at the top. Your solution is better though.

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 5th Sep 2011 21:13 Edited at: 5th Sep 2011 22:44
Finally I'v got it working. You can download complete example here:

http://forum.thegamecreators.com/?m=forum_view&t=189029&b=1&p=0#m2255070






Cheers.

I'm not a grumpy grandpa
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 6th Sep 2011 15:15
I'm not sure if this is relevant now, but in your earlier snippet a few posts back you had



The following seems simpler and does the same thing:

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 6th Sep 2011 15:38
Works !! Thaks Green Gandalf .It was just a stupid way I did. If you read the complete thread, I mention the problem I had. Finaly I found a solution that works too



Thanks anyway.

Cheers.

I'm not a grumpy grandpa

Login to post a reply

Server time is: 2026-07-10 15:31:38
Your offset time is: 2026-07-10 15:31:38