Skip to main content

Texture from image (square on triangle) results in grained-like texture

15 replies [Last post]
m3nelvagor
Offline
Joined: 2010-09-22

Hi all,

I am currently trying to create a 3D representation of an area. For this, I allready have the overall shape in the form of multiple triangles.
I also have images per triangle that need to be pasted on the triangles.

But when I apply the images as a Texture, the result is some grainy fill of the triangle. It seems to be using the overall pixel-color, but it won't just cover the triangle with the image.

You can take a look at:

http://www.eurotronics.com/3D_model/Screenshot_3D_Model.png

Any ideas what may be the problem?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Don Casteel

To me it looks like your texture coordinates are off on some of the triangles.
All of the triangles that are not right, have a bunch of stripes, this indicates
to me that you are using the exact same value along either U or V where you
should have some amount of distance.

Hope this helps
 
Don Casteel 

Freelance Portfolio   Deviant Art Home
Deviant Art Gallery
Project Home 

________________________________
From: "java3d-interest@javadesktop.org"
To: interest@java3d.dev.java.net
Sent: Mon, September 27, 2010 10:42:44 AM
Subject: Re: Texture from image (square on triangle) results in grained-like
texture

Hi all,

Sorry for the time between replies, but I needed to put in some time on another
project at work.
In the meantime, I got it working for the most part, but still there are some
issues for which I'm unable to find the solution.

Check the screenshot:

http://www.eurotronics.com/3D_model/Screen_shot_triangles.png

So some of the mappings are as they should be (it's an areal mapping of a
cemetry), but other textures are stretched for some reason.
Anybody got a suggestion about the possible cause?

By the way, I'm using a custom mapping for each vertex of a triangle and this
seems to work in 50% of the cases.

Thanks for any coorperation!
[Message sent by forum member 'm3nelvagor']

http://forums.java.net/jive/thread.jspa?messageID=483782

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@java3d.dev.java.net
For additional commands, e-mail: interest-help@java3d.dev.java.net

[att1.html]

m3nelvagor
Offline
Joined: 2010-09-22

It kind of looks like I have a scaling issue with the textures. Do you think that's possible? Should the size of the image with which I create the texture fit the size of the surface it is projected on?

darwinjob
Offline
Joined: 2004-11-16

>Should the size of the image with which I create the texture fit the size of the surface it is projected on?

No. This is what texture coordinates are for. Using them you describe HOW you want your image to be placed.

Seriously, make the mesh as Quads with dimensions of the real images and map the textures 1 to 1;

Message was edited by: darwinjob

darwinjob
Offline
Joined: 2004-11-16

About texture coordinates:

http://java.sun.com/developer/onlineTraining/java3d/j3d_tutorial_ch7.pdf

Section 7.5

Do you use TexCoordGeneration?

m3nelvagor
Offline
Joined: 2010-09-22

Ok, there is some evolution in the texture rendering :-)

It's not yet how it should look, but it's a start. I'll take another look at the parameters for the FaceCull and check the sizes of the image vs triangle.

Here's a new screenshot by the way:

http://www.eurotronics.com/3D_model/Screenshot_3D_Model_2.png

Looks like modern art ...

darwinjob
Offline
Joined: 2004-11-16

Just a tip...
If your unit texture images are squares, maybe you should use QuadArrays?

http://download.java.net/media/java3d/javadoc/1.5.2/javax/media/j3d/Quad...

then it will be real cubism ;)

aces
Offline
Joined: 2003-07-17

Hi

To fix normals, use NormalGenerator :

[code]
GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
// initialize the geometry info here
// generate normals
NormalGenerator ng = new NormalGenerator();
ng.generateNormals(gi);
// stripify
Stripifier st = new Stripifier();
st.stripify(gi);
// get it as indexed geometry.
GeometryArray geoResult = gi.getIndexedGeometryArray(true);

// fix texture coordinates, as linear
TexCoordGeneration tcg =
TexCoordGeneration(TexCoordGeneration.OBJECT_LINEAR,
TexCoordGeneration.TEXTURE_COORDINATE_2);

Appearance app = new Appearance();
app.setTexCoordGeneration(tcg);
// define others appearance atributes, as material, etc

// create shape 3D
Shape3D shp = new Shape3D(geoResult, app);

[/code]

Good Luck ;)

m3nelvagor
Offline
Joined: 2010-09-22

Hi all,

Sorry for the time between replies, but I needed to put in some time on another project at work.
In the meantime, I got it working for the most part, but still there are some issues for which I'm unable to find the solution.

Check the screenshot:

http://www.eurotronics.com/3D_model/Screen_shot_triangles.png

So some of the mappings are as they should be (it's an areal mapping of a cemetry), but other textures are stretched for some reason.
Anybody got a suggestion about the possible cause?

By the way, I'm using a custom mapping for each vertex of a triangle and this seems to work in 50% of the cases.

Thanks for any coorperation!

m3nelvagor
Offline
Joined: 2010-09-22

Never mind, I got the mapping of the vertecis wrong.
Resolved the issue and now it works just fine.

Nice ... my first 3D model in java :-)

darwinjob
Offline
Joined: 2004-11-16

>Nice ... my first 3D model in java :-)

Congratulations! And it's a.. cemetery ;) :)

m3nelvagor
Offline
Joined: 2010-09-22

Yeah, but it's a 3D model of a cemetry, formed by a (from heightpoints) triangulated mesh and textured by aerial photographs which are automatically selected+croped+repositioned.

And the whole thing is georeferenced, so porting to Google Earth in the future should be possible :-)

darwinjob
Offline
Joined: 2004-11-16

One Texture per one Triangle - is that correct?

Are you sure that your triangles do not overlap?

m3nelvagor
Offline
Joined: 2010-09-22

Hi darwinjob,

Yes, that is correct.
To be able to do this, I created a GeometryArray which contains all the triangles.

And yes, I am sure that the triangles don't overlap.
Here is the model with a line-appearance:

http://www.eurotronics.com/3D_model/Screenshot_3D_Lines.png

darwinjob
Offline
Joined: 2004-11-16

>I created a GeometryArray which contains all the triangles.

so the texture is applied to the GeometryArray (sort of one per all triangles).

My guess is that you have something wrong with texture coordinates and normals.

About normals:
Could you play with face culling and see what you get?

Face culling - defines which polygons are culled (discarded) before they are converted to screen coordinates.

* CULL_NONE - disables face culling.
* CULL_BACK - culls all back-facing polygons. The default.
* CULL_FRONT - culls all front-facing polygons.

http://download.java.net/media/java3d/javadoc/1.5.2/javax/media/j3d/Poly...

m3nelvagor
Offline
Joined: 2010-09-22

Well, I stated that wrong.

I go over all the triangles (in a different format from triangulation) and generate a IndexedTriangleArray whicht contains 1 triangle, for which I then set the TextureCoordinates.

After this is done, I create an appearance for each Geometry and put a texture on the geometry which is a different picture for each one loaded with a TextureLoader.

I tried all culling settings and none of them resulted in a better image.
I also tried to remove the normal generator, but this didn't help either.

I'm sure the solution is going to be one of those small things that escapes my attention ...