Upspring 1.54 - Page 11

Upspring 1.54

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Hmm, here's an idea... maybe it's not reading the model's new X axis correctly, if you have to rotate it (does experiment).

Nope. That's not it. Dunno what's causing this.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Ok... here's what's going on:

Something in "recalculate vertex normals" corrects this problem. I don't know why, either- it looks fine in UpSpring, but in UpSpring, the light is moving with the camera, so I suspect it's hiding the problem, which I strongly suspect is being caused when the model is being imported.

If you make a 3DS mesh of a simple sphere, and then bring it into UpSpring, and just export it to whatever, then it is *always* screwed up. If you do "recalculate vertex normals", then it quits doing this, but it also removes all the verts that we need for nice, sharp edges and a lack of artifacts from shading.

I've tried exporting from 4 different pieces of software: LithUnwrap, Rhino3D 3.0, Milkshape3D, and Wings. I've tried OBJ imports (not that I want to use OBJ) and it's actually worse... OBJ models do not have proper normals on import, and must use "recalculate vertex normals" to display at all correctly.

All had the same result. It's actually easiest to see this problem if you use a simple texture and turn the shadows off, but it's clearly reversing the X axis- and only that axis. Everything else is perfect :?

Here's a quick proof. Trust me, it did this every time, with every model tested- and it's also just as clearly something reversing the X-axis of the normals, because at certain angles the models look good, if you're not looking at the shadows, or another model nearby providing contrast. It really did take me a second to see this clearly the first time, since the shadows on this map (Tropical) are mainly along the X axis.

Image

Whoa... here's with shadows on. The light is obviously coming from an impossible, inverted direction. It's not inverted on the Y or Z, as you can see- just the X, where that pinpoint sun helps us clearly see the problem.

Image

This has gotta be a single math error in the import code, I'm guessing. Unless you tell UpSpring to "recalculate vertex normals", it doesn't seem to actually *do* anything with the normals.
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

Uploaded the WIP version again :
http://user.supradigital.org/jcnossen/U ... %20WIP.exe

* Fixed weird lighting
* Undo/redo now working without slowness, also please notice the photoshop style history viewer :)
* Light unlockable from camera

But I still couldn't fix that normals bug, can you send me a not-working 3DS example.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Okie doke! The normals thing is the only major issue, then! I really like the configurable light, btw, although it'd be nice to specify a non-black level for ambient.

As for the normal thing... here ya go:

Click here to download two sample objects, in 3DS format. These objects are always shaded wrong, unless "recalculate vertex normals" is used.

I had a weird thought... I don't suppose that this might be being caused by whatever code you changed so that the orientation of an object in UpSpring matches the orientation/mirroring of Spring? That would involve normal translation, surely. Just a thought.
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

Image

Doesn't seem really wrong to me, I thought the problem was normals with X=0. Maybe you mean the non-merged edge? That would mean I have to write my own normal calculation instead of using lib3ds's
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

They look fine in UpSpring... but bring 'em into Spring... and:

Image

Image

As you can see very clearly with shadows on, the light is inverted from the actual direction the sun is shining. That's what's wrong here. The Y-direction lighting is right (otherwise, these objects would be all dark, in this top-down shot), the Z-direction light is right (otherwise, we would see the top edges in this shot getting more light than the bottoms)... it's the light from the x-axis that is wrong. And it's unique to these models- older UpSpring stuff is fine, 3DOs are fine. Do you want a quick mini-mod, so you don't have to bother attaching a saved S3O to a unit and can see what I mean immediately? I could build a tester really quick-like.

And no, I don't mean merged/non-merged edges, or stuff like seams. Those are all a modeler's problem, don't worry about them- the sphere has one because I didn't bother doing a good job with the uvmap.
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Upspring 1.5

Post by jcnossen »

Ah everything is clear now, that was an easy fix actually!

http://user.supradigital.org/jcnossen/U ... er-1.5.exe

Complete changes for 1.5:

- Fixed wrong normals in X-direction for exported S3O models
- Undo/redo support + History viewer (Called Undo buffer viewer)
- Lighting unlockable from camera
- Fixed weird lighting when using untextured solid rendering
- Fixed "add empty"
- Fixed and improved "Set S3O texture dir"
- 3DS smoothing groups are used when 3DS files are imported.

Maestro: If you're reading this, I seem to have lost your latest PDF, and I'm not sure if the one in 1.43 is the newest, so thats why its not included currently
Last edited by jcnossen on 16 Mar 2007, 02:54, edited 1 time in total.
User avatar
MadRat
Posts: 532
Joined: 24 Oct 2006, 13:45

Post by MadRat »

Its almost like its placing the shading on the faces but doesn't realize the traingle perspective relative to the light source and therefor those faces are not actually aligned the direction they should. I mean if you look closely it sees the faces on the left of the object as if rotated them 90º off kilter, and the faces nearest to the light source are rendered completely ass-backwards. The darkest gradient should be away from the light source, not nearest it.

I'm only guessing here, but could the bug be in Spring's rendering engine and not in Upswing?
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

It's still inverted in Spring. UpSpring's lighting now matches Spring though, lol!
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

Its good now right?
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Nope. Or did you just do one more build past 1.5?

Ah, you did... <tests>

YES!!!

It *totally* works. Now all I've gotta do is export every model, fix the smoothing angles, and re-import them, and ... finally... no more welding problems! THANK YOU!
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Post by FLOZi »

Time for a celebration. 8)
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Time to get to WORK!

I'm going to have to export-->repair-->re-import quite a few models.

But... it's going to be soooooo worth it.

BEFORE: crappy welding issues making models look badly shaded and ugly.

Image

AFTER: clean cuts, sharp edges, smooth curves! Even on this old thing, which I'll be the first to say has some fairly nasty flaws as a model, the difference is immediate.

Image

The final test... is a FPS test, to make sure that this didn't make things render horribly slow or whatever. I very much doubt it, but we are processing quite a few more verts per model with this, so if you're making a really performance-based mod like NanoBlobs, you're going to want to weld completely whereever you can get away with it.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Image

...and that's a fairly crappy, poorly-skinned model, with me rushing it out. Just imagine what our stuff's going to look like when we're taking full advantage of this.
User avatar
Peet
Malcontent
Posts: 4384
Joined: 27 Feb 2006, 22:04

Post by Peet »

Wow...major improvement. The shading..so much better. Now I just need to learn to texture properly :)

<offtopic>btw, what's the tricount on those teamcolour balls?</offtopic>
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

BTW, be careful: Hard edges break tristrips which can greatly increase the model's resource footprint.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Post by smoth »

Problem, the new version of upspring is importing my obj files without normals. I have use the generate normals option and this results in really ugly normals.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Post by FLOZi »

smoth wrote:Problem, the new version of upspring is importing my obj files without normals. I have use the generate normals option and this results in really ugly normals.
Use 3ds. :P
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

3ds is a horrible format, even MAX users hate it because it unwelds the vertices along UV seams. Also not every 3d application handles every format well.
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

I haven't changed anything in OBJ loading code...
Post Reply

Return to “Engine”