Rotate and overlay DynamicTexture itself on sphere on y and z axis

Hi there

Here’s my Playground

I’ve got a problem: I’d like to create a texture for a sphere where on all axises (x, y and z) will be strips, like on Y axis in the playground. The reason I decided to use a dynamic texture is that I need not static texture, it should be generated on a client every time a user sets a new value for the gridSize variable. For now it’s a const, but it’s just an example.

I assume the easiest way to reach my goal is to overlay the texture on itself with rotating it on 90 degrees twice (around one axis and another). But I don’t know if it’s possible and how to do it if it’s so.

P.s.: if you got what I want you could also offer me other ways those seem to be better or more optimal or have any other advantagies over my intention. Thank you

Hmm you could make a custom shader to rotate the UVs and sample the texture a second time but it would be simpler to just draw the vertical lines to the dynamic texture too I think. Maybe something like this for example. :slight_smile:

Ahh, sorry, I mean a different thing

Imagine this is a sphere, with red strips on two axies. Y axis strips should be paralleled to it’s axis, like X asix strips to X axis and Z axis strips to Z axis.

Oops, sorry IDK what kind of grid you want to make then if it’s not anything like below… :thinking: But maybe someone else will. :slight_smile:

Finally created in Krita one side of it

And from an angle

Take only the idea of how strips are located. It’s just 2 colors.

Huh? I would say the same as @Blake. No clue what you are trying to achieve and what exactly the issue is. From your initial post (I didn’t reply to because you are using baseTexture and I have no experience with it) but I believe @Blake gave you the answer for it. Then I would have said the same for

I’m afraid you will have to further explain why you are using a baseTexture and (may be more importantly) what exactly is this grid). I believe we both understood the initial post and thought just to rotate your texture 90°… but apparently this still doesn’t give the result you want, does it?

No, it would give the result.

@Blake created a UV sphere, where vertical lines are merged at poles.

My plan is to create a sphere with like a Rubik’s cube texture on it.

OK, yes, now I get it. However, I have no idea how to do it :wink: Not just now. It’s a matter of how the UVs/normals are on a sphere - Where you want the texture on the sphere to render the same as on a cube, correct? If only my Maths would be better, I would have already given you the solution instead of typing this :wink:

I suppose you already tried changing the projection mode to cubic, yes?

    mat.diffuseTexture.coordinatesMode = BABYLON.Texture.CUBIC_MODE;

That would be too easy, wouldn’t it? :wink:

Tried it, but nothing’s changed :smile:

No, of course it doesn’t. As I said, too easy, doesn’t make sense :grinning:
Let’s call in once again @Blake or eventually @PolygonalSun to help you fix this, now that we have the full information. If anyone can tell you how to do it, I’m sure one of’em will :smile:

It would easy if we could just divide a sphere’s surface onto 6 different parts by proecting a cube and then apply the same texture on every part.

Yes. I can do it in a 3D app of course but I have no clue how to do it in BJS.

Would that work if it is only for stripes GUI3D : Slider3D isVisible boolean not working ?

The grid material uses the vertex positions instead of UVs, are you going for something like this maybe? If so there’s also an NME version that can be customized more. :slight_smile:

4 Likes

:open_mouth::open_mouth::open_mouth::open_mouth::open_mouth:
There’s already a built-in material, undeliverable!
Found out even how to change frequency (amount of lines in a grid).

The main task solved, but I’ve got a small question :new_moon_with_face:: How to get rid of these dim barely visible lines. They catch my eye even thou they barely visible
image

1 Like

Awesome, setting minorUnitVisibility to 0 should take care of that I think, or if not a PG repro with that issue will help. :slight_smile:

3 Likes

Did you see my answer to your earlier question? Does it not do what you want?

1 Like

Oh yeah

They are different questions :new_moon_with_face: about different shapes

But I’ll need to apply the same things to this material too: putting stones on points on click

I do not understand the difference. This is precisely what my solution does.

Well it’s a really nice demo either way IMO, and in only a few hundred vertices! :+1: :beers:

1 Like