Page 2 of 3

Re: Quad Rendering Code

PostPosted: Mon Oct 16, 2017 12:38 pm
by Ian
Do you mean that using that keyword throws out an error or just ignores that?

It just didn't do anything, no compile error. It just did regular interpolation.

Noperspective should make textures ugly like this
Image

whilst default smooth interpolation or 1/z looks like this
Image

http://www.geeks3d.com/20130514/opengl- ... -tutorial/

Re: Quad Rendering Code

PostPosted: Mon Oct 16, 2017 2:58 pm
by Ian
Well I fixed the issue with the bad quad. Although I am emulating quads, it's really still drawing 2 triangles, and depth testing as 2 triangles. Anyway the order was flipped from what we had it as originally
which was just
0,1,2 triangle one
0,2,3 triangle two

Anyway the quad probably wasn't planar, hence the difference in depth testing
Anyway .. looks like this now. Might make sense to looking into emulating proper depth values for the quad .. although not sure we'll need to go that far. Only an issue for non planar ones anyway.

Image

Re: Quad Rendering Code

PostPosted: Mon Oct 16, 2017 3:36 pm
by HarryTuttle
So, if I understood well, this mean the original hw probably could have splitted a non-planar quad into triangles for proper depth testing?

Re: Quad Rendering Code

PostPosted: Mon Oct 16, 2017 4:09 pm
by Ian
I think the original hardware just natively drew quads. The broken poly on the front of the car is still there. If you flip the triangle split it disappears. So if we natively emulate the depth value for quads it should all hopefully go away ..

Re: Quad Rendering Code

PostPosted: Wed Oct 18, 2017 5:41 pm
by Ian
Well ..
I made a bit more progress with this tonight
I had a go at emulating the depth values for a quad, instead of using the actual value for the 2 triangles
Formula is simple, just this

Code: Select all
gl_FragDepth = ((zDepth * interp_oneOverW) + 1.0) / 2.0;


Anyway :) It finally fixed the missing poly on the car in scud.

Image

Image

Originally I thought that missing poly was a bug in the actual game or something, but nope, it was just being depth tested out. I bet this is why they probably never ported scud over, because without proper quad emulation the models just fall apart. Tesselation when I tried it only works well enough when you really ramp up the number of polys, which isn't practical.

Re: Quad Rendering Code

PostPosted: Wed Oct 18, 2017 7:31 pm
by YoYo09
Ian
Is this symptom related to quad rendering too?
Or is it a texture problem?

Image

Re: Quad Rendering Code

PostPosted: Wed Oct 18, 2017 10:09 pm
by Bart
I think character outfits in VF3 have numerous issues related to rendering order, especially Aoi's translucent dress.

Awesome work, Ian! I don't quite understand why depth values would be incorrect for an ordinary quad that is comprised of two coplanar triangles. Why aren't they mathematically equivalent?

Re: Quad Rendering Code

PostPosted: Thu Oct 19, 2017 1:28 am
by Ian
Yoyo,
not sure, maybe. I had noticed those polys before but just assumed it was one part of the model poking through the other. Not sure they are transparent.

Ian! I don't quite understand why depth values would be incorrect for an ordinary quad that is comprised of two coplanar triangles. Why aren't they mathematically equivalent?


They are mathematically equivalent for co-planar quads. But the quads on the car aren't co-planar, they are bent :p

You can see the issue here. With the first split the quad is bent downwards. With the 2nd it's bent upwards.
Image

The proper quad emulation it's like a mix between the 2, which gives us very different depth values.

The depth issue is a lot easier to solve with tessellation. But the texturing of quads is much harder. When experimenting I increased the poly count by a factor of 10, then finally the lines on the car were the shape they were meant to be. But at 10x the polys it started to choke the renderer. But increasing the resolution brought the same problems back again. So yeah I guess this would make porting scud pretty hard without really going back and re-texturing/remodeling the cars.

This is scud race on demul. I guess this was some prototype/demo version for the dreamcast, I don't know if it was ever released?
You can see the same bug there
Image

I've honestly never seen any other renderer attempt to actually properly emulate quads, I don't know if this thing is a first or what. :)
But not quite sure what to do with the code. I'm not even sure Harry can run it on his pc.. and that's not good at all, since he has been such a major contributor to the project. I think the best idea might be to simply have 2 sets of shaders that can be switched between versions. The shader inputs are identical. That might be one way of doing it.

Re: Quad Rendering Code

PostPosted: Thu Oct 19, 2017 1:32 am
by Ian
Yoyo
how's this ? :)
Image

Re: Quad Rendering Code

PostPosted: Thu Oct 19, 2017 2:16 am
by YoYo09
Ian wrote:Yoyo
how's this ? :)
Image


Awesome :D

thank Ian