Can we do Decals/Stencils with Karma XPU?

   Views 630   Replies 5   Subscribers 2
User Avatar
Member
479 posts
Joined: Feb. 2013
Offline
Scenario:
Imagine you have a mesh of a wall with its own uvs and material. The wall material is set up to be tiling, takes advantage of vertex colors and so on.
Now imagine you want to put Graffiti on the wall. The Graffiti paint material has it's uv UV layout.

I want to project the Graffiti material with an alpha cutout onto the wall. And I want it to look like actual paint, so it has to be completely and tightly stuck on the underlying geo.

This: https://www.sidefx.com/docs/houdini/nodes/sop/labs--decal_projector.html [www.sidefx.com] kinda works, but it's relatively clumsy because there will be always a tiny offset from the underlying geo.

How would I do either of the following:
I have used stencil projectors (sometimes called magic lights. For this sort of thing. It basically projects a second (virtual) uv set onto the geo and layers the material on top of the other, reusing underlying properties like normals, but also layering more information on top.
Alternatively, I could use a second uv set for the wall mesh and sample the Graffiti textures based on the second UV set and layer it in a custom material.
User Avatar
Member
23 posts
Joined: May 2010
Offline
There's an approach here using COPS
https://www.youtube.com/watch?v=c1jupIDfQ_I [www.youtube.com]
User Avatar
Member
616 posts
Joined: Aug. 2014
Offline
bender83
There's an approach here using COPS
https://www.youtube.com/watch?v=c1jupIDfQ_I [www.youtube.com]
The title of this video is misleading, because the video demonstrates a workflow for stamp painting. Not projecting decals.

DASD
This: https://www.sidefx.com/docs/houdini/nodes/sop/labs--decal_projector.html [www.sidefx.com] kinda works, but it's relatively clumsy because there will be always a tiny offset from the underlying geo.

Labs decal projector works well, but you need to remember to set appropriately low floating distance and to make decal primitives invisible to shadow rays in render geometry settings, so that the decal doesn't project shadow on the surface it's attached to. This two things combined make the gap virtually invisible, even at low camera angles and on extreme close ups.

Attachments:
decal.jpg (54.2 KB)
decal2.jpg (47.1 KB)

User Avatar
Member
324 posts
Joined: Aug. 2018
Offline
For most decals I would just generate an additional uv set and import and use that uv in Matlx via a 'MtlxGeomPropValue' LOP - Geomprop: uv2; Signature: Vector2. Pipe that into MtlxPlace2D if you want to adjust place / scale / rotation in Solaris, and then into MtlxImage : texcoord.
Edited by Mike_A - March 20, 2025 17:51:38
User Avatar
Member
10 posts
Joined: Sept. 2021
Offline
DASD
Scenario:
Imagine you have a mesh of a wall with its own uvs and material. The wall material is set up to be tiling, takes advantage of vertex colors and so on.
Now imagine you want to put Graffiti on the wall. The Graffiti paint material has it's uv UV layout.

I want to project the Graffiti material with an alpha cutout onto the wall. And I want it to look like actual paint, so it has to be completely and tightly stuck on the underlying geo.

This: https://www.sidefx.com/docs/houdini/nodes/sop/labs--decal_projector.html [www.sidefx.com] kinda works, but it's relatively clumsy because there will be always a tiny offset from the underlying geo.

How would I do either of the following:
I have used stencil projectors (sometimes called magic lights. For this sort of thing. It basically projects a second (virtual) uv set onto the geo and layers the material on top of the other, reusing underlying properties like normals, but also layering more information on top.
Alternatively, I could use a second uv set for the wall mesh and sample the Graffiti textures based on the second UV set and layer it in a custom material.

DASD
Scenario:
Imagine you have a mesh of a wall with its own uvs and material. The wall material is set up to be tiling, takes advantage of vertex colors and so on.
Now imagine you want to put Graffiti on the wall. The Graffiti paint material has it's uv UV layout.

I want to project the Graffiti material with an alpha cutout onto the wall. And I want it to look like actual paint, so it has to be completely and tightly stuck on the underlying geo.

This: https://www.sidefx.com/docs/houdini/nodes/sop/labs--decal_projector.html [www.sidefx.com] kinda works, but it's relatively clumsy because there will be always a tiny offset from the underlying geo.

How would I do either of the following:
I have used stencil projectors (sometimes called magic lights. For this sort of thing. It basically projects a second (virtual) uv set onto the geo and layers the material on top of the other, reusing underlying properties like normals, but also layering more information on top.
Alternatively, I could use a second uv set for the wall mesh and sample the Graffiti textures based on the second UV set and layer it in a custom material.

I was doing it in VEX.
Beauty of VEX shaders is that you can use functions like intersect, xyzdist, primuv inside shader.
On one recent project we had huge environment for Jerusalem. For roads we generated bunch of curves, created polystrips from them and sampled these curves directly in shader, so texture of road was nicely repeated on terrain, nicely blending with existing terrain texture under.

I will have lecture on that on CGA belgrade on 10. and 11. april. Also I developed texture structs inside my shaders. So for example, you have diffuse, roughness, displacement textures, and you want to composite them over another set of textures. You have to do it multiple times for each component (diffuse, roughness, disp...). Here you just put them in texture pack node, do your layering and unpack them and plug to shader.

I asked SideFX when these two features will be possible with materialx, they pointed me toward USD developement discussions which are more general then Houdini.
User Avatar
Member
9078 posts
Joined: July 2007
Offline
bogdana
I asked SideFX when these two features will be possible with materialx, they pointed me toward USD developement discussions which are more general then Houdini.
This may be the biggest issue that I keep struggling with, not particularly the geometry sampling which would be great, but giving up control to USD and MtlX with no in house solutions for most of what we can do in VEX shaders
I'm also used to power of VEX or even any shading language for that matter, but the fact that MtlX definition is very basic with no meaningful additions over the past few years and that Karma doesn't support OSL or MDL or even custom shading language just doesn't seem ideal, at least compared to most other GPU renderers which tend to support OSL
Edited by tamte - March 18, 2025 13:51:44
Tomas Slancik
FX Supervisor
Method Studios, NY
  • Quick Links