3D Texture producing stripes

Try changing the last element of each from -1.0f to 0.5f or -0.5f.

For an accurate 1:1 mapping, the scale factor and offset should be calculated from the bounding box.

The scale factor should be the reciprocal of the size of the object in that dimension. The offset should be the negative of the minimum value multiplied by the scale factor. Based upon the values in the OBJ file from 3ds Max, I calculate:

x scale = 1/(20.3459 - -14.5704) = 1/34.9163 = 0.02864
y scale = 1/(23.6314 - -17.9663) = 1/41.5977 = 0.02404
z scale = 1/(20.3455 - -17.8120) = 1/38.1575 = 0.02621

x offset = 14.5704 * 0.02864 = 0.4173
y offset = 17.9663 * 0.02404 = 0.4319
z offset = 17.8120 * 0.02621 = 0.4669

I.e.:


	GLfloat sPlane[4] = { 0.02864f, 0.0f, 0.0f, 0.4173f };
	GLfloat tPlane[4] = { 0.0f, 0.02404f, 0.0f, 0.4319f };
	GLfloat rPlane[4] = { 0.0f, 0.0f, 0.02621f, 0.4669f };

Thank you!
That’s definitely very good and almost what I’d like to create:
[ATTACH=CONFIG]991[/ATTACH]
Still I’d like to have the center of the rings in the center of the face.

Fatman_Stoned

Your texture only contains one quadrant; the centre of the rings is at the corner of the texture.

That isn’t exactly wrong (if you buy a length of wood from a hardware store, the chances are that it won’t have been cut from the very centre of the trunk), but if it isn’t what you want you need to change the code which generates the texture:

From your earlier post:

If you want the centre of the rings to be in the centre of the texture, you need to replace i with (i-WIDTH/2) and j with (j-HEIGHT/2).

Alternatively, you could use glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT) (likewise for GL_TEXTURE_WRAP_T) and change the plane coefficients back so that the corner of the texture is in the middle of the face.

This has the advantage of doubling the effective size of the texture in each dimension without increasing storage, but the result will be perfectly symmetrical, which isn’t necessarily what you would want. You’ll probably also need to tweak the generation code slightly to avoid obvious seams.

Awsome! That’s what I wanted, thank you!
What would I have to do to get no perfect circles but randomly shaped circle-like circles?

Fatman_Stoned

There’s all kinds of things you could do, far too many to list really.

The simplest is to apply some slightly non-linear transformation to either the input (i,j) or the output (r,alpha). Ultimately, it just comes down to what looks credible.

Mark it for review later.

x^2/i^2+y^2/j^2=1
the parameter of i,j can change the shape of a circyle. and take random loop control can do the trick.
you may mean this?

Thank you!
This thread can be closed.