Decorated pig

podperson

Active member
Nice plating Archie. I'd love to use a similar technique for my bake but I can't use either procedural 3d space or UVs since the model is horribly complex, has no UVs, and no local coordinate spaces for its components (very frustrating actually). I ended up using voronoi (constant) instead of cellnoise because cellnoise makes it so much more obvious how bad it is.
 

podperson

Active member
UV Indirection

I just realized that one of the things I've been asking Martin for (tilable bitmap samplers as per Groboto) can in fact be done using the existing material system, and in fact it represents a very powerful hybrid technique for using procedural textures in a controlled way. (It also gives me an idea for a very useful utility program for creating new tiling materials.)

The basic idea is that you use an image as a "sampler", in other words instead of the pixel you get based on a UV coordinate being the color you use in your material, it's the UV (or RG -- red green) coordinate of the sample you take from the next image in the food chain. (See diagram.)

The red/green/yellow things are "sampler" images that map an incoming UV coordinate to a new UV coordinate. The first is the "identity" -- it doesn't do anything, but it's useful for creating other samplers. The next is the one used for the metal pig. The next is a "brick" sampler.

The beauty of this technique is that it lets you grab pieces of a non-tiling image and create a tiling material. It also lets you grab portions of an image and render arbitrary pieces of them (at arbitrary scales and angles) in the final material.

And you're not limited to sampling bitmap -- you can use the same technique to sample procedural materials.
 

Attachments

Last edited:

podperson

Active member
Here's a version of the material used — I replaced the source bitmap with a procedural node to keep the file size down. It also illustrates the idea of using a bitmap sampler image to sample a procedural node. Not all procedural nodes work this way (cellnoise for example does not).
 

Attachments

podperson

Active member
More complex example of the same idea

Here's a considerably more complex example of the same idea, using the brick sampler (and a mask for handling the mortar).

Note that the "mortar" is a tiling sampler of the original image created by using composited red and green clouds — so it's basically grabbing continuous random samples from the source AND it tiles.
 

Attachments

very interesting !

i think putting a spatial gradient into a position is basically scaling.
like when you are walking in a slow train at the same speed, the velocities ad up, the speed doubles.
when you walk the other way they cancel and you stay in place related to the outside.
so when you put the state's uv into a node's position you do a scaling x2.
when you invert the uv you freeze the node, it will show the origin's pixel color all over.
i see that red means u and green v but have not yet figured out why the uv colors are always blueish like normal maps (put the uv into the diffuse of the pig material). maybe blue means height and is set to one by default ?

- archie

Screen shot 2010-08-06 at 11.26.35 AM.png


update:
now this is way better than my approach.
there are artifacts depending on the image filtering that perfectly support the metal effect :smile:
thanks tonio !

View attachment samplat2.c3dmat.zip

samplat2.jpg
 
Last edited:

podperson

Active member
The only fly in the ointment is that there seems to be a bug in the state node such that its UV1 output doesn't actually match UV1 output (you can verify this by building a simple image -> diffuse material then adding a state node and feeding its UV1 into the texture's position -- very odd.

I've reported this to Martin (it's causing the seams you can see in some of the bricks, which should not be there).

The problem doesn't affect sampling of tiling or procedural textures as badly, but it's a problem nonetheless since the whole point of this approach is to sample non-tiling bitmaps to create tiling patterns.

And yes, you get artifacts which may enhance OR detract from the quality of the material. If you use very high resolution sampling bitmaps the artifacts are pretty much negligible.

The blue part of the UV coordinates is just garbage (I guess they're actually UVW and W is always 1 or something).

i think putting a spatial gradient into a position is basically scaling.
like when you are walking in a slow train at the same speed, the velocities ad up, the speed doubles.
when you walk the other way they cancel and you stay in place related to the outside.
so when you put the state's uv into a node's position you do a scaling x2.
when you invert the uv you freeze the node, it will show the origin's pixel color all over.
i see that red means u and green v but have not yet figured out why the uv colors are always blueish like normal maps (put the uv into the diffuse of the pig material). maybe blue means height and is set to one by default ?
No, it's sampling. An RGB color is a 3d vector on [0,1]. A UV coordinate is a 2D vector on R which wraps onto [0,1] when sampling bitmaps — but C3D passes around UV coordinates as 3d vectors (UVW). So think of each pixel in the "sampling" map as a UV coordinate encoded as Red and Green — it's the location of the pixel you want from the next image map along (hence "indirection").

So the identify sampler maps uvs onto themselves. To create your own samplers, simply grab regions of the identify map and build your own collage. You can rotate them too (but don't do funky things like blur them as this will have very weird effects).

Finally — the reason for the artifacts is that when you get to a boundary in the collage you're suddenly interpolating between arbitrary coordinates instead of neighboring coordinates. (This is also why blurring, etc., tends to be a bad idea. It's not doing what you might think it's doing.)
 
Last edited:
Top