Wings 3D Development Forum
I currently can't sphere/cylinder map this type of chart/cuts - Printable Version

+- Wings 3D Development Forum (https://www.wings3d.com/forum)
+-- Forum: Wings 3D (https://www.wings3d.com/forum/forumdisplay.php?fid=1)
+--- Forum: Gripes & Grumbles (https://www.wings3d.com/forum/forumdisplay.php?fid=4)
+--- Thread: I currently can't sphere/cylinder map this type of chart/cuts (/showthread.php?tid=1504)

Pages: 1 2 3


RE: I currently can't sphere/cylinder map this type of chart/cuts - ggaliens - 12-29-2015

Yes ... I wrote my own spherical uv coordinates ... to bypass or over-ride anything already assigned.


RE: I currently can't sphere/cylinder map this type of chart/cuts - ggaliens - 12-29-2015

Depending on exactly what we want to do with the UV coordinates ... the mapping could be as simple as ...
Code:
command({vertex,{manifoldlab,spherical_y}}, #st{sel=[{WeID,Set}]}=St) ->
    wings_io:hourglass(),
    #we{} = We = gb_trees:get(WeID, St#st.shapes),
    [{_,MinY,_}=_Min,_Max] = wings_vertex:bounding_box(We),
    {_,Dy,_} = e3d_vec:sub(_Max,_Min),
    TWOPI = 2.0*math:pi(),
    MyAcc = fun(Vi, #we{}=Acc) ->
        {X,Y,Z} = wings_vertex:pos(Vi,We),
        U0 = (math:atan2(X,Z) + math:pi())/TWOPI, % range 0 - 1.0
        U = min(U0,1.0000),
        Temp = max(min(Y/(0.5*Dy),1.0),-1.0),
        V =  (math:asin(Temp) + math:pi()/2.0)/math:pi(),
        set_vtx_uv(Vi, {U,V}, Acc)
    end,
    We2 = gb_sets:fold(MyAcc, We, Set),
    wings_shape:replace(WeID,We2,St);

The issue with the above is that it does not address what happens when an arbitrary triangle crosses the U=1.0 boundary. That could be detected and handled properly if we iterated using FACES and if we assumed that the mesh was somewhat dense ... which is surely the case if we are trying to make a planet or moon.

Here is anther interesting UV mapping consideration ... I might need to look into ... not sure how Wings3D sets or handles UVs over-runs.

http://gamedev.stackexchange.com/questions/61217/why-is-it-possible-to-encounter-a-texture-coordinate-greater-than-1-or-less-than


RE: I currently can't sphere/cylinder map this type of chart/cuts - micheus - 12-29-2015

Thanks for share the fragment of code.

(12-29-2015, 05:44 AM)ggaliens Wrote: Here is anther interesting UV mapping consideration ... I might need to look into ... not sure how Wings3D sets or handles UVs over-runs.

http://gamedev.stackexchange.com/questions/61217/why-is-it-possible-to-encounter-a-texture-coordinate-greater-than-1-or-less-than
That use to be applied to make "tillable" textures.
If you move the mesh outside the map image it will like be "moved" inside from the other side:
[Image: th_sphere-map-tile_zpsbxh8hrl6.png]
[Image: th_sphere-map-tile-2_zpsqjfffmmq.png]
Maybe you could use that to avoid to make that cut from top to bottom, it could be "imaginary".

Just now I noticed the Y in 3D space was not matching with the Y in UV space. (it's upside down) Smile


RE: I currently can't sphere/cylinder map this type of chart/cuts - ggaliens - 12-29-2015

I didn't need the long cut line at all. BUT ... that being said ... it did mean that I'd need to throw away the texture at the end of process and do "convert materials to colors". Which in this particular case is what I wanted to do anyways.

Did you try that code fragment ?

No long cutline needed. Poles very very simple.


In my dropbox ... I did share "good-moon" file. If you wanted to inspect result closer.


RE: I currently can't sphere/cylinder map this type of chart/cuts - micheus - 12-29-2015

She looks beautiful. Good work. Smile

(12-29-2015, 02:53 PM)ggaliens Wrote: it did mean that I'd need to throw away the texture at the end of process and do "convert materials to colors". Which in this particular case is what I wanted to do anyways.
That should create dozens of materials. Doesn't it?

Quote:Did you try that code fragment ?
No, I didn't have time for test it. I was updating my dev environment and got some issues. I just fixed it today.

Quote:No long cutline needed. Poles very very simple.
It's there in a certain mode - virtually. It's easy to see if we decide to apply a moon texture to it which produce a nice visual result.
[Image: th_moon_zpsrxbyjurq.png]
By doing that, I noticed you:
1) left the UV information in the mesh;
2) the UV information looks weird since it's boundaries are very irregular and we use to apply a squared or rectangular image that should be entirely mapped;
3) you assigned that information to the Default material, since I just dragged the image to it and got it applied. You must to use a proper material for that - I just heard from dgud once that I shouldn't play with Default materials values; Wink
4) by having the UV map information, I tried to backing the vertex color into a texture and got a big crash. It seems that "garbage" compromised Wings3D operations:
Quote:Window: {autouv,2}
Reason: {badarg,[{gl,bindTexture,2,[{file,"gen/gl.erl"},{line,7000}]},
{wpc_autouv,draw_background,1,
[{file,"wpc_autouv.erl"},{line,1950}]},
{wings,'-redraw/2-fun-0-',2,[{file,"wings.erl"},{line,280}]},
{wx,batch,1,[{file,"wx.erl"},{line,180}]},
{wpc_autouv,handle_event,2,
[{file,"wpc_autouv.erl"},{line,572}]},
{wings_wm,handle_event,3,[{file,"wings_wm.erl"},{line,931}]},
{wings_wm,send_event,2,[{file,"wings_wm.erl"},{line,903}]},
{wings_wm,do_dispatch,2,[{file,"wings_wm.erl"},{line,768}]}]}
[Image: th_moon-map-is-there_zps5ebxkdyb.png]In the left a weird selection when I did that using the marque option in face mode. Do you see that too? In the right is the strange UV map.

Maybe you should to remove that information. There is a operation for that which code you could to use - with it selected in Body mode -> Vertex Attributes -> Remove UV Coordinates.
After I do this I was able to backing the vertex color to a texture;


RE: I currently can't sphere/cylinder map this type of chart/cuts - ggaliens - 12-29-2015

Yes. I understand some of what you offer here. Removing the UVs might be a good idea.

But as you have discovered ... I'm leaving a path of odd UVs where the seam wraps. I do know how to fix this I think. We shall see. It goes away when I do two steps (1) convert the materials to colors (SLOW). And then (2) delete unwanted items in outliner. I'm creating a bunch of worlds in the dropbox that you can look at ... if you have any time.

So ... I still need to decide what steps I want to make "auto-magical".


RE: I currently can't sphere/cylinder map this type of chart/cuts - micheus - 12-29-2015

That noise can maybe come from the seams. Remember what I said/show about the tillable texture...
[Image: moon-seam_zpshdar7oas.png]
You are mapping UV to its limit [0.0-1.0] that results each side of the seam to not fit fully each other. In the image I'm showing only the left side - it's a lot of work play with images that way. Smile

you need "define a virtual straight line" (the meridian) that will match with the left and right side of the image and by using it you chose which vertex must be mapped like greater then 1.0 for the right side and which should be mapped less than 0.0 for the left side.

It's something like that. I hope you got the idea.
It may not work exactly like that but in that way - need to code and test (not me Wink)


RE: I currently can't sphere/cylinder map this type of chart/cuts - ggaliens - 12-29-2015

You don't need a straight line to fix it. You just need to set the proper OpenGL behaviors. That's why I provided the relevant link earlier in the thread. Basically ... when the UV crosses the seam ... I allow the UV to go to 1.01 or 1.x and that .x portion is just wrap around if the proper OpenGL setting is poked.

It's just another way to say that OPENGL can automatically TILE your textures for you so that wrap around does not make bizzare artifacts. But I also need to make sure my UVS don't wrap explicitly ... they mych get just over the U=1.0 line and I can do that by iterating by face as I set UVs.


RE: I currently can't sphere/cylinder map this type of chart/cuts - micheus - 12-30-2015

I should have made all the image steps... Undecided

I didn't say you need a real straight line.
That red line is representing the two sides (left an right) of the texture when you roll it in a cylinder. The point where they are "glued".

The Black line is just the right boundary of the your UV map "mesh". The oder left side is laying in the right side of the red line and I didn't represented it. But it's there.

The space between both is what is causing the noise you see in that sub dark image. It's a portion of your UV mapped sphere.

So, if you really "allow UV to go to 1.01...", but also -0.01 - something you are not doing - you will remove that noise and you will get your sphere perfectly mapped - no gaps or noise in the result produced.
Think that as scaling the UV in the horizontal until that sinuous black line be centred in the imaginary red one - some vertices will lay on the left of it other on right.

But, it's of your interest this, not mine. I don't know why I keep trying to explain this kind of stuff. It's a bit of compulsive. Smile
I need to take control over this otherwise my precious time to work in Wings3D flies away.


RE: I currently can't sphere/cylinder map this type of chart/cuts - ggaliens - 12-30-2015

It's not noise you see ... it's a copy of the entire image wrapped across each little triangle .. in that odd triangle strip.
So the fix is just to modulate the numbers differently and set the texture mapping style in OpenGL.

A lot of people doing the same thing ... use the GEODOME as a substructure. So I'm trying the geodome a bit more today. Noticed the dialog box had limits because it does not like ggaliens.