#273629
Texture Mapping

Texture-mapping in the 1.7 plugin works slightly differently than in previous versions. I will highlight the most valuable information. To begin with, let us establish some terms:

Texture Tiling

see: Rhino Help > Search 'tile' > Material mapping options

in a regular Rhino 'basic' material, one may assign up to four different maps, 'Texture', 'Transparency', 'Bump', and 'Environment'. In each of these, there are Rhino parameters for 'Tiling' which you access by clicking on the map's 'Modify...' button. The parameters available are 'Tiling' and 'Offset'. These correspond to the Tile X/Y and Offset X/Y parameters in a Maxwell texture.

These parameters are per-material, though they sometimes seem to be per-object. The reason is that Rhino creates new materials all the time, so if you change these parameters for a certain object, you are really creating a new 'basic' Rhino material. This is hidden from you, since (unlike Maxwell) Rhino never shows you the 'list' of materials contained in a document. In Maxwell, the Tile/Offset parameters are per-texture, so that means they are also per-Material, like in Rhino. However, Maxwell does not create hundreds of similar-but-different materials like Rhino does, so changing Tile/Offset for a certain texture will change those values for all objects which use that texture's Material.

Texture Mapping

see: Rhino Help > Object Properties > Texture Mapping

In addition to each Rhino object-material's tile/offset parameters, Rhino also offers specialized functions for adding 'Texture mappings' to an object. Texture mappings provide a way of 'projecting' a texture onto an object, using a set of primitives: plane, cube, sphere, and cylinder. These are managed using Rhino's Object Properties > Texture Mapping window. Multiple mappings may be added to each object - when there are more than one, they are referred to by their index, so an object which has three mappings added to it has mappings at index 1, 2, and 3.

Maxwell textures have a 'Channel' parameter - it is this parameter which is used to associate any given texture with a certain Rhino mapping. If, as shown above, you have an object which has three mappings, you may associate a Maxwell texture with the object's second mapping by setting the texture's Channel to 2. There is a subtle feature that the 1.7 plugin adds in this area: normally, it is not possible to show any certain Rhino mapping in the viewport. Rather, you must actually modify the desired mapping, and then it will be updated and shown. The 1.7 plugin lets you switch which Rhino mapping is shown in the viewport by simply changing a texture's Channel, or selecting between different textures - when a texture is selected, the viewport will be updated to show the Rhino mapping which corresponds to the selected texture's channel.

An Example

1. make sure that viewport-materials are enabled (Database Manager toolbar > Enable/Disable real-time viewport Materials)
2. create a one-meter cube
3. open the Maxwell Material Editor and create a new Maxwell Material (Options > New Material)
4. drag-drop this new Material onto the cube
5. right-click the Reflectance 0° texture in the Material's BSDF layer
6. the Material Editor's texture-editor should now be opened. Click the 'Browse' button
7. select a bitmap to use in this texture and click OK

Now, this texture will be shown on the cube in the viewport. The texture will be 'stretched out' to cover the cube's surface - it is using Rhino's default 'surface' UV mapping. So let's continue:

8. in the Maxwell texture-editor, change the texture's Tile X and Y parameters to 0.25
9. the viewport will show you the effects of the change you made

Here, if you were to select the cube, go to Rhino's Object Properties window, and select the Material page, you could inspect the Rhino material which has been created by the plugin. Switch the material assignment from 'Plug-in' to 'basic', and then click 'Modify...' in the 'Texture' texture. You should see that the plugin has created a Rhino material with matching tile/offset values as you set in the Maxwell texture. Now, let's add a Rhino mapping:

10. select the cube and go to Rhino Object Properties > Texture Mapping
11. switch from Default to Custom
12. check the 'Show Advanced UI' box - you will see that a 'Surface' mapping has been added on Channel 1
13. switch this mapping to use the 'Box' projection
14. click the 'Show Mapping' button
15. look in the viewport - you should see the cube mapping as a dotted-outline object (it has the color of the Default layer, so you may need to change that depending on your viewport background color)
16. select the 'mapping widget' and rotate it using the regular Rhino Rotate command
17. click Render

Let's discuss what we're dealing with now. We have a Maxwell texture which uses Channel 0, but we have a Rhino mapping on channel 1. Why is this mapping shown when we render? The channels don't match, after all. The reason is: in addition to the list of Rhino mappings you may add using the Texture Mapping window, there is also a default 'viewport' mapping. This mapping is filled with the parameters from whichever explicit mapping is currently being edited, so, when we changed the rotation parameter of the channel 1 Rhino Box mapping we created, this channel 1 mapping was copied into the default viewport mapping, so we could see what we were doing. So therefore, it should now make sense why the Maxwell texture on Channel 0 has the same placement as what is being shown in the viewport. Let's explore this further:

18. select the object and add another Rhino mapping - this new mapping will use Rhino's #2 mapping channel, and it will now be shown in the viewport
19. switch the mapping to use a 'Planar' projection, see that the viewport has changed
20. click Render

Now, the render does not look like the viewport. Why? Because we are working with the #2 Rhino mapping in the viewport, but our Maxwell texture is assigned to Channel 0. If we:

21. switch the Maxwell texture to use Channel 2
22. click Render

Now the render matches, since our texture is using the same mapping channel which we are working with in the viewport. The next step demonstrates a new feature of the 1.7 plugin:

23. switch the Maxwell texture to use Channel 1

You should now see Rhino's channel 1 'Box' mapping again. This is because (as noted before) the plugin will cause whichever channel is being edited in its' texture-editor to be shown in the viewport, if such a channel exists. Now, let's use two different textures:

24. in the Material Editor, click the button for the BSDF's Roughness texture
25. in the texture-editor, click the Browse button and choose a map
26. switch the texture to use Channel 1

The viewport should not change - we were already viewing Rhino's #1 mapping channel since we selected it in step 23.

27. switch the texture to use Channel 2

Now, the viewport should show Rhino's #2 mapping channel. We can now click between the Reflectance 0° and Roughness maps in the Material Editor and watch the Rhino viewport switch between Rhino's channel 1 and 2 mappings.

This is the basic operation of the plugin as regards Rhino texture-mapping. However, there is one more important aspect which has not yet been mentioned: Real Scale. When a texture has the Real Scale feature enabled, it works under a different set of rules than those shown above. Namely, it is always done using Channel 0. This means that there will be no explicit Rhino mapping associated - they always start at #1. If a texture uses Real Scale, it will create/show its special mapping in the viewport whenever it is selected, or its Channel is changed to 0. If a texture on a Channel other than 0 uses Real Scale, the only effect is that the action of the Tile X/Y parameters is reversed - setting a smaller tile size will shrink the tile and setting larger will grow it - it will not necessarily have any certain size-relationship to the objects which use it.


Real Scale

Real Scale texture mode provides a way of working with textures in an object-size-independent way. By default, textures are projected onto objects by Rhino using a 'surface' mapping. This means that the rectangular texture is stretched out across the surface. Optionally, you may use Rhino's texture-mapping tools to define other explicit planar, cubic, spherical, or cylindrical mappings. Rather than the texture's pixels being stretched to fit the object's surface, they will be 'projected' onto the object using these primitives. When an object which has no explicit mapping is scaled, the texture's pixels are just stretched out differently, depending on how the object was scaled. If it uses an explicit mapping, Rhino will attempt to scale the mapping to match. In both cases, the size of the mapping is dependent on the size of the object. In many cases, this is the desired result - the texture bears some relation to the object it is being assigned to, and when the object changes, the texture should be changed to match. But it is not always desired.

Say, for example, that you are building a model of a piece of wood furniture. You want to assign a woodgrain texture to the various parts of the model. In this case, it is certain that you do not want the size of the texture to be dependent on the size of each object it is assigned to - the size of the woodgrain should remain constant. This is the purpose of the Real Scale function; to maintain texture-size independent of object-size. In Maxwell, this means that rather than defining a texture's size by defining how many times it 'tiles' across the mapped area, this texture may have its' Real Scale feature enabled. After doing so, the meaning of the Tile X/Y size parameters take on a different meaning: if you specify a Tile X value of 0.25, it does not mean to stretch out the texture four times across the mapping, it means that each tile should be an absolute 0.25 meters in the X direction. To use a texture in Real Scale mode, you should not define any explicit Rhino texture-mappings for it - the plugin will create a cubic mapping for each object to which this texture is assigned. After creating the object's mapping, the plugin will size it so that each texture tile is [Tile X/Y times 1 meter] in size, regardless of the current document's unit scale.

This brings a new question: if you are not supposed to define an explicit projector for Real Scale textures, how can you define the orientation of the texture on the object? Normally, this would be done by selecting the Rhino texture-mapping, clicking 'Show Widget', and then manually dragging it around the viewport. Since this is not possible, and the orientation of the mapping is determined only by the plugin, you are provided with three rotation parameters in the Maxwell Object Properties page - these will be shown when the object is selected in the viewport.

So, using Real Scale is actually the simplest method of mapping with the plugin:
  • 1. assign a Material which uses Real Scale textures to an object
    2. make sure that the Real Scale-enabled textures use Channel 0
    3. select the object
    4. find the Maxwell Object Properties > Real Scale Texture Control section in Rhino Object Properties
    5. use the x/y/z axis rotation controls to orient the texture as desired
This is all that is required; after doing this, the object may be moved/scaled/rotated/modified however you wish, and the plugin will keep the mapping oriented correctly and sized based on the one-meter scale. If a Real Scale-enabled texture uses a Channel other than 0 then the texture will operate just as any other, except that its Tile X/Y parameters will size things inverse to normal - decreasing Tile will decrease the texture-size, and vice-versa. The plugin will cause whichever mapping index is used by the current texture to be shown in the viewport, if one exists - this happens when switching the 'current' texture (i.e. clicking on a texture-button in the Material Editor), or when changing the Channel of the current texture.

Note that because the plugin is a client of the viewport, and not its' owner, there are certain object-modifications you may make which will cause the viewport to show an inaccurate representation of the mapping (i.e. boolean, split, etc. - things which cause UVs to be re-calculated), and it may be necessary to use the 'Refresh viewport Materials' command to restore the Real Scale state of the object in the viewport.

Real Scale Texture Control

Real Scale is a mode for Maxwell Textures which ensures that they are sized based on an absolute scale of one meter, regardless of the size of the objects they are assigned to. The plugin maintains its own texture-mappings for objects which use these textures, and it always uses the texture Channel zero. Using normal Rhino texture-mappings, moving/scaling/rotating the object may cause the texture-mapping also to be moved/scaled/rotated, and this makes it almost impossible to maintain a consistent relationship between the position of the object and the orientation of the texture on that object.

The plugin manages Real Scale mappings in a different way: as opposed to Rhino texture-mappings, the mapping maintained by the plugin is created using physical characteristics of the object to which it is applied. This is necessary because Rhino objects do not have any concept of a local transformation - they all exist in world x/y/z space, and as a result, there is no reliable way to know how an object may have been modified. While the plugin's method allows for a mapping to always be oriented consistently with the current position of the object it is applied to, there is a downside: the actual position of the texture on the object is out of the user's control - it is permanently tied to the object, however it was oriented when it was created

This is the reason for the existence of the Real Scale Texture Control section of the Maxwell Object Properties page: to specify an x/y/z rotation for Real Scale textures which are used by this object. When the mapping for an object is created and maintained by the plugin, it will be rotated using the values specified here after it has been oriented to line up with the current position of the object. Note that while the rotation is continuously-adjustable using the normal click/drag-up/down method of the plugin, the +/- increment buttons here are configured to alter the value in 90° increments. Using these rotation controls, it is possible to orient a texture on an object, and yet to have this orientation remain in effect as the object is further moved or modified.
Sketchup 2024 Released

I would like to add my voice to this annual reques[…]