Login Action Required

The NinevehGL Forum uses a new concept of "socialized forum" or as we like to say "Tweet Forum".


Here is the deal:
  1. No new registration is required. Just sign in with your Twitter account and authorize the NinevehGL Forum.
  2. Once you’re in, you'll be able to "Follow a Thread", that means every time that thread receive a new post or update you'll receive a mention on your twitter.
  3. Besides, you can enable "Auto Share", then every new post and/or thread you make will be tweeted on your timeline. (By default, auto-share is enabled only for your threads)

Forum Rules:

1. We understand human comunication can become "hot" sometimes. So some insults and bad words ARE allowed. Just don't push too much being an asshole all the time.

2. SPAMMERS are not allowed. There are penalties for this kind of user and they can be banned forever.

3. You can report other users, if you judge necessary. An user reported many times by many people can also be banned forever. However you can also receive penalties for report deliberately for no apparent reason.

If there is a similar thread title, make sure the other one doesn't already have the answer you're looking for.

This forum uses the BBCode (Bulletin Board Code), here are some instructions:

Bold: [b]text[/b]
Italic: [i]text[/i]
Underline: [u]text[/u]

Code: [code]text[/code]
Quote:
[quote=@username]text[/quote]
[quote]text[/quote]

List:
[ul] [*]item [/ul]
[ol] [*]item [/ol]

URL:
[url]http://url.com[/url]
[url=http://url.com]text[/url]

Image:
[img]http://imageurl.com[/img]

Embed (videos, code, 3D):
[embed]http://url.com[/embed]

Welcome to the NinevehGL's world!
NinevehGL is a 3D engine forged with pure Obj-C.
Welcome to the
Forum!
Hello, Guest.

Your current vote:

You can change your vote many times. But it's still one single vote.

Set HI-RES Textures
Vote this thread:


@quotoman

Posts: 8

NGLNewbie

Fri, Mar 29 2013


Hi all,
I'm having problems setting hi-resolution textures onto meshes. I set the texture from file in this way:

NGLMaterial *textureMaterial = [NGLMaterial material];
textureMaterial.diffuseMap = [NGLTexture texture2DWithFile:textureFilename];

_mattelModel.material = textureMaterial;
[_mattelModel compileCoreMesh];


The problem is that on retina display, the engine doesn't seem to load the texture at its full resolution. All of my textures are 2048*2048. As specified in the documentation the engine the maximum res for non retina is 1024*1024 and for retina screens is 2048*2048. I do not know how to target the right image to be loaded. Maybe I'm doing the scaling wrong or something else related to retina scaling. Now I'm only setting contentScaleFactor on the NGLView and resizing the backgroundVideo (it's an AR app with Vuforia) according to the contentScaleFactor.

Also trying with
initWithImage
I have the same result.

Thanks in advance guys!
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Sat, Mar 30 2013


In response to: @quotoman

Hello,

The maximum size for textures is 2048. However you should never use such size, instead use a couple of small textures (with 512 max) forming a big image.

To set the render for retina display you have to change the NGLView "contentScaleFactor" to 2.0, however this is not good as well because will directly affect the performance. As adviced by Apple, you should keep this number under 2.0, usually 1.5 is good enough and saves a lot of processing.
0% like this - 0/0

@quotoman

Posts: 8

NGLNewbie

Sat, Mar 30 2013


In response to: @dineybomfim

You are saying that I should use 4 uv map with different textures and apply that to different materials on the obj? I cannot do that because I can't edit the meshes source. I have about 80 meshes "linked" to 80 marker (Vuforia). I need to force NinevehGL to present the hi res resolution. Regarding the contentScaleFactor, I already tried values between 1.0 and 2.0 as the Apple docs states but the textures appears pixelated anyway

Is there maybe a workaround to apply the textures with OpenGL directly? Because trying to do that with the same mesh data and texture in an OpenGL-only app seems to present the textures in the right way.

0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Sat, Mar 30 2013


In response to: @quotoman

OK, lot of questions involved here:


  1. Yes, you can do it with custom shaders, in this case you'll need to manage the image sources as well.

  2. You don't need to put your hands on mesh to change its materials. This is what NGLSurface is for. For example: If you want to slice a texture into 4 others all that you need is to create 4 NGLSurface, specify a start and a length (you can do it dynamically based on the length of the original surface(s)) and apply 4 materials to it, each one with a different part of the texture. This process doesn't even involve the UV Mapping, it still exactly the same. Just make sure that each of your slices is cutting a triangle (3 vertices).

  3. But based on what you said, the next one will be the best to solve your problem.

  4. If you already changed the "contentScaleFactor", I'm almost sure that what you're complaining is about the texture compression. Each Texture has its own compression and quality, however you can change it globally. The global property just affect new textures, so you must change it before initiating any mesh if you want it applied to all meshes:

  5. nglGlobalTextureQuality(NGLTextureQualityTrilinear);
    nglGlobalTextureOptimize(NGLTextureOptimizeNone);
    nglGlobalFlush();



These 2 lines will set the texture to its maximum quality and with no compression. This is the best quality that OpenGL can render for a texture of 2048. If yet you still thinking that it's not good enough for you, try the first 2 approaches.
0% like this - 0/0

@quotoman

Posts: 8

NGLNewbie

Wed, Apr 3 2013


In response to: @dineybomfim

Thanks for the various options!

Setting the global property was one of the first things I tried, but the result was not as good as we wanted.

Now I'm trying to apply the 4 surfaces, but maybe I'm missing something: I read the documentation and every NGLSurface applied to the mesh has to have identifier equal as the NGLMaterial.

So I would have done something like that:
N is replaced with the increasing number, from 0 to 3.



// Starting here I don't know how to get the original surface length

unsigned int length = [(NGLSurface*)_model.surface lengthData];

NGLTexture = [NGLTexture texture2DWithFile:textureFilename];

NGLSurface *textureN = [NGLSurface surfacetWithStart:length * N length:length identifier: N];
NGLMaterial *materialN = [NGLMaterial material];
materialN.identifier = N;
materialN.diffuseMap = texture;

[...]

NGLSurfaceMulti *multiSurface = [[NGLSurfaceMulti alloc] initWithSurfaces:surface0, ..., surfaceN, nil];
NGLMaterialMulti *multiMaterial = [[NGLMaterialMulti alloc] initWithMaterials:material0, ..., materialN, nil];

_model.surface = multiSurface;
_model.material = multiMaterial;


I think I'm missing some basic info on how surface-shader-material-texture works in this case.
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Wed, Apr 3 2013


In response to: @quotoman

Hi,

You're doing almost everything right, except by the fact that the original mesh's surface is not a single NGLSurface, it's a NGLSurfaceMulti. You have to loop through it to get the correct length of the arrays. Even if your mesh has only one valid surface, it'll be a NGLSurfaceMulti with one NGLSurface element.
0% like this - 0/0

@quotoman

Posts: 8

NGLNewbie

Wed, Apr 3 2013


In response to: @dineybomfim

Hi,

I'm trying to retrieve the surfaces when the mesh finish to load but the (NGLSurfaceMulti*)_model.surface count] says that's equal to 0

Damn it!

I call applyTextureWithFile:toMesh: in meshLoadingDidFinish:

Here's the methods code:

0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Wed, Apr 3 2013


In response to: @quotoman

Hello,

Really strange... 0...

What is the output for NSLog(@"Model surface %@", _model.surface);?

Besides, instead of counting each surface you can also take de "indicesCount" directly from NGLMesh, it has the same effect as counting the surfaces.
0% like this - 0/0

@quotoman

Posts: 8

NGLNewbie

Thu, Apr 4 2013


In response to: @dineybomfim

Hi Diney,

I got the texture loading by using the indicesCount and NGLSurfaceMulti after loading the mesh, however the texture has the same low detail!

Here is a wider overview of my code, I pasted here the loading methods, the preparing methods and the applying methods.

Hope I'm not bothering you too much, but I really do not understand how to get this damn hi-res texture .

0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Thu, Apr 4 2013


In response to: @quotoman

Hello man,

Can you post an image of what you consider "low-res"? And what you consider "high-res"?

Seems you already did the maximum settings for the highest res. If this is the case, there is nothing else that OpenGL can do for you. The mobile world will always have limits and we must work inside this boundaries.
0% like this - 0/0

@quotoman

Posts: 8

NGLNewbie

Fri, Apr 5 2013


In response to: @dineybomfim

Hi man,

here are 2 screenshots, as you can see on the pure OpenGL app the texture is a way better resolution:

App with NinevehGL VuforiaAR

LOWER RES

Screenshot (1136x640): http://oi46.tinypic.com/t7eiow.jpg

Texture apply code: already posted before


App with OpenGLES Pipeline VuforiaAR
(derived from ImageTargets Vuforia sample app)

BETTER RES

Screenshot (1136x640): http://oi45.tinypic.com/aql90.jpg

Texture apply code:

Texture is an ARCommon class - QCAR Texture source here: http://pastebin.com/CLKXxWds

0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Fri, Apr 5 2013


In response to: @quotoman

No idea of what is going on.
Can you send us your project via email? We'll investigate the case.
0% like this - 0/0
Technology

NinevehGL is a 3D engine built right on top of OpenGL ES and it uses all the programmable pipeline power, making it easy for you to create great application with shaders.

Share on


Follow NinevehGL
Fastest way to contact us:

Copyright © 2011 db-in. All rights reserved.