Jump to content

Sign in to follow this  
Michael Goldshteyn

Applying a material to part of a Subdivision Surface without making it editable

Recommended Posts

I have made every effort to apply a material to a portion of a Subdivision Surface (i.e., only some polygons and not others after the SubD changes) without first having to make the subdivided object (i.e., from the SubD level on down) a single editable Polygonal Object (i.e., using Connect Objects + Delete).

 

The reason I want to do this is because I want to apply the material to only a portion of a polygon of a low-poly starting polygonal and/or primitive object, that maps to many polygonal subdivided faces after the SubD step, from which I only want to select a subset of the polygonal faces.

 

Here is a a very simple "contrived" example to illustrate the problem and what is being asked:

 

1. Start with a Plane parametric object (Width Segments: 1 and Height Segments: 1)

Start-With-A-Plane.png.7b36a1456bb9d52c0600768f08453671.png and in the Object Manager: SimplePlane.png.9908bf85377263e8b7caeccc4757d020.png

 

2. Add a Subdivision Surface generator as its parent, producing the following subdivided object that contains of 16 quad polygonal faces:

Add-SubbD.png.bd0d48535e0214a7ba32d084ae3cba08.png and in the Object Manager: PrimitivePlaneSubdivided.png.1c76619106515aed4e38b493dc0ba132.png

 

3. Create a Null group containing the Subdivision Surface generator (the Plane that is its child) and a Correction Deformer. Then click to activate said deformer and, in Polygons Mode, select one of the polygons (i.e., faces) that resulted from the application of the Subdivision Surface:

PolygonSelection.thumb.png.6d10181fc07de1f189561fd333deeb50.png

4. Note that the Correction Deformer does correctly see all of the polygonal faces created by the Subdivision Surface generator and allows you to create a polygonal selection as well as a Polygon Selection Tag, from among them:

CreatePolygonSelection.png.d5c8f5dae83fa74d6690dce9d375df71.png Selection tag attributes showing the tag's name: PolygonSelectionTagAdded.png.e7734ca87f671758e47bb7dc652955da.png

5.

   a) Transfer the Polygon Selection Tag from the Correction Deformer to the Subdivision Surface node

   b) Add a Material Tag for a material to the Subdivision Surface

   c) Drag and drop the Polygon Selection Tag to the Material Tag's Selection attribute to apply the material to just the one selected polygon

   d) Delete the Correction Deformer from the Null - it is no longer needed (I have included the attributes of the two tags in the image below to show that all is right and proper - the Polygon Selection is named as expected and the Selection attribute of the Material Tag is populated with that name):

NoMaterialAppliedToPolygon.thumb.png.f84f444342d4cc2cfd4c1edb0d27e2b5.png

Note that the selected polygon (from the deformer) does not have the texture applied as it should. No polygon of the SubD result does. I can demonstrate that the texture is applied correctly and should be visible, but the polygon selection to select a particular polygon is not working as it should on the Subdivision Surface Generator.

I can do this by removing the name of the Polygon Selection Tag from the Selection attribute of the Material Tag.

This results in the following image in the Perspective View (with attributes of the Material Tag in the image showing that the Selection name was removed to select the entire object):

NoPolygonSelectionMaterialApplied.thumb.png.ecfcc20596e1330891490a2f4449d038.png

 

I should also note that I tried putting the Subdivision Surface generator inside a Connect generator to see if this fixes the issue of polygon selection transfer from the Correction Deformer. I did this by:

1. Making the Subdivision Surface a child of the Connect generator

2. Readding the Correction Deformer, to allow for the selection of polygons from the Connect generator

3. Making a new selection of a single polygon and storing that as a Polygon Selection Tag (this time called Connect Selection)

4. Transferring the Polygon Selection Tag to the Connect Generator, since the polygon selection is now relative to it

5. Applying the same material to the Connect Generator

6. And finally, dragging the Connect's Polygon Selection Tag into the Material's Tag's Selection attribute, with identical results - no material is applied:

ConnectObjectAttempt.thumb.png.dab3ffeac190b61d1d833a2de3ab3c1a.png

 

On top of all of this, I also tried all of the above starting with the Plane first converted to a Polygonal Object using Make Editable (before doing any subdivision on it), that is:

PolygonalPlaneSubdivided.png.d7d673bfa207436a0c256b2f3f0f5b82.png instead of PrimitivePlaneSubdivided.png.1c76619106515aed4e38b493dc0ba132.png

 

So, is there anyway I can apply a material to only a portion of a SubD generated surface (i.e., only some of the resultant polygons), short of a custom UV mapping to a part of the object, or making the object editable and losing my procedural workflow with regard to the SubD generator and primitive(s) underneath it.

 

Thanks for any tips

 

 

Share this post


Link to post

For such a long and rewardingly thorough post, the answer is embarassingly short and not the one you want. That's a hard no I think.

 

CBR

Share this post


Link to post
On 6/25/2020 at 3:23 PM, Cerbera said:

For such a long and rewardingly thorough post, the answer is embarassingly short and not the one you want. That's a hard no I think.

 

CBR

If that is in fact the case, that you cannot partially texture (only some of the) polygons of a generated object - one that goes through one of Cinema's generators, whether SubD or any of the others including Loft, Lathe, Extrude, and Sweep). And, you can't even do this by throwing the whole lot into a Connect generator, whose sole purpose is to "polygonalize" (i.e., materialize into a Polygonal Object) its child nodes, then that is a very large shortcoming of C4D in terms of supporting a procedural non-destructive workflow. It is also very surprising, because it is clear that under the covers, Cinema is generating these Polygon Objects and displaying them in all of their polygonal glory the Editor (i.e., Views).

 

I'll go farther and say that the Correction Deformer even sees the polygons correctly and allows one to generate a Polygon Selection Tag, so all the info is clearly present inside Cinema 4D.

 

Having to constantly make objects editable in order to be able to texture only a portion of their polygons sounds like a really bad approach from a non-destructive procedural perspective, or at the least involves a lot of overhead having to stash away procedural version (for example in some sort of template layer) and then copy and collapse them to Editable Polygons that are completely physically decoupled from their procedural "beginnings."

 

If no-one comes up with a good simple automated C4D solution to this that I am simply overlooking, because it seems to me like this is a commonly needed feature, I am going to have to write a plug-in to allow for this sort of thing. I feel that this is something that C4D really should have available to keep up with other more procedural modeling tools.

 

Michael

 

Share this post


Link to post
1 hour ago, Michael Goldshteyn said:

whether SubD or any of the others including Loft, Lathe, Extrude, and Sweep

 

Well it's not all the generators. Here is that plan working on both loft and sweep for example. I think it is only SDS it doesn't work on.

 

image.thumb.png.be0ecbfde97c9399cb862f5ff51ddbf8.png

 

CBR

Share this post


Link to post
12 hours ago, Cerbera said:

 

Well it's not all the generators. Here is that plan working on both loft and sweep for example. I think it is only SDS it doesn't work on.

 

image.thumb.png.be0ecbfde97c9399cb862f5ff51ddbf8.png

 

CBR

Well, that's interesting and I wonder what makes SDS special, then.

Share this post


Link to post

Well, I got it to work via a fairly complex Python Generator script that took several hours to write consisting of about 170 lines of commented code. I'll post it later after I clean it up and test it further. Here are the results:

Gouraud Shaded:

PartiallyTexturedSubdPolys.thumb.png.1dbb45ade7327d0219a3d333ae88383b.png

..., with lines to show polygons:

PartiallyTexturedSubdPolysShowingLines.thumb.png.9db967dc9c3e84663f723cd19c0664ef.png 

Object Hierarchy

The Python Generator creates a single polygonal object out of the sibling Null that follows it (named Parametric Group in the image below). Then, the Correction Deformer can be employed to create Polygon Selection tags from that single generated polygonal object, which can then be moved them to the Python Generator for purposes of partial texturing. The result is that the Material Tags on the generator with corresponding selections assigned to them allow for a subset of the polygons resulting from the subdivision, to get textured. It should be noted that the generator is forced to copy (clones of) the selection tags to the polygonal object it generates in order for them to have the desired affect. Sadly, if this isn't done, we're back to square one just like with the SubD Gen that started this adventure. Fortunately, this process is automatic and happens behind the scenes when the generated object is, well, generated.

All of this is done without destroying or having to manually materialize the parametric modeled hierarchy as the materialized polygonal object gets created. The parametric nature of said hierarchy allows for meaningful high level changes in real time and such changes get automatically propagated to the polygonal object created by the generator (sans any NGons, since all ngon lines need to be resolved to tris and quads, due to poor NGon support in Python).

Of course major topological changes to the procedural portion will "corrupt" the polygonal selections in the generator's tags, so this example does not represent the best use case for this technique, since it shows many disparate objects merged into one and the topology is therefore closely coupled to all of them.

It is a good demo of the capabilities of the generator and certainly helps to get the point across, though. A real use of this would be to have several (or many) triplet groups, consisting of the generator, a reasonable self-contained parametric subset, and a temporary correction modifier that can be used to generate the selection tags. These triplets would then get grouped as part of a larger model and allow for the continued use of parametric objects such as primitives, generators, and deformers all through the development of the model with the ability to texture partial subsets of the resulting polygonal constructs they create.

Hierarchy.png.4a67ff7c8b896bfb9de8572633d6276e.png

Share this post


Link to post

But wait there's more!

Why have "fixed" polygon selections that break as soon as the topology of the objects to be textured changes, when you can use primitives and parametric shapes to volume select? Now things are getting really interesting from a procedural perspective:

ReallyParametricSubdTexturingWithFields.thumb.png.e0ac7a1d86d7e4170ac6524323551d0b.png

 

Share this post


Link to post

Nice solution...

Fir this kind of selections I use xspolyinstance or ToPoly plugins which do the same. Create polyinsatnce from any object and allow user create standard selections...

Share this post


Link to post
5 hours ago, bezo said:

Nice solution...

Fir this kind of selections I use xspolyinstance or ToPoly plugins which do the same. Create polyinsatnce from any object and allow user create standard selections...

Unfortunately, best I can tell, the xs* series of tools is pretty much dead in the water support and update wise, since their author, xs yann (and his web site) are long gone. With regard to the ToPoly plugin, I could not find it, but maybe I was searching for the wrong keywords, so if you can reply with a link to it, I'd appreciate it.

 

I want to look over the purchasable options and compare them to what I have written so far.

 

 

Share this post


Link to post

So, here is the same idea re-implemented (presumably) using the same technique and mechanisms that XS Yann employed for his (purchasable) xsPolyinstance plugin, the difference being that I have the source code since I wrote it, fields work just fine to allow parametric (more complex and topology independent) selections to be made, and I can add to and extend the feature set as fresh ideas pour in. Also, I am willing to share the resulting python source code which is well commented,  explaining what it does and why it does it.

The way this mechanism works is by using a Python tag on the Materialized Object (an empty Null materialized into an empty (i.e., devoid of points/edges/polygons) Polygon Object) to which the topology (points, edges, and polygons) of a (materialized) Parametric Group are transferred. The source object is linked to this tag via one of its User Data properties (i.e., Object to Materialize), as can be seen in the following screenshot of said properties.

ParametrigGroupMaterializerTag.png.bd07537e1624e68f82538f27c11710bb.png

Changes to the topology of the objects in the parametric group are immediately reflected in the materialized rendition of those objects, with textures reapplied accordingly (per the volume field characteristics of the transparent volumes shown in the following image). Also, it works just fine in C4D S22 as an added bonus:

 

UsingATagToMaterialize.thumb.png.d9cae6bab69f593e6633c50fa43c915a.png

 

Michael

 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
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.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...