toji / webgl-source

WebGL renderer for Source Engine levels
238 stars 23 forks source link

Graphical distortion with some models #5

Open dvelovski opened 4 years ago

dvelovski commented 4 years ago

I know it's been quite a while since you would've worked on this code (and I am very thankful that you've shared it with the world, too), but I've recently decided to pick some of it up and try adapting it for my own project - namely the code where you load Source engine models.

It's worked flawlessly for the most part, however there are some issues I was hoping you could give me some pointers or ideas on how to fix - primarly that there is a fair bit of distortion that affects some (maybe 1 in 25 or so?) models, as you'll see below...

image

To the extent I could, I've replicated or closely adapted your code into Java and I am left scratching my head as to what's caused this - did you experience this issue throughout your development of this project at all, or do you have any idea what might be causing this problem? The image included is when I load a model with LOD 1 - loading with LOD 0 affects even more models.

Thanks so much for having a read of this <3

toji commented 4 years ago

Hoo boy, it HAS been a long time since I looked at this! Most of my knowledge of the formats quirks at the time were dumped into this blog post, which has a few links off to various resources that are probably more help than I will be at this point.

I do recall that when parsing these files there was at least one offset that wasn't actually specified explicitly (that I could find), and instead had to be computed by figuring out the size of all the chunks that had come before it in the same data array. If I were to point at anything that felt particularly brittle about my code that would be the first thing I would be suspicious of, but it's not guaranteed to be the source of your artifacts by any means.

Really the best I can suggest is to look through the community-compiled documentation on these formats and compare to your/my code to see if there's any obvious errors or omissions. Any if you do get it sorted out let me know! I always enjoy seeing projects that my past work has contributed to or influenced in some way!