Need help understanding texture mapping

Software: Away3D 4.x

Avatar
Alexander Seifert, Moderator
Posted: 16 August 2011 09:06 AM   Total Posts: 129   [ # 16 ]
Amon - 15 August 2011 03:15 PM

I don’t understand it either. If I use tile6 param set to true, according to docs, I expect to give 2x3 bitmapData wrapped in BitmapMaterial as an input where unit of this measure is power of two. However it yells that given material is not power of two! How can it be power of two when what I need is 2:3 ratio!?

I didn’t take a look at the provided source code, but this seems to need some clarification to understand how textures work.

1. Yes, their sides need to be of length of power of two.
2. No, textures do not need to be square.

How to fit a 3 by 2 ratio into that? Anyway you want, as long as you respect 1. and 2.

In Photoshop, you can create a bitmap with a 3 by 2 ratio of sides, showing the six faces of the cube, each square. But to be able to load it as texture and upload it to the graphics card, you need to transform it in a way to comply with 1. and 2. So, e.g., you could simply change the size of the bitmap to be a square. Of course, that will distort the six square faces of the cube and make non-square rectangles out of them. But that will be automatically corrected and mapped correctly by the GPU. That is done relying on the UV coordinates.

UV coordinates always range from 0 to 1 on each axis, where 0::0 is the upper left corner and 1::1 the lower right one. It doesn’t matter which aspect ratio or size a texture has, these coordinates will always be applied.
So you could, for instance, use a 128x2048 px bitmap to map on the cube. If the UV coords are set to six equally sized rectangles (3 by 2 grid, first row: 0::0 to 0.33::0.5, 0.33::0 to 0.66::0.5, 0.66::0 to 1::0.5, second row: 0::0.5 to 0.33::1, 0.33::0.5 to 0.66::1, 0.66::0.5 to 1::1), the coordinates of the pixels actually drawn on the geometry are calculated by multiplying an interpolated UV coordinate of the current pixel to draw with the length of the corresponding side of the texture.
So the center pixel of the upper left rectangle within that 3 by 2 grid would be located at (0.33 - 0) * 0.5 * 128 :: (0.5 - 0) * 0.5 * 2048, which is 21.333::512.

I don’t know how much my explanations you’ve already known, but I hope there was at least something new for you =)

Cheers!
Alex

 Signature 
signature_image

http://www.deltastrike.org

   

John Brookes, Moderator
Posted: 16 August 2011 10:44 AM   Total Posts: 732   [ # 17 ]

yeah the latest beta2 player readme

Enhanced high resolution bitmap support — BitmapData objects are no longer limited to a maximum
resolution of 16 megapixels (16,777,215 pixels), and maximum bitmap width/height is no longer limited to
8,191 pixels, enabling the development of apps that utilize very large bitmaps.

But isn’t the size also limited by the GPU itself?

   

Avatar
jansensan, Newbie
Posted: 16 August 2011 12:03 PM   Total Posts: 16   [ # 18 ]
Ringo Blanken - 16 August 2011 07:57 AM

Amon he talks about a 2x3 grid, what I see in his picture is a 3x2 grid.

Ringo, I had originally tested with a 2x3 grid, but the results were worse. I removed the correction 80prozent had provided so you see what happens if I take the code as downloaded with a 2x3 grid.

Test:
http://jansensan.net/experiments/away3d-tests/cube03.html

Image:
http://jansensan.net/experiments/away3d-tests/resources/images/2x3_1024x1024.jpg

   

Amon, Newbie
Posted: 16 August 2011 12:11 PM   Total Posts: 15   [ # 19 ]

Yep… I’ve tried the same… 2x3 or 3x2 (square bmpd 1024 or 2048 pix per dim) it doesn’t work

   

Avatar
80prozent, Sr. Member
Posted: 16 August 2011 11:10 PM   Total Posts: 430   [ # 20 ]

@ringo: befor i changed any code in cube.as, i tested varius 2x3, 3x2 grids for 6-tiled textures. none worked.

edit: ups…didnt realised their was allready a secound side for this thread…

 Signature 

sorry…i hope my actionscript is better than my english…

   

BlackSheep, Newbie
Posted: 12 September 2011 10:18 AM   Total Posts: 1   [ # 21 ]

Hi All,

This is my first post on Away3d Forums and I had similiar trouble to other people who have posted on this thread but have to say the fix by 80prozent worked quite nicely for me, however I have some questions surrounding the skybox, Im currently building for the flash player 11 beta release, had to do another fix surrounding the viewport that was posted by another coder in order to get anything to build first off so my question is just a general wonderment about wether people are experiencing the same problem as me. I’m having trouble displaying a skybox, the error i get is around me not providing all the correct mip map levels for the skybox, this error also occurs on the broomstick example water demo so i know its not my code or my textures, however i able to run the example of the water demo off the website, so could I have broken the skybox myself by implementing the Cube UV fix or by implementing the ViewPort fix ? Does anyone have a skybox running correctly from their own source on Flash Player 11 Beta or is this a known problem? Thanks all

cheers

Rhys Thomas

   

Mr Margaret Scratcher, Sr. Member
Posted: 12 September 2011 05:57 PM   Total Posts: 344   [ # 22 ]
Ringo Blanken - 16 August 2011 07:57 AM

Amon he talks about a 2x3 grid, what I see in his picture is a 3x2 grid.

Yep, I just borrowed his demo texture and rotated it, and am now getting what I’d expect.. to a degree at least…


Really wish i was better at constructing classes, I can pseudocode what needs to happen to a set of 6 bitmaps in order to generate a 2x3 grid, but I’m not yet experienced enough to put it into code…

 

And yes, it does not make sense that the grid divides by 3 along one edge, of a length not divisible by 3…

   

Mr Margaret Scratcher, Sr. Member
Posted: 12 September 2011 06:21 PM   Total Posts: 344   [ # 23 ]

I’ve managed to get the cube displaying what it should, but it looks ver poor indeed, due to the texture being stretched out and then squashed back again… The tile6 method might work for cubes which are roughly equal in all dimensions, but for my purpose, a DVD case, it doesn’t look very good at all…

Mybe I would be better off making an actual DVD case in blender, and then writing the covers over the imported UV… Hmmm…

   

Mr Margaret Scratcher, Sr. Member
Posted: 12 September 2011 08:04 PM   Total Posts: 344   [ # 24 ]

Actually, having looked again, it is actually alright, solong as the mouse isn’t moving, which for some reason blurs the textures… It’s also happening on the texture of my imported .obj, but only in one area..

   

Avatar
ddddesigns, Jr. Member
Posted: 14 September 2011 05:50 PM   Total Posts: 37   [ # 25 ]

Sounds like you have motion blur turned on.

   

Mr Margaret Scratcher, Sr. Member
Posted: 14 September 2011 06:32 PM   Total Posts: 344   [ # 26 ]

Nope, besides, it is literally when I move the mouse pointer, nothing is moving on screen…

   

Avatar
ddddesigns, Jr. Member
Posted: 14 September 2011 06:33 PM   Total Posts: 37   [ # 27 ]

Wow.  that is strange….

   

Mr Margaret Scratcher, Sr. Member
Posted: 14 September 2011 06:39 PM   Total Posts: 344   [ # 28 ]

Weird, it;s fine until I add the objects, lemme try adding them but not making them interactive…

   

Mr Margaret Scratcher, Sr. Member
Posted: 14 September 2011 06:43 PM   Total Posts: 344   [ # 29 ]

Yep weird, adding them without mouseEnabled = true; and it;s all fine…

I would show you an example but I get sandbox security errors with it live (never did quite understand what needed to be done with the .xml for that in order to get it to work, maybe now’s the time to find out….)

   

Mr Margaret Scratcher, Sr. Member
Posted: 15 September 2011 08:26 PM   Total Posts: 344   [ # 30 ]

http://videoemporium.co.uk/VirtualEmporium/index.html

Okay, you should see what I’m talking about here - when you move the mouse, without dragging, the DVD textures blur…

   
   
‹‹ PreFab usage

X

Away3D Forum

Member Login

Username

Password

Remember_me



X