Author Topic: Making a 'corrected texture' for a triangle.  (Read 479 times)

20EnderDude20

  • Full Member
  • ***
  • Posts: 115
  • Karma: +6/-0
  • I'm also known as "The Blender Fiddler" on Youtube
    • View Profile
    • Youtube Channel
Making a 'corrected texture' for a triangle.
« on: August 03, 2018, 03:24:30 am »
I've been looking at Sonic Z-Treme, and I've seen many triangular faces that are displaying the entire texture. Ever since, I've been thinking about making a texture become 'corrected', so to speak. I started out with messing around with the distort tool in Flash 8. But later, I thought that I could do this using UV mapping in Blender. however, I've hit a snag. I think UV distortion uses affine transformation, and if I use coordinates that aren't mathematically similar to the face, it won't give the intended result. Is there a solution to this?
« Last Edit: August 03, 2018, 07:52:09 pm by 20EnderDude20 »

ponut64

  • Full Member
  • ***
  • Posts: 176
  • Karma: +13/-0
    • View Profile
Re: Making a 'corrected texture' on a triangle.
« Reply #1 on: August 03, 2018, 05:57:18 am »
This is the concept:
Take your square texture.
Take the bottom right vertice and move it to the same position as the bottom left vertice. Do not merge them.
Done.

You can do this in Adobe Photoshop.

So this texture...


What does this look like, undistorted?
It's this:


How do we pre-distort that .. when we want this:


... I don't know.

XL2

  • Sr. Member
  • ****
  • Posts: 343
  • Karma: +75/-1
    • View Profile
Re: Making a 'corrected texture' on a triangle.
« Reply #2 on: August 03, 2018, 01:36:15 pm »
Ponut is right about that solution, but use caution as even if it has invisible pixels, the Saturn still needs to "render" them, so it can make things way slower quickly. The way around that is to use end codes, which none of my tools support. The other solution is to pre-distort the texture, but again I don't know much about it.

20EnderDude20

  • Full Member
  • ***
  • Posts: 115
  • Karma: +6/-0
  • I'm also known as "The Blender Fiddler" on Youtube
    • View Profile
    • Youtube Channel
Re: Making a 'corrected texture' on a triangle.
« Reply #3 on: August 03, 2018, 04:30:36 pm »
So, the thing that I noticed with 'correcting' a texture for an isosceles right triangle is that you form an isosceles triangle from the pixels that are outside the canvas. as an example, the vertex lines up with the top vertex of the triangle. Here are two triangles. The blue one being the face you're putting it on, and the dashed one being the amount of distortion on the texture.

you can see it's just a mirrored version of the face. This process worked when I tried it on the Saturn, and it's very easy with right triangles, but I never did it on a triangle without a right angle, so that's new territory for me.  ;D I hope this helps.

corvusd

  • Jr. Member
  • **
  • Posts: 83
  • Karma: +8/-0
    • View Profile
    • Personal Web Portfolio
Re: Making a 'corrected texture' on a triangle.
« Reply #4 on: August 03, 2018, 05:36:56 pm »
Ponut is right about that solution, but use caution as even if it has invisible pixels, the Saturn still needs to "render" them, so it can make things way slower quickly. The way around that is to use end codes, which none of my tools support. The other solution is to pre-distort the texture, but again I don't know much about it.

This days assault me this dubt:
Is need it config register=0 Trasparent pixel disable, to avoid draw pixels in a texture/pattern used only to make a mask?
Or can be used End code draw in texture/pattern pixel data to avoid draw this pixels?
Or need both of then "activated"
For CC VDP1 is need both activated. But if you only need a mask texture... what option is the best to gain maxium time or use less cycles?
Wherever, I undestand that is necesary generate the data(pixel data or command table data) for this features to avoid waste cycles in draw VDP1.
« Last Edit: August 03, 2018, 07:09:02 pm by corvusd »
David Gámiz Jiménez

20EnderDude20

  • Full Member
  • ***
  • Posts: 115
  • Karma: +6/-0
  • I'm also known as "The Blender Fiddler" on Youtube
    • View Profile
    • Youtube Channel
Re: Making a 'corrected texture' on a triangle.
« Reply #5 on: August 03, 2018, 06:26:40 pm »
Here is a comparison:
The one on the left uses the unmodified texture, or this one:

The one on the right is 'corrected', or this one:.
« Last Edit: August 03, 2018, 06:30:12 pm by 20EnderDude20 »

XL2

  • Sr. Member
  • ****
  • Posts: 343
  • Karma: +75/-1
    • View Profile
Re: Making a 'corrected texture' on a triangle.
« Reply #6 on: August 03, 2018, 07:00:06 pm »
Ponut is right about that solution, but use caution as even if it has invisible pixels, the Saturn still needs to "render" them, so it can make things way slower quickly. The way around that is to use end codes, which none of my tools support. The other solution is to pre-distort the texture, but again I don't know much about it.

This assault me this dubt:
Is need it config register=0 Trasparent pixel disable, to avoid draw pixels in a texture/pattern used only to make a mask?
Or can be used End code draw in texture/pattern pixel data to avoid draw this pixels?
Or need both of then "activated"
For CC VDP1 is need both activated. But if you only need a mask texture... what option is the best to gain maxium time or use less cycles?
Wherever, I undestand that is necesary generate the data(pixel data or command table data) for this features to avoid waste cycles in draw VDP1.

The End code tells the VDP1 to stop processing that line, while transparent pixel just writes nothing to the framebuffer.
So if you have lots of transparent pixels, the processing speed is the same as an image full of colored pixels.

But the End code just tells the VDP1 to stop processing the line, so it's faster to render.
You need 2 end codes to stop processing a line, so the way to do it is to put one in front of your first colored pixel on each line and one right after your last colored pixel.

With clut sprites, you need to waste 2 colors for the transparent pixel and the end code.

corvusd

  • Jr. Member
  • **
  • Posts: 83
  • Karma: +8/-0
    • View Profile
    • Personal Web Portfolio
Re: Making a 'corrected texture' on a triangle.
« Reply #7 on: August 03, 2018, 07:14:26 pm »
Ponut is right about that solution, but use caution as even if it has invisible pixels, the Saturn still needs to "render" them, so it can make things way slower quickly. The way around that is to use end codes, which none of my tools support. The other solution is to pre-distort the texture, but again I don't know much about it.

This assault me this dubt:
Is need it config register=0 Trasparent pixel disable, to avoid draw pixels in a texture/pattern used only to make a mask?
Or can be used End code draw in texture/pattern pixel data to avoid draw this pixels?
Or need both of then "activated"
For CC VDP1 is need both activated. But if you only need a mask texture... what option is the best to gain maxium time or use less cycles?
Wherever, I undestand that is necesary generate the data(pixel data or command table data) for this features to avoid waste cycles in draw VDP1.

The End code tells the VDP1 to stop processing that line, while transparent pixel just writes nothing to the framebuffer.
So if you have lots of transparent pixels, the processing speed is the same as an image full of colored pixels.

But the End code just tells the VDP1 to stop processing the line, so it's faster to render.
You need 2 end codes to stop processing a line, so the way to do it is to put one in front of your first colored pixel on each line and one right after your last colored pixel.

With clut sprites, you need to waste 2 colors for the transparent pixel and the end code.

Then, not it is possible gain speed or not "process" the transparent pixel, some way? I understand, that it save cycles in the fill pixels in the framebuffer? It not write nothing not would have cost... but in the same way to process texels data no?
David Gámiz Jiménez

ponut64

  • Full Member
  • ***
  • Posts: 176
  • Karma: +13/-0
    • View Profile
Re: Making a 'corrected texture' on a triangle.
« Reply #8 on: August 03, 2018, 07:50:26 pm »
As far as I gather, the transparent pixels consume cycles because they are present in the instruction for as long as any pixel would be until the next instruction.
The key to the end codes is to truncate the length of the instruction, not so much to reduce the computational intensity of that instruction.
It being based on filling the frame-buffer, it is timed with Vblank, so the computational intensity of what can be done by Vblank is something that you can more or less assume will never change, as it's always the same amount of time. Thus reducing the time spent on regions of the instruction is how you save performance in this case.
[I realize this is a very obvious series of statements, perhaps I shouldn't conjecture about things I don't understand]

Also, that's some good work on the pre-distortion, enderdude.
[If it wasn't clear, you grab the top-right vertice and drag it one box-size up]
« Last Edit: August 03, 2018, 08:09:05 pm by ponut64 »

20EnderDude20

  • Full Member
  • ***
  • Posts: 115
  • Karma: +6/-0
  • I'm also known as "The Blender Fiddler" on Youtube
    • View Profile
    • Youtube Channel
Re: Making a 'corrected texture' for a triangle.
« Reply #9 on: August 03, 2018, 07:57:04 pm »
Maybe you can use a black-and-white bitmap to tell your converter where the end codes are. I think we are making something that can possibly give a primitive version of uv mapping on the saturn. ;D
« Last Edit: August 03, 2018, 08:16:28 pm by 20EnderDude20 »

Jorhlok

  • Newbie
  • *
  • Posts: 13
  • Karma: +3/-0
    • View Profile
Re: Making a 'corrected texture' for a triangle.
« Reply #10 on: August 03, 2018, 11:14:39 pm »
I saw this and had an idea to try so I did a screen cap of manipulating an image in gimp and the result it drew. It got reasonable results so I cut the videos together and slapped it on youtube.
https://youtu.be/yTGtuu98AYw

For this I took each vertical column of pixels and stretched them vertically to fill the space.

EDIT: I was worried about texture warping horizontally so I added some lines to the corrected texture to see how it would be effected. I was expecting the grey lines to bend either left or right but to my surprise it didn't
« Last Edit: August 04, 2018, 04:49:40 am by Jorhlok »

20EnderDude20

  • Full Member
  • ***
  • Posts: 115
  • Karma: +6/-0
  • I'm also known as "The Blender Fiddler" on Youtube
    • View Profile
    • Youtube Channel
Re: Making a 'corrected texture' for a triangle.
« Reply #11 on: August 06, 2018, 04:33:37 am »
So, my original question was to find a way to correctly distort the texture on Blender to get the corrected texture, because Blender uses affine distortion for uv mapping. It looks like this: https://youtu.be/8TleepxIORU?t=33s .

20EnderDude20

  • Full Member
  • ***
  • Posts: 115
  • Karma: +6/-0
  • I'm also known as "The Blender Fiddler" on Youtube
    • View Profile
    • Youtube Channel
Re: Making a 'corrected texture' for a triangle.
« Reply #12 on: August 07, 2018, 12:04:40 am »
Okay, so after some thinking of a system to make start and stop addresses, I've made this diagram that gives a loose idea of a concept of primitive uv mapping. I honestly don't know if this is possible, but it's an idea. This is if you can change the start and stop addresses using interrupts, (preferably, v-interrupts): . The upside would be that the hardware won't have to draw transparent pixels.
« Last Edit: August 07, 2018, 04:05:38 am by 20EnderDude20 »

20EnderDude20

  • Full Member
  • ***
  • Posts: 115
  • Karma: +6/-0
  • I'm also known as "The Blender Fiddler" on Youtube
    • View Profile
    • Youtube Channel
Re: Making a 'corrected texture' for a triangle.
« Reply #13 on: August 07, 2018, 04:11:45 am »
So, does this technique make uv mapping available on the Saturn?

corvusd

  • Jr. Member
  • **
  • Posts: 83
  • Karma: +8/-0
    • View Profile
    • Personal Web Portfolio
Re: Making a 'corrected texture' for a triangle.
« Reply #14 on: August 07, 2018, 07:15:38 pm »
No. I explain in my post:
http://www.davidgamizjimenez.com/inpostivegames/sega-saturn-to-the-limit-i/ ->  1.1 Triangle vs Quadrangle – EXTRA Ball: UV Mapping

Well, I try to explain. XD
David Gámiz Jiménez

 

Sitemap 1 2 3 4 5 6 7 8 9 10 
SMF spam blocked by CleanTalk