|
SCCOTTT, Newbie
Posted: 13 August 2014 09:25 PM Total Posts: 4
When I try wrapping a cube with a basic texture, I always seem to get fuzziness on the edges where colors from other faces are wrapping around. It seems to get worse when its more of a flattened cuboid shape, and when the camera is at certain angles.
I’m using the attached texture, and I’ve also included a screenshot of what I’m talking about.
Is there a way to prevent this and guarantee sharp edges?
|
Fabrice Closier, Administrator
Posted: 14 August 2014 09:30 AM Total Posts: 1265
[ # 1 ]
This “bleeding” is caused by a pixel color defined by a uv coordinates on a map is not the equivalent of an integer. In other words, if your map would be 4 pixels wide, where you would use it on 2 sides only, the first side would be 0-2 and 2-4. In uv values, 0-0.5 - 0.5 -1. Each side would get rendered perfectly. In a situation like yours, assuming you use a 512 map your problem is basically “170.6666”(512/3) on u axis.
For the mapping logic of your cube, the u axis of your map is representing 3 sides, and as we use power of 2 sizes, you will always get coordinates that point to somewhere inside of a pixel on the map at the edges. This pixel color will be shared on at least 2 sides.
“Is there a way to prevent this and guarantee sharp edges?”
You could loop over normals per side and down resize a bit so it fits per side on the map using integers or loop and alter the uv’s u’s. So you end up having a non shared coordinates on the u values representing the edges of a side. Of course, you must ensure that the edges vertices/uvs are not shared before doing this. If you don’t problem will remain.
Doing this cost very little time/effort to be done if you are familiar with the engine. Some do prefer to build the cube from 6 planes geometries or import a custom one remapped in external editors…
|
SCCOTTT, Newbie
Posted: 14 August 2014 05:23 PM Total Posts: 4
[ # 2 ]
Thanks Fabrice for the response.
I’m not actually very familiar with the engine (and I’m new to 3D), so I had some trouble following your suggestions.
How do I alter the u values and/or resize the normals per side? Are you able to point me to any code or examples of what you’re suggesting?
|
Fabrice Closier, Administrator
Posted: 14 August 2014 05:59 PM Total Posts: 1265
[ # 3 ]
getting the normals using “classic” subGeometry mesh.geometry.subGeometry[0].normalVertexData;
using the CompactSubGeometry object, you need to get the data and loop over the buffer using the stride and offsets values for a given data type. The CompactSubGeometry stores all the data (uv, normals, vertices, tangents etc) in one buffer instead of multiple buffers as done in the “classic” subGeometry object.
same for update.
repeat for UVData.
Look in tools or primitive package to see how this works.
|
SCCOTTT, Newbie
Posted: 14 August 2014 07:04 PM Total Posts: 4
[ # 4 ]
Thanks again for the continued responses, Fabrice.
I’m afraid, though, I really don’t follow any of this. I know ActionScript well, but I’m very new to Away3D and 3D in general and most of this is greek to me.
Unless there is a more dumbed-down example or way to explain this, I think I’m just going to go with creating 6 separate planes with separate textures for each.
|
Fabrice Closier, Administrator
Posted: 14 August 2014 08:43 PM Total Posts: 1265
[ # 5 ]
No problem, you can get the same using planesGeometries.
It’s less ‘elegant’ but once assembled, noone will see the diff and I promess I will tell nobody :D
|
SCCOTTT, Newbie
Posted: 15 August 2014 04:56 PM Total Posts: 4
[ # 6 ]
There’s nothing elegant about any of this code, so it’s all good.
And, the 6 separate planes worked great. Thanks for the help.
|