Author Topic: REQUEST : UV offset  (Read 1294 times)

Setsuki

  • Newbie
  • *
  • Posts: 5
    • View Profile
REQUEST : UV offset
« on: March 05, 2017, 12:38:42 PM »
Hello !
I'm starting to use Crocotile recently for a personal game project, and I'm pretty glad I bought it so far.
However, I am encountering a problem, and while I found a workaround, I wonder if Crocotile would be able to provide tools to fix it.

In the attached files, image 1 is the tileset I'm using. Each tile is 32x32. image 2 is the resulting created object.

After exporting the object file and importing it to Unity, I encounter image 3 ; the UV precision isn't the same in crocotile and Unity, and despite tweaking shaders and import options, I keep having the same problem : the ploygons render with a tiny offset, and the alpha surrounding my tile "leaks" in my textured polygon.

I redid the whole tileset by making each tile 34x34 instead of 32x32, clamping each border, and setting an UV Padding of 1,1 in Crocotile. This way, I'm using a 32x32 tile and allow Unity an error of one pixel. As you can see in 4.png, it works.

Now, I have to remap ALL the models I did since my tileset has changed. And being a bit dumb, I did a lot of them before checking if everything worked properly.

So, I was wondering, to avoid future users from doing the same mistake I did, if there could be some ways to prevent this.

For example, allowing decimals in the UV Padding parameter, in order to only crop part of the border pixels ?
Or best of all, when exporting objects/scenes, have an "vertice UV padding" parameter, allowing the user to add this decimal padding at the last moment ?

Or maybe, just maybe, I'm thinking about this all wrong ?

Alex

  • Administrator
  • Sr. Member
  • *****
  • Posts: 305
    • View Profile
Re: REQUEST : UV offset
« Reply #1 on: March 05, 2017, 03:14:22 PM »
When you export, there is an option to set the uv padding, and if you export the textures as well it will redraw the tiles with the padding. Is that what you need?

also, you may want to check with the Unity community/etc to see if there is a fix for that issue you had- perhaps there is a way to solve it in Unity without having to redo your models.
« Last Edit: March 05, 2017, 03:20:35 PM by Alex »

Setsuki

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: REQUEST : UV offset
« Reply #2 on: March 05, 2017, 04:54:53 PM »
Hello, and thank you.
The models are already redone, thanks to Crocotile's alt+click feature  ;D

Now, I can't set an UV padding if I don't export the textures. (The way you mentioned this option seemed to imply that it was possible.)
So I exported the texture as well.

I tried setting UV Padding to 1.

It doesn't look like the texture file exported is any different from the original.

Importing the model in Unity and using the generated tileset texture or the original texture doesn't change much ; The padding's been taken into account all right, but it's the opposite of the solution I'm looking for ; it expands the texture, while I'm trying to constrict it.

The way I did (using a 34x34 square for a 32x32 tile) works fine. We can agree that this is due to Unity's rendering...


Wait. :-[ I got it.

SOLUTION :
In case someone stumbles upon this thread looking for a solution. As you can guess, Crocotile exports the UVs and the model just fine. It is Unity that corrupts it.
Import your texture without compression (you probably already did this) but also, disable anti-aliasing. The glitch will be visible only if your camera is very, very close to the object.

Now I'm off to redo everything all over again. This is what versioning servers are for, kids.

Sorry Alex, this thread ends up not being in the right forum. Thank you for your answer and this software !
« Last Edit: March 05, 2017, 05:11:36 PM by Setsuki »

Alex

  • Administrator
  • Sr. Member
  • *****
  • Posts: 305
    • View Profile
Re: REQUEST : UV offset
« Reply #3 on: March 05, 2017, 06:12:13 PM »
no problem, glad you solved the issue, and thanks for the kind words. :)

MrKarate1983

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: REQUEST : UV offset
« Reply #4 on: March 11, 2017, 05:53:48 AM »
Hello, I'm a new user of Crocotile3D too. I don't use UNITY as engine for my game, actually I'm using an alternative lightweight engine. However the engine that I'm using only admit *.FBX files.

So I was checking a couple of tutorials on YouTube and I found a very simple and nice tutorial that explain how to import an OBJ file created with Crocotile3D into Blender and then exporting that file to *.FBX. The guy that did the video then used the created model into UNITY. It looked pretty good. Without any problem with the UV offset.

https://www.youtube.com/watch?v=ic5Q4XAnOgk

Maybe you could try the same approach. Blender is free after all -and that's the program that I'm using to convert OBJ files to FBX for my projects without any problem with the UV offset. :)

EDIT: Oh, sorry. It was Unreal Engine 4, not UNITY :(
« Last Edit: March 11, 2017, 06:06:01 AM by MrKarate1983 »

Setsuki

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: REQUEST : UV offset
« Reply #5 on: March 11, 2017, 08:07:37 AM »
Thank you MrKarate, but I've been able to manage the problem in multiple ways, as this pixel precision requirement was giving me trouble with :
- Texture compression
- Anti-Aliasing
-Quality settings
-Mipmapping

Mixing multiple solutions of leaving an additional pixel for padding and shaders programmed for this purpose was the best solution, and actually gives me some room for mistake and low quality settings.

Alex

  • Administrator
  • Sr. Member
  • *****
  • Posts: 305
    • View Profile
Re: REQUEST : UV offset
« Reply #6 on: March 30, 2017, 11:22:45 PM »
I would also like to mention another possible fix to this issue.
You can try checking if your texture dimensions are a power of two (2,4,8,16,32,64,128,256,512,1024)..
If they aren't, you can try adding extra space to your texture so that it is a power of two, and then export it and see if you still have the issue.
I tested this and found that Unity will render textures wrong if they aren't power of two, so I thought I would leave this info here.

Setsuki

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: REQUEST : UV offset
« Reply #7 on: March 31, 2017, 06:20:16 AM »
Thanks a lot, I should've mentioned it, my textures are indeed square and powers of two. (256x256 and 512x512 to be exact). But you are right, it is important for better rendering, especially on mobile.