Jump to content
  • Advertisement
Azzinoth

OpenGL Export textures from unreal engine 4 to own openGL app

This topic is 441 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

I want to export some models from ue4. mesh are ok(export to obj file) but textures in some cases are like :

textureExample.thumb.jpg.6680b38c517609214499279d16a7ffc0.jpg

so in my app it looks like :

myApp.png.2d85ffa3123eab6e2568ec69a4423c07.png

I understand that for some purpose this texture is done in this way but I can understand why and how should I render it(or I need to delete all "not correct" parts in photoshop ?). Can someone explain how I can manage this issue ?

Share this post


Link to post
Share on other sites
Advertisement

I want to start by saying I've never used UE4, but this seems to be a texture atlas.

 

Basically, instead of having 6 separate textures, they are all packed in a single one (the so called texture atlas). The advantage being that you can draw all those different textures, only having to bind it once (intead of having to bound each separate texture).

 

The separated textures would look something like this (I put them in spoiler tags, so as not to flood the post):

Spoiler

SteZhZI.jpg

Spoiler

XIawMT3.jpg

Spoiler

ra1D6BK.jpg

Spoiler

62Xk7px.jpg

Spoiler

3EHPFWF.jpg

Spoiler

HGubMID.jpg

 

Perhaps the most confusing part about that texture, is that the separate textures seem to bleed onto each other, but when they're rendered (by setting the appropriate texture coordinates), the extra pixels won't be visible.

 

When rendering, the actual texture area used would be something like this (delimited by the red lines):

Spoiler

7BAGpIF.jpg

 

Just as a quick note, this kind of atlas is a packed atlas (were each texture is packed as tightly as possible, or thereabouts). Another common texture atlas type, is to put each texture on a grid, with each of them having the same dimensions (a typical example would be a tileset, very common in 2D games).

There's plenty of topics on texture atlases on the web, so you can read about them a bit more, if you're interested.

 

Anyway, hope it helps.

Edited by 3333360

Share this post


Link to post
Share on other sites

Hello, thanks for your post!

I understand that it is textured atlas, when I exported mesh to .obj from ue4 I have correct vt( vertex texture coordinates). By the correct vt I mean that each part of mesh is covered by right part of texture atlas. But the problem is related with surrounding color of each part of atlas(green color around leafs, blue-purple color around flower) so in my app mesh is textured corresponding to atlas but this surrounding color make a mess. If I just delete this color in Photoshop and replace it with color that have alpha = 0 than it looks perfect. But I was wondering why developers put such colors if they don't give some additional info or they give some info for ue4 shaders and this is some additional map(like normal/metalness/AO maps).

Share this post


Link to post
Share on other sites

One thing you can do is trying to see in their sources. They might do a post-process in order to change these colors as transparent colors (avoid to store alpha component can save space in the texture files). Or they might treat these colors as transparent colors, and thus do any blending or other treatment in the shaders during rendering time.

Share this post


Link to post
Share on other sites
17 minutes ago, Azzinoth said:

Photoshop and replace it with color that have alpha = 0

Instead when exporting the texture you need to export the alpha channel with it. To do this remove the texture filter on the textures you want to export.

19 minutes ago, Azzinoth said:

But the problem is related with surrounding color of each part of atlas

The blurry part is done by the artist.

They will first make the plant texture and then blur it, hiding the blur with the alpha mask.

The reason for this is Mip maps. Mip maps is generated by scaling down your texture by merging 4 pixels into 1 pixel. So if one was transparent and the others wasn't they will still get some transparent value.

Because plants use alpha clip, even partly transparent pixels don't get rendered. So this means that when you move away from the plant it starts to grow very small very fast.

 

The Blur prevents this because with the correct filter the alpha is turn to a mask and the image with the blur is left over, it's mip maps are done on it's own because with no alpha it doesn't get partly transparent pixels.

Then the alpha mask is mip mapped and because the shader now knows it's a clip mask because of the filter it turns all partial pixels to solid pixels.

 

If the plant didn't have that blur one of two things would happen. Either it shrinks and disappears fast like before or it renders the black pixel now revealed by the alpha mip map.

 

 

So if you don't have that blur you get a black edge around the plants or the plant just shrinks away.

Share this post


Link to post
Share on other sites

So using Unreal I was only able to get the black boarder.

EdgeExample.thumb.png.b4c0fcd367a935540e919fda8efcd8c9.png

When Unreal notices there is no color set by the artist, it fills the back with a color similar to the picture.

Just note that where the black pixels are now would have clipped off with a engine that didn't use the alpha as a mask. Then the flower would grow smaller exponentially as you moved away from it.

The black boarder messes with the BPR shading and can make plants look fake. Considering that all you would have to do to prevent it is do one blur, there is no excuse for having these problems.

Edit:

With a worst filter or scaling mode the black boarder increases, this was done with the normal from texture group setting-> World.

 

You also won't have them if your engine fixes it like Unreal and Unity.

Edited by Scouting Ninja

Share this post


Link to post
Share on other sites
Quote

Hello, thanks for your post!

I understand that it is textured atlas, when I exported mesh to .obj from ue4 I have correct vt( vertex texture coordinates). By the correct vt I mean that each part of mesh is covered by right part of texture atlas. But the problem is related with surrounding color of each part of atlas(green color around leafs, blue-purple color around flower) so in my app mesh is textured corresponding to atlas but this surrounding color make a mess. If I just delete this color in Photoshop and replace it with color that have alpha = 0 than it looks perfect. But I was wondering why developers put such colors if they don't give some additional info or they give some info for ue4 shaders and this is some additional map(like normal/metalness/AO maps).

Ah okay, I apologize. I thought you were doubtful about the packing of the individual textures rather than the colors that bleed onto the other textures.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!