[Patch] MicroTexture

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] MicroTexture

Postby Shekel » Tue Mar 14, 2017 3:04 am

Your frame comparisons are always really good, Harry.
User avatar
Shekel
 
Posts: 343
Joined: Wed Mar 16, 2016 12:45 pm

Re: [Patch] MicroTexture

Postby Ian » Tue Mar 14, 2017 5:37 am

Well,
I finally found a video where I can see this

https://www.youtube.com/watch?v=3y3WupfbEPU

If you look at the dark line in the middle of the road you can see it's progressively eaten by the microtexture. But honestly I wouldn't say it's blended, it straight up looks like the microtexture is only applied to the first mipmap level, because there is a hard line between the mipmap levels.

Should we emulate this? I dunno I am mixed. It's probably a performance cheat they are doing on the hardware itself. But we are bound by no such limitations.
Ian
 
Posts: 1216
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] MicroTexture

Postby Ian » Tue Mar 14, 2017 5:40 am

good image of it

Image
Ian
 
Posts: 1216
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] MicroTexture

Postby HarryTuttle » Tue Mar 14, 2017 5:51 am

Ian wrote:good image of it

Image


Good catch! :D On high-contrasted images it's effectively easier to spot. About the hard seam: i think that it's a bit exaggerated by the contrasted image.

Ian wrote:Should we emulate this? I dunno I am mixed. It's probably a performance cheat they are doing on the hardware itself. But we are bound by no such limitations.


IMHO, I think we should do that, for the sake of accuracy. It's always possible to remove such a limitation in a config option (think of some sort of enhancement features, like Model2Emu or Dolphin Emulator).

I think also that they, at Sega, took advantage of that limitation on purpose, that is display speed and/or detail textures where it's more appropriate: near the camera. Maybe it could be a hardcoded limit in that hardware fixed-function. Today we have more flexibility with blended multi layered textures.
User avatar
HarryTuttle
 
Posts: 558
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] MicroTexture

Postby HarryTuttle » Tue Mar 14, 2017 5:57 am

Watching other videos the seam is a bit more "softened". In the fragment shader I let the GPU to do the transition, based on the fact that's the video card that chooses what pixel is in LOD=0 or LOD=1 or in-between.

The formula used (well, borrowed) is the equivalent of an equation standardized in OpenGL specification book (I'll post some references later), however if we substitute "log2" with "log", while mathematically incorrect, will bring a softer transition.

Anyway I'll post some version of that formula, with the indication of a preferred choice that seems to be more arcade-accurate. Then you decide.

Update 1:
Here's the spec https://www.khronos.org/registry/OpenGL/specs/gl/glspec44.core.pdf, chapter 8.14.1, equation 8.8.

Update 2 (code snippets):

for OpenGL Shading Language v4.x we can use the built-in function
Code: Select all
#version 400
float mipmapLevel = textureQueryLod(myTexture, textureCoord).x;
float LODLevel = textureQueryLod(myTexture, textureCoord).y;


for OpenGL Shading Language v3.x and below there's also a built-in function (note the capitalization of the function's name)
Code: Select all
#version 330
#extension GL_ARB_texture_query_lod : enable
float mipmapLevel = textureQueryLOD(myTexture, textureCoord).x;
float LODLevel = textureQueryLOD(myTexture, textureCoord).y;


However i prefer this (maybe more consistent between different GPUs):
Code: Select all
float getMipLevel(in const vec2 coord, in const sampler2D tex)
{
  vec2 texSize = textureSize(tex, 0);
  vec2 coordXY = coord * texSize;

  // VERSION 1 - Follows OpenGL standard
  //vec2 dx_vtc = dFdx(coordXY);
  //vec2 dy_vtc = dFdy(coordXY);
  //float delta_max_sqr = max(dot(dx_vtc, dx_vtc), dot(dy_vtc, dy_vtc));

  // VERSION 2 - Seems more uniform at some angles
  float delta_max_sqr = dot(fwidth(coordXY), fwidth(coordXY));

  delta_max_sqr = max(1.0, delta_max_sqr); // Safety check for paranoids

  //float mml = 0.5 * log2(delta_max_sqr); // == log2(sqrt(delta_max_sqr)); // Harder transition
  float mml = 0.5 * log(delta_max_sqr); // Softer transition

  mml = max(0.0, mml); // Avoids negative MIPs

  return mml;
}


Then in the following pseudo-code:
Code: Select all
// Fetch mipmapped microTexture
//micro = texture2D(tex2, coord.st * microScale * textureRatio);
// Fetch only LOD=0, disabling mipmapping in microTextures, seems to be more consistent to arcade version
micro = textureLod(tex2, coord.st * microScale * textureRatio, 0);

float lod, lodBias, blendFactor;
lodBias = -1.3;
lod = getMipLevel(coord.st, tex1) + lodBias; // Offsets LOD, "tex1" is the base texture
lod = max(0.0, lod);
lod = min(5.0, lod);
blendFactor = min(one, 0.5 + lod * 0.5);
fragment.rgb = mix(micro.rgb, base.rgb, blendFactor);
Last edited by HarryTuttle on Tue Mar 14, 2017 10:29 am, edited 2 times in total.
User avatar
HarryTuttle
 
Posts: 558
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] MicroTexture

Postby Jiterdomer » Tue Mar 14, 2017 7:47 am

Aside from Beginner track from BOTE, take a look on the other three courses:

Beginner (Power Edition):
https://www.youtube.com/watch?v=-wUPtqVA2k0
https://www.youtube.com/watch?v=aJwakqTT1_g

Advanced (Starts at 4:26):
https://www.youtube.com/watch?v=hJkaVbY8fUs (notice the START sign color was in Yellow text in Black background unlike Supermodel's)
https://www.youtube.com/watch?v=2n_3of21AfQ

Expert:
https://www.youtube.com/watch?v=jbNN55PZbz4

You guys should try Marubaku's video because the gameplay were captured from a video card that connects from the actual arcade monitor.
Feel the heartbeat of my machine through this tight seat. I feel every motion of my machine
Image
User avatar
Jiterdomer
 
Posts: 472
Joined: Mon Sep 26, 2011 6:37 pm
Location: Los Angeles, CA

Re: [Patch] MicroTexture

Postby HarryTuttle » Tue Mar 14, 2017 8:18 am

@Jiterdomer

I prefer Abe's direct captures, those uploaded on Mega, not on Youtube. They're far more detailed and also run @ 60fps.

As for the sign color I think that's one of the issue relating to animated textures, some other example: in ECA the ambulance rotating lights animation phase is shifted by half-cycle (when are lit on arcade, they are switched off in Supermodel), the fireplace in the cave stage in VF3 seems to be reverse animated, etc.
User avatar
HarryTuttle
 
Posts: 558
Joined: Thu Mar 09, 2017 8:57 am

Previous

Return to The Dark Room

Who is online

Users browsing this forum: No registered users and 1 guest