don't click here

SADX Lantern Engine

Discussion in 'Engineering & Reverse Engineering' started by SF94, Dec 23, 2016.

  1. McAleeCh

    McAleeCh

    Oldbie
    1,469
    528
    93
    Wow, this looks amazing - combined with the other recent Dreamcast mods, it looks like this really restores the look and feel of the original version of the game. It's amazing how much atmosphere the original lighting adds to a lot of these areas - you can tell the original art team put a lot of work into it. From watching the comparison videos from the series posted above, it looks like there's still a couple of minor things still to iron out (e.g. clouds you descend through in Red Mountain are still looking darker on the mod compared to the original DC), but it's pretty much 99.9% of the way there now and looks so much better than any post-DC version as a result!

    Hats off for the absolutely incredible job on this - amazing to think something that was only being first discussed a few months ago is now not only a reality but almost fully perfected! = D Looking at the comparison screenshots with vanilla PC DX, it's like night and day - almost literally in the case of Final Egg. Was that really that overlit on the GC version of DX, or did they break it further in the port to PC?

    Really need to get my hands on a copy of DX so that I can try these out for myself - I'm sure even my dinosaur of a PC could just about run this. = P
     
  2. SF94

    SF94

    Tech Member
    Thanks everyone!

    Nah, it's for another mildly interesting reason. That comparison shot uses the SA1 version of the level. In SA1, basically none of the stages (to my knowledge) had vertex colors, so it defaults to a bright diffuse white. SADX's lighting was tuned for stages with vertex colors, so it just looks full bright with the Dreamcast stages.

    In other news:

    There was an oversight that had the potential to cause crashes (particularly in Sky Deck) when you try to restart a stage. I honestly can't be bothered to make a packaged release, so I'd recommend just downloading this build if you happen to run into the issue.
     
  3. When I was comparing the way that the 2004 PC version looked to the GameCube and Dreamcast versions, I noticed that the textures that were meant to ignore lighting like the lava in Red Mountain looked slightly darker in the PC version. I found it to be very odd and none of the newer ports seemed to have fixed that issue. The PC port and the newer ones also had the issue of the character lighting direction in some stages being the same as the direction that the camera pointed. I'm glad that the Dreamcast lighting mod fixes those two problems.
     
  4. SF94

    SF94

    Tech Member
    This is the case in all stages, and it's by design. They could have easily disabled it on PC (it's just a D3D render state; D3DRS_LOCALVIEWER defaults to enabled), and it would have actually been less computationally expensive to do so, but they deliberately left it enabled. Physically speaking, that's how specular lighting is supposed to work; the brightness of the specular reflection depends on the perspective of the viewer. That being said, I used non-relative specular lighting to be accurate, as you could imagine. :v:
     
  5. Turbohog

    Turbohog

    Member
    920
    116
    43
    I second this. I feel like SA2 doesn't get as much modding love as it deserves (not to the fault of anyone I might add).

    Also, I just want to point out another difference between the Dreamcast and PC release. See this video at 3 min 33 sec. The sky at this point of Sky Deck looks so much better on the Dreamcast. Does the sky always look the same in each respective version?
     
  6. PkR

    PkR

    Member
    191
    24
    18
    SADX Dreamcast Conversion, The Emeralds' Awakening
    You might like this (I also animated the clouds):
    [​IMG]
    There's a catch though. The clouds consist of two transparent layers, and apparently there is some code that clips them at different camera angles. It isn't very noticeable in Sonic's stage, but when you play as Knuckles it looks like pretty awful pop-in. I'm gonna need someone familiar with the code to help me fix this thing.
    Also, since this isn't lighting-related, it might be a good idea to discuss this particular issue in the DC Mods topic.
     
  7. McAleeCh

    McAleeCh

    Oldbie
    1,469
    528
    93
    Ah, that makes sense - thanks for the explanation! I should have guessed using the Dreamcast stages with the vanilla SADX lighting might produce funky results. I've never played SADX on PC and haven't played the GC version in donkey's years, but I was pretty sure I didn't remember Final Egg looking like that. Glad it wasn't just my memory playing tricks on me.
     
  8. Turbohog

    Turbohog

    Member
    920
    116
    43
    Ah, my mistake. Sometimes I forget that we have like, 3 topics in which we're discussing SADX Dreamcast stuff. :specialed:
     
  9. Yuzu

    Yuzu

    Member
    2,548
    51
    28
    This looks amazing!

    Going to definitely download this for my next SA playthrough.
     
  10. InstantSonic

    InstantSonic

    Just add water! Oldbie
    Incredible. I never thought I'd see a port of SA with proper lighting outside of the Dreamcast... and yet, here we are, almost 13 years later.
     
  11. ezodagrom

    ezodagrom

    Member
    90
    0
    6
    Having a few framerate dips to 40~55 here and there in the first part of Red Mountain (Sonic) when using this mod together with the Dreamcast Conversion mod. Framerate stays at 60 with either one of the mods, the dips just happen if they're both enabled.
    Using the Steam version with BetterSADX though (which pretty much turns the Steam version to the 2004 version I guess), so dunno if that could be a cause for the dips.

    Framerate is mostly stable in other stages other than a rare dip in a few places. but none as frequent as Red Mountain.

    Specs, AMD Phenom II X4 955 3.2GHz and Nvidia Geforce GTX 1060 6GB.
     
  12. PkR

    PkR

    Member
    191
    24
    18
    SADX Dreamcast Conversion, The Emeralds' Awakening
    I think it's happening because of two things: 1) The palette lighting shader is very CPU-dependent, and 2) The DC mod for Red Mountain increases draw distance, and the PL mod has to process more level geometry as a result.
    Unfortunately I can't reduce draw distance because it causes clipping artifacts like these. Alternatively I could change the way those mountains appear with reduced draw distance, but then it would cause pop-in. So I don't really know if there's a good solution for it. Maybe I'll look into dynamic draw distance at some point.
    Also, you might be aware of this, but that CPU is seriously bottlenecking your GPU. I have no dips at 1080p while running the game on the integrated GPU with an Intel i5-4210M, which is a dualcore laptop CPU.
    Have a look at processes in Task Manager when you're running the game, perhaps you have something resource-intensive running in the background. If sonic.exe has very high CPU usage, then it's probably the PL mod choking it.
     
  13. ezodagrom

    ezodagrom

    Member
    90
    0
    6
    Looks like it may be the CPU indeed. I was mostly just curious on what was causing the dips, they're not very game breaking since they only happen at specific locations, overall it's still more stable (and better looking) than the vanilla Steam version. xD

    Emerald Coast (60fps) - http://i.imgur.com/RW3aRjL.jpg
    Red Mountain (45fps) - http://i.imgur.com/nlTKieR.jpg
    After moving the camera a bit (60fps) - http://i.imgur.com/lw0OG8Y.jpg

    I know about my CPU being a bottleneck, a few months ago I got a chance to get a better GPU for relatively cheap, so I took it.
    I want to upgrade my CPU and everything else other than my GPU sometime, just gotta wait until I have more money though. ^^;
     
  14. I run the game on my onboard Skylate 6700k and it's at a locked 60 100% of the time. Oh AMD.
     
  15. ezodagrom

    ezodagrom

    Member
    90
    0
    6
    Well, the AMD Phenom II CPUs are from the Intel Core 2 era, it's not just a case of it being an AMD CPU, but a case of it being an old CPU.
     
  16. SF94

    SF94

    Tech Member
    The reason it's so CPU dependent is because it has to switch shaders multiple times per frame (and that includes toggling it on and off!), which is really inefficient. It's a Direct3D bottleneck. Ideally what needs to happen is: the mesh to be rendered needs to be put into a queue, and then at the end of a frame the queue should be sorted by the required shader, and then finally rendered. That would reduce the shader switch count from potentially hundreds per frame to a maximum of 3.

    For reference, here's my specs and performance:

    CPU: AMD FX-6300 @ 4.1GHz (overclocked to its turbo speed)
    RAM: 8GB 1600MHz DDR3
    GPU: AMD R7 265 2GB (overclocked core at 1050MHz)

    I'm playing at 1080p, with 16x anisotropic filtering and 8xEQ adaptive antialiasing (which applies the antialiasing to the alpha channel of transparent textures).

    Emerald Coast: http://i.imgur.com/YyRx6bq.jpg
    Red Mountain: http://i.imgur.com/GN7G4mS.jpg
    Red Mountain, other direction: http://i.imgur.com/Er3SrEv.jpg
    Red Mountain, no antialiasing: http://i.imgur.com/YFijQ3F.jpg

    I tested with different antialiasing settings because I've run some profiling, and my GPU driver is getting CPU limited there. As you can see though, on <= modern Intel Core i3 tier performance CPUs (as far as single-threaded performance is concerned), we're getting nearly the same performance despite mine being more modern, and this is all due to that bottleneck I mentioned. This, by the way, is after I optimized shader parameter committing to hell and back (at least, to the best of my ability, although it could still use some work). It used to be worse, which is scary. You'll also probably notice my CPU wasn't even hitting its maximum frequency, which it typically does in multithreaded applications. If I was able to multithread this thing in any conceivable way, I would, but there's just no way to squeeze that into this existing pipeline as far as I can see.

    I really want to implement the draw queue, and in fact SADX has one built in for rudimentary alpha sorting (spoiler: they tried so hard to make that work and it still fails when it's needed). There are a lot of potential complications due to SADX's rendering pipeline though. I know from experience, having already attempted to implement my own alpha sort queue.

    p.s thanks for the performance report; I'm still interested in performance on a wider variety of hardware if anyone is willing to post.

    mfw comparing modern cpu to really old cpu :psyduck:
     
  17. To be fair Skylake is a year old, and it's not that much faster than Haswell. 10% isn't really anything to write home about.
     
  18. ezodagrom

    ezodagrom

    Member
    90
    0
    6
    The Phenom II series is almost 8 years old though, it's Core 2 Quad Yorkfield tier (which is just as old).
    Even the early Nehalem i7 were considerably better, so naturally the more recent CPUs like Haswell and Skylake are alot better in comparison.

    (If the AMD's Ryzen CPUs underperform, then the "Oh AMD" comment will be appropriate).
     
  19. At one point I had a Phenom x4 9500. iirc SADX ran pretty okay.
     
  20. ezodagrom

    ezodagrom

    Member
    90
    0
    6
    This isn't even about just running the game though, it's about running it with the dreamcast conversion mod and dreamcast lighting mod together (which runs mostly fine other than a few sections with drops with such an old CPU).