[Patch] Textures

Technical discussion for those interested in Supermodel development and Model 3 reverse engineering. Prospective contributors welcome.
Forum rules
Keep it classy!

  • No ROM requests or links.
  • Do not ask to be a play tester.
  • Do not ask about release dates.
  • No drama!

Re: [Patch] Textures

Postby Ian » Mon Dec 11, 2017 11:00 am

I think the
Code: Select all
void          IsContourTexture        ( void ) ;


Actually sets the contour type for the texture. Notice it has no return type.

In the sdk it's setting some flag when you call that function
Code: Select all
void __thiscall PRO_Texture::IsContourTexture(PRO_Texture *this)
{
  int v1; // eax@1

  v1 = *((_DWORD *)this + 16);
  if ( v1 & 8 )
    *((_DWORD *)this + 16) = v1 | 2;
}
Ian
 
Posts: 1323
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Textures

Postby Ian » Mon Dec 11, 2017 11:03 am

Yeah I think that's right
If you look at

Code: Select all
      unsigned long     _already_allocated        : 1 ;
      unsigned long     _contour_translucency     : 1 ;
      unsigned long     _rotated                  : 1 ;
      unsigned long     _has_alpha                : 1 ;


contour is the 2nd value

So

Code: Select all
  if ( v1 & 8 )
    *((_DWORD *)this + 16) = v1 | 2;


Should read
Code: Select all
  if ( v1 & _has_alpha )
    *((_DWORD *)this + 16) = v1 | _contour_translucency;
Ian
 
Posts: 1323
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Textures

Postby HarryTuttle » Mon Dec 11, 2017 11:10 am

Ian wrote:
Correcting texture uploading to host GPU (i.e. fix Fighting Vipers 2 tiling problem in helicopters' spotlights during attract demo + correct wrong Emi textures).

Is this not some timing related issue? About the thrashing, check if its the main textures or the mipmaps which are being uploaded

In texture sheet, BindTexture function, there's a check for textures which extend beyond the 2048x2048 area limits, and eventually returns NULL. For those one I've temporarily hacked in a different formula to get the texture dimensions from the polygon header: "8 << ph.TexWidth()", same for height. That will "fix" Emi textures, but I've still work on that, it's not the final solution.

As for the helicopter I've no idea, but the mirrored coordinates are out of phase, so for example instead of being like 0-1-0, they're 1-0-1. I still have to look better at that anyway. I first want to finish the first part involving Texture RAM uploading.
User avatar
HarryTuttle
 
Posts: 609
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Textures

Postby Ian » Mon Dec 11, 2017 11:12 am

I look forward to seeing your patch :) Seems like you've made some really great discoveries!
Ian
 
Posts: 1323
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Textures

Postby HarryTuttle » Mon Dec 11, 2017 11:15 am

Ian wrote:
Implementing texture filtering and coordinate wrapping modes (repeat, clamp-to-edge, mirrored, etc.) in fragment shader, simulating as much as possible the Real3D behavior.

I had actually thought about this one. It's the only way to properly solve the weird non smooth repeat texturing. My current hack works, but the assumption breaks apart somewhat when used with mipmapping, since half a texel shift is no longer half a texel with mipmaps. But it's mostly okay.

There's still something off in Lemans 24 checkered floor, comparing to actual hardware. While Model3 seems "wrong" in this regard, is still different from the PC. I've fixed that, and if I recall there's something in Ocean Hunter as well, screenshots will come...
User avatar
HarryTuttle
 
Posts: 609
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Textures

Postby HarryTuttle » Mon Dec 11, 2017 11:28 am

Ian wrote:
Implementing pixel dilate in alpha channel texels for format-0-and-contour textures, like the Real3D.

What is this thing ? :)

It's this :) Look at the right, the big palm tree foliage edges. I've also applied there a contour threshold of 32/255.

Left = Model3, Right = Supermodel
Image

Here's the theory. It works beautifully for those texture types. SWTrilogy, Sega Rally 2, Harley, ECA, Dirt Devils... are just a few examples where that technique shines.
User avatar
HarryTuttle
 
Posts: 609
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Textures

Postby Ian » Mon Dec 11, 2017 11:49 am

There could be something fundamental we are missing with regards to texture coordinates.
In opengl the lower left is 0,0, in direct3d 9, it's half in the middle of a pixel

Have a look at this
https://msdn.microsoft.com/en-us/library/windows/desktop/cc308049(v=vs.85).aspx
Dx10 now matches how opengl works. But all the versions before it there is quite a subtle difference. Maybe the real3d also has something like that ..
Ian
 
Posts: 1323
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Textures

Postby HarryTuttle » Mon Dec 11, 2017 12:20 pm

Ian wrote:Maybe the real3d also has something like that ..


Regarding my last post, pixel "dilate": I'm using my version of bilinear filtering resulting from 9 texel fetches appropriately blended, bypassing that opengl vs dx9 vs dx10 issue. Since I'm accessing texel data directly I pass integer coordinate values. Only the blending "gradients" are derived from texture coordinates.

Even if I shift the coordinates half-texel in a given direction, the whole texture would be shifted in respect of the polygon position. I already tried that just to exclude any possibility of half texel issue.

What is happening here, instead, is that the edge texels "bleed" toward the "outer", transparent, texture area copying their RGB values there, while leaving the alpha channel intact. Infact the texture edge is cut in respect of the original alpha value, while its color is replicated from the "inner" texels.

This fixes, with the appropriate contour threshold, all the ugly white/black borders (but even some colored ones) in contour textures.
User avatar
HarryTuttle
 
Posts: 609
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Textures

Postby Ian » Mon Dec 11, 2017 12:56 pm

Yeah that's quite interesting. I guess it's entirely possible they rolled some custom texturing to support contour textures
Ian
 
Posts: 1323
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Textures

Postby Ian » Mon Dec 11, 2017 4:43 pm

Harry,
post what you have done so far with the texture mipmapping :) It shouldn't be too hard to finish off ? :)
Ian
 
Posts: 1323
Joined: Tue Feb 23, 2016 9:23 am

PreviousNext

Return to The Dark Room

Who is online

Users browsing this forum: No registered users and 1 guest