Hi everybody, I’m a big fan of Omniverse and the Material Definition Language and I could really use some help!
I’ve created a custom MDL for projecting a decal onto an object and it works pretty well except there is a problem where part of the object, which has the projected material attached, is visible when it shouldn’t be. To describe what it looks like, it’s almost as if the shadow of the projected material is visible on the inside of the object. It’s difficult to describe, but I have attached a USD so you can view it yourself. This “shadow” of the material really shouldn’t be visible. I have colored every location which is supposed to be completely transparent in red and, as is shown in the USD file, the “shadow” is showing up red.
I am new to MDL and I suspect I have done something incorrectly in my MDL, I’d really appreciate insight into why this is happening, and how I can fix it.
Thanks for the post, and thanks for the file. Yes this seems normal. The “red” version is the inverse of the texture on the inside face of the cube. The top version is the “positive” face and the red version is the inverted normal of the bottom face of the cube. To solve this, simply apply this mdl to a simple plane and make that the texture. Then bring the plane down on to the top of another plane or cube and you will have a “sticker” effect. You may want to then select the sticker plane and turn off shadows for it, so it does not cast shadows on the cube.
But just for clarification this is not really a “projected” material. It is just a normal mdl using a PNG texture with alpha as a transparency map.
Thanks for getting back to me and Happy Holidays! Sorry for the late response; I was taking some time off. To provide some context, I’m trying to apply a decal to any mesh and the box is just an example. The way I intend to use it is to create a duplicate mesh and slightly expand it and then project the material onto that from different angles and locations. For opaque objects, seeing the negative side doesn’t seem to be much of a problem, but if I need to deal with a transparent object, I’m worried that it will become problematic. Are there any solutions you can think of? I really appreciate it, I’ve been trying to crack this for some time now.
P.S. Could you clarify what you mean by this not being a projected material? I’m new to MDL.
If you want to try to make a decal material in MDL without any geometry trick, go to your material Graph and add a “Simple Sticker” node. This will achieve the same idea, in one mdl without needing to do a “geometry trick”. That copy and offset scale is going to cause major issues down the road.
Thanks for the advice! Unfortunately, I’m trying to automate decals being applied, so using the material graph GUI isn’t going to work. Additionally, I’m using the “geometry trick” of duplicating and scaling the mesh so that I can segment the decal differently from the rest of the base mesh. It’s certainly not the cleanest solution, but I suppose I’m not experienced enough to see how it would cause problems in the future. I would be happy to change my approach and would appreciate it if you could provide some examples of the difficulties I might face by using this trick.
Taking a step back, though, I have a question about the MDL file itself. On line 48, final_color is set to red only if in_projection is false. Then, on the next line, show_surface is set to false if in_projection is false. Finally, on line 55, I set the cutout_opacity parameter to be 0.0 if show_surface is false. If I understand correctly, this means that the only way the surface can appear red is for the cutout opacity to be set to 0, making the object transparent at that location. Perhaps I’m thinking about this incorrectly, and please let me know if that is the case, but it seems to me that it should be entirely impossible for the object to be both red and visible at the same position even though that’s exactly what is happening. Am I misunderstanding something about the code?
We did manage to resolve the issue outside of this forum. The solution turned out to be setting the singleSided attribute of the mesh to true and turning on the “/rtx/hydra/faceCulling/enabled” Carb setting.