Jump to content

Tiling/Blocking a Shader


Recommended Posts


So Im trying to very basically tile the shader, what I want out of this is the ability to effectively cut the object into sections that are a set size and then be able to set that block to a color or a texture reference.

If I can figure out how to cleanly tile a texture I should be on the right path.

It does not seem to be tiling very effectively...  maybe I should be doing the split up on the UV and not the world position?


nevermind im dumb... I was doing xy not xz... anyways, anyone now how to output some info for debug in GLSL?
visually is the only way I know of how so like: http://www.babylonjs.com/cyos/#1ZJMOH#4

Here is the difference between UV and world position:


Link to comment
Share on other sites

Ok, but, sigh.

A shader... is a material thing, not really a subMesh thing.  SubMeshes use multi-materials... and those could be shader-made materials.

Tiling is a subMesh/multiMaterial thing.  At least I think so.  :)

Here's a thing where @NasimiAsl shaderBuilder was used... for tiling-ish things, though.  Looks like he's doing careful manipulation of the box UV's.  This is material tiling, but not mesh/subMesh tiling:


Aw heck, let's show another "Naz" special... http://www.babylonjs-playground.com/#1BPLPL#1

That water is a long and continuous texture, eh?  Cuz... it's a "procedural texture".

I think... you seek Yoda.  :)  Err... I mean... you seek procedural textures... that are based-upon static textures.  We have quite a few pattern-based procTextures listed at the bottom of the previously linked page.  Maybe a decent "early step" is to get a procedural texture... "mapped" across all 4 tiles of this playground... in a way where we see no texture seams between tiles.  Start with the bricks procTexture, perhaps.  *shrug*

If you get bricks proc-texture to map across tiles without seam-lines, you're halfway home, yes?

Link to comment
Share on other sites

9 minutes ago, Wingnut said:


A shader... is a material thing, not really a subMesh thing.  SubMeshes use multi-materials... and those could be shader-made materials.

I know its a material thing... does not mean you don't want to identify zones in your shader, in relation to the mesh.
I never once said anything about sub meshing, but I can see how when I said cut it up you could infer that.

Link to comment
Share on other sites

Ok so we have our plane and on it it has global positions that we turned into a grid of what ever set size.

So each section of the material would ideally have a pseudo unique ID from its position in global space by doing some sort of combining of its cords.

Now once we have a ID for each block, we take that ID and pass it through a pseudo random number generator that has a set seed, and transpose its value to a range between the number of textures you have in your array, so if its a grass area and we have 6 textures that seamlessly fit into each other but have different key elements, it would take the ID generate a number between 0-5 and then point to that texture placing it in that section of the material, which would be random but controllable with your seed.


Link to comment
Share on other sites


I almost got it figured out... I just need to figure out a better way of rounding to a nearest size...

So that way I can define a block size, and not have the position matter...  if I can figure that out, then i already figured out how to do a pseudo random number to get that areas assigned texture...

Somebody has to have an idea what im trying to do...  I am clueless on shaders this is a bunch of tossing crap at the wall and seeing what happens...

*** EDIT

Ok now I got the block IDing http://www.babylonjs.com/cyos/#1ZJMOH#7
now to transpose them to a value between 0-3.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...