Jump to content
  • Advertisement
Sign in to follow this  
giugio

OpenGL sketchup and opengl es visualization

This topic is 2745 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'm trying to speed up the rendering of a sketchup model with opengl es .
In sketchup i have a lot of faces(that are a mesh with very low number of vertex) and a low sized texture for each face/mesh.
My idea is to create a big texture(and offsets) at the importation section that contains all the textures of the faces/meshes and then group all the geometry in a single mesh.
Then create a list of index for each face/mesh and in my shader i send an indexed array of texture offset for each face.

like
vertex shader:
offsetfacevertex[0]=0 [1(start first mesh)]
offsetfacevertex[1]=3 [2(start second mesh)]
offsetfacevertex[2]=6 [3(start third mesh)]

textureoffsetx[0]=0
textureoffsetx[1]=1000
textureoffsetx[2]=2000

then(shader pseudocode):

if(current vertex> offsetfacevertex[currentindex])
currenttextureoffsetx = textureoffsetx[currentindex]
Out.offsets.x = currentoffsetx;

pixel shader:

sample2d(U+offsetx,V+offsety ecc...);//offset y is not implemented

I would use this for increment rendering performance in webgl .
I can do all in the trasformation and creation of textures in the importation time without performance requirement, then visualizing the cooked mesh in webgl.

Is a good idea?
How i can concatenate the textures with opengl 2 (in the importation step)?
thanks.

Share this post


Link to post
Share on other sites
Advertisement
From what you described I see no need to make use of knowing the vertex indices. IMHO it should be sufficient to bake all textures into a texture atlas and to bake all those meshes into a single VBO.

Because all textures go into a single texture atlas, you need not address a particular texture in dependence on the vertex. The adapted texture (u,v) address is sufficient. For baking the texture atlas you can use one of the known packing algorithms. (You're mentioned OpenGL-ES and WebGL, so texture arrays are no option, right? And be aware that indexing samplers is not possible, AFAIK.)

When baking all small meshes into a single VBO, you can apply their respective model transformation at that time (i.e. on the CPU). This is best for static meshes but need to be done every frame when the meshes are dynamic. In the latter case you can split the VBO into two, one for the static part (e.g. u,v co-oridnates) with usage GL_STATIC_DRAW, and one for the dynamic part (e.g. vertex positions and normals) with usage GL_STREAM_DRAW or perhaps GL_DYNAMIC_DRAW, to yield in a somewhat less transfer volume. Another, perhaps better, way would be to extend the vertex attributes by a matrix index and supply all the model transformations as uniforms into the shader (in case that you use shaders, of course).

Possible limiting aspects are hence the maximum size of the texture atlas, the bandwidth, and the amount of matrices you can supply the shaders with.

Share this post


Link to post
Share on other sites

From what you described I see no need to make use of knowing the vertex indices. IMHO it should be sufficient to bake all textures into a texture atlas and to bake all those meshes into a single VBO.

Because all textures go into a single texture atlas, you need not address a particular texture in dependence on the vertex. The adapted texture (u,v) address is sufficient. For baking the texture atlas you can use one of the known packing algorithms. (You're mentioned OpenGL-ES and WebGL, so texture arrays are no option, right? And be aware that indexing samplers is not possible, AFAIK.)

When baking all small meshes into a single VBO, you can apply their respective model transformation at that time (i.e. on the CPU). This is best for static meshes but need to be done every frame when the meshes are dynamic. In the latter case you can split the VBO into two, one for the static part (e.g. u,v co-oridnates) with usage GL_STATIC_DRAW, and one for the dynamic part (e.g. vertex positions and normals) with usage GL_STREAM_DRAW or perhaps GL_DYNAMIC_DRAW, to yield in a somewhat less transfer volume. Another, perhaps better, way would be to extend the vertex attributes by a matrix index and supply all the model transformations as uniforms into the shader (in case that you use shaders, of course).

Possible limiting aspects are hence the maximum size of the texture atlas, the bandwidth, and the amount of matrices you can supply the shaders with.


thanks headgarr.
Now i have 2 problem:
1)the meshes that I'm show are alwais static , i show civil buildings, but i'm not understand the transformation problem(sorry for my english), i can't trasform all multiplying point by point for the word matrix(in importation phase)? then send(or save in a my format) the precalculated points for the shader.
2)my problem now is how i can create a texture atlas.There are algorithms for do it in automatic from c++ ?
Thanks.

Share this post


Link to post
Share on other sites
When you import a mesh for a single object, e.g. a house, then the mesh's vertices will typically be given w.r.t. a local co-ordinate system. You place the object into the world by defining a location, orientation, and perhaps scaling in the world. This is usually be expressed by a model transformation matrix. When you apply this matrix to each vertex of the imported model, then you compute the vertex w.r.t. the world co-ordinate system. Store these computed vertices into the VBO. (You can of course use any other co-ordinate system. The only important aspect is that all sub-meshes in the VBO share a common reference co-ordinate system as long as you don't use the mentioned trick of supplying an array of transformations.)

Making a texture atlas means to create a new empty and large texture, and to copy the smaller textures into it. Obviously you'll try to waste as less texels as possible, meaning you'll try to pack the small textures as dense as possible into the atlas. There are some algorithms out there that do something like this. Search the internet for "texture packing algorithm" and you'll find them, e.g. this thesis. Another way would be to use some already existing software. E.g. from nVidia.

Share this post


Link to post
Share on other sites

When you import a mesh for a single object, e.g. a house, then the mesh's vertices will typically be given w.r.t. a local co-ordinate system. You place the object into the world by defining a location, orientation, and perhaps scaling in the world. This is usually be expressed by a model transformation matrix. When you apply this matrix to each vertex of the imported model, then you compute the vertex w.r.t. the world co-ordinate system. Store these computed vertices into the VBO. (You can of course use any other co-ordinate system. The only important aspect is that all sub-meshes in the VBO share a common reference co-ordinate system as long as you don't use the mentioned trick of supplying an array of transformations.)

Making a texture atlas means to create a new empty and large texture, and to copy the smaller textures into it. Obviously you'll try to waste as less texels as possible, meaning you'll try to pack the small textures as dense as possible into the atlas. There are some algorithms out there that do something like this. Search the internet for "texture packing algorithm" and you'll find them, e.g. this thesis. Another way would be to use some already existing software. E.g. from nVidia.


thanks , but i'm not understand how modify the UV with after the creation of the texture atlas with nvidia tool.
where i get the information for offsetting the UV?
thanks.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!