Discussion in 'Assets and Asset Store' started by Dantus, Jun 29, 2012.
I'm using the Decal/Transparent Diffused shader
@Ken T: Hope you are aware that SkinnedDecals are not yet production ready. Though I made some updated to them. But I had to move on to Unity 4.x. I had too many problems because I tried to support both Unity 3.x and Unity 4.x.
Do you have a possibility to move to Unity 4?
The upgrade decision will mostly based on the feedback I get on Level 1 of my game.
This is extremely good for a free product, great work!
Would it be possible to use this system to enable self-illuminated decals? I'm working on a citybuilder and need a way to light up windows at night. During the day they will use the building UV texture but I don't want to create a seperate atlas for nighttime. I was thinking the buildings could have a decal placed over the windows and be 'activated' at night then hidden in the morning.
Naturally I would need to manage the enable-disable during runtime. I was thinking the decals would just be a basic self-illuminated texture. I could then loop the enabling/disabling to cycle through all the windows of the building and randomly toggling them over a couple seconds. This would give the impression that window lights wouldn't all turn on or off at once.
Let me know if this is doable. thanks.
I think this is doable! You basically need to have a self-illuminating decals shader for it. You can take the one from Unity and adjust it, if needed at all. That shader is the only missing part from my point of view.
If you want to turn on/off some lights, there are several solutions that come spontaneously to my mind:
- Use vertex colors to show/hide them (though it is needed that you are using one decal projector per window)
- Use another alpha texture to blend the self-illuminating areas in (slightly more complex shader is needed for that)
Hope this helps
Decal System 1.3 is now under review for the Asset Store. The release notes are already available: http://www.edelweissinteractive.com/2013/03/decal-system-1-3/
So I couldn't just deactivate a decal? I'd like to be able to cycle through all the window decals for any given building and turn them on/off as needed. The decals would just lay over the top of the building mesh at the window locations, one decal per lit-window. Just the basic self-illuminated shader will work fine I think, but I need a way to process the decals on a city and building level.
Basically a loop going through all buildings in a city with another loop for each of their window decals. Once all decals are processed the loop need not be processed again until the time engine that manages the day/night cycle fires an event telling the decals to be processed again.
You can also deactivate a whole decals instance. Just deactivate the game object and they will become invisible.
Decal System 1.3 is available. The asset store people are awesome!
I don't want to activate or deactivate all the decals at once, the lights in a city do not suddenly blink on everywhere at once. I need to be able to gradually turn them on.
Wow, this latest update (v1.3) COMPLETELY CRASHED my Unity (for the first time! Now do you feel special ).
While importing (when it is compiling the script) :
Type == kMetaAssetType pathName.find
I can't even open up my Unity Project now. Guess I need to externally delete this extension.
My setup : Macbook Pro 2010, OSX 10.6.8, Unity 3.5.7.
EDIT: My fault. I didn't read the changelog before upgrading (I rarely read changelog...)
Says right there :
Version 1.3 - Unity 4 required.
So just a heads up for anyone still staying with Unity 3.x - DO NOT UPGRADE to Decal Systemv1.3 !!!!!!
You can have one DS_Decals per building. Like that you can turn on/off the lights per building.
Wow! How could you download the newest version from Unity 3.x? I expected this is not possible! Maybe because you made an upgrade and didn't download it for the first time? In that case I would have to update the description!
Edit: I just checked my Unity 3.x and I am getting Needs Unity upgrade to version 4.0.1
Strange, I can download with no problem.
I was updating it from the download manager screen (which is how I normally update all my extensions ... and the reason why I rarely read changelog. I guess this will prompt me to read changelog more vigilantly).
Same here. I submitted a bug report: Case 532331
Hey Dantus. Thanks for the new release! I'll go ahead and reiterate my requests from last time, just for the record:
1) Is there a way to make the Decal Mesh Renderer un-selectable? So far if you want to select the object upon which a decal is projected you have to go hunt and click all over the object until you manage to find a spot where the decal mesh does not reach (which is not even possible if the decal mesh covers most of the object). The second option is to click on the object (which selects the decal mesh instead), then go to the Hierarchy panel, scroll up or down to locate the decal parent group, select that, go to the inspector to disable the group, and finally go back to the scene view to select the object you wanted to select in the first place. I hope you can agree that this is not exactly an optimal workflow.
2) It would be nice to get an additional Parallax Occlusion Mapping shader in the decals shaders choices, for times when a normal map alone just isn't enough.
I hope those suggestions can find their way in a future release...
I tried to make Decal Mesh Renderers unselectable, but without success. I couldn't find a way to make any mesh unselectable in Unity. If someone knows how to achieve that, I am open for suggestions.
You can easily create your own one if you need it. Just pick the one from Unity and adjust the line with the offset to:
Nearly all shaders were created like that.
Oh. That's a bummer about Unity not able to support unselectable meshes. And I guess it's not possible to make a layer type that would make its members unselectable. Oh well. As a makeshift solution I made myself a button in the editor that I can click to toggle the decal group's visibility.
Regarding the parallax shader for decals, I'm missing something here. I mean I already have a POM shader which works fine, but I though that decals only supported the material types listed in the "Projection" drop-down menu from the "Decals" tab of your UI. And since I don't see any choice for POM I thought I couldn't get POM. But you're saying I can create my own by replacing a line. Do you mean replacing a line in your code? Sorry, I'm confused...
And lastly, unfortunately the latest release seems broken in Unity 4.1 (at least on my machine). Everything worked fine before, but now all the decals have turned black:
Any idea where that could come from? Note that they were fine until I started moving one, which then turned black. And when I did a "Update Child Projectors" all of them turned black. That is, of course, a very, very big problem.
Would you know where I can download the previous version of the Decals System, please?
UPDATE: I think I found the culprit regarding the decals turning black; I used to use my own custom shader before, which was working fine in the previous Decals System version. But after testing your own shaders just now (in the Decals submenu) I can see the problem's gone! I think your changes/optimizations only exposed my crappy shader-coding skills. So I'd say it's a classic case of user error!
The Projection drop-down is there to tell how the mesh has to be created. There are some default presets for that make it as simple as possible. As you know, you can select which material has to be used for the decals visualization. For the material you can pick any shader you want. It is necessary that the selection you make in the Projection drop-down is correct for that shader.
Hope this helps
I've watched all of the videos and I'm very impressed with this system, but I'm wondering whether decals can be created dynamically with this system. I need to use a decal for bullet holes, so I will need to instantiate decals at runtime as most likely a prefab. Can this be done with this system?
When you download the Decal System, you can find several demo scenes. In all of them you can create decals at runtime. You can just walk around and click to create the decals.
Thanks for that, I kept walking around and clicking like mad but couldn't see anything, probably because I was clicking too far away. But it works brilliantly and I noticed each new decal doesn't increase the drawcall count, great stuff.
There was a huge demand for those scenes and I am aware that the way they work is not optimal. At the moment you should understand them as references for programmers, to help them understand all the different aspects.
I am glad you like it.
A decals object per building is closer to my goal, can I create an array of decals for a building and parse through them individually? An example would be a large commercial building, some lights will turn on right away and some may randomly come and go as the night progresses.
Or is the DS_Decals itself a collection of decals that I can already parse?
A DS_Decals can be seen a a collection of decal projectors. In an actual scene it is only a mesh. If you want to control each of those projectors separately, you have the two options I described in my first answer:
The shader solution is easier, because for the other one you would need to know which vertices belong to which decal projector.
Hi Dantus, I use your system to get some different ground textures and I was wondering if there is a way to detect which material (in this case which decal) the player is standing on... Thanks!
Could you be a little bit more specific with the question? There are tons of answers about how to find out on which mesh with which material a player is standing. So I expect you have trouble with a certain aspect in relation with the Decal System?
Sure: My player is made of a character controller. And I would like to detect the material under that controller so I can trigger footsteps sounds accordingly. But if I simply detect the mesh collider (using RaycastHit) under the controller and get the material from that, it will always return the same material (the one attached to the ground mesh, not the one from the decal mesh since it's not "solid").
So how do I detect the decal's material instead of the mesh collider's material upon which the decal is projected?
The only way to achieve it in general is with a tigger/collider for the decals. If you place a decals instance into a prefab, it automatically generates the mesh asset for it. You may use that one to create the tigger/collider.
I see, I'll try that then. Thanks!
I've been using this system for a while now, and I have to say I absolutely love it! However, I have noticed that it generates tons of .asset files in the root assets folder, which completely litters our project; considering the fact that we are using perforce for version control, this brings in problems with file management.
I have tried moving the .asset files to a folder we want them to be (along with the .meta files of course), but the plugin seems to still generate the .asset files.
So, I was wondering if it is possible to have the plugin refer to the location we want to reference the .asset files? If not, is there a way to do this in a scripted way, or maybe another solution?
Still a great system, this is really helping the project, so thanks very much for making this free
@MaVCArt: Welcome to the forums! Which version of Unity are you using and which version of the Decal System.
The asset files are only generated if you place the decals in a prefab. In fact they are needed. There was a bug in the previous version of the Decal System which should be resolved in the most recent one. Unfortunately, it only runs in for Unity 4.
Edit: The asset files can be placed wherever you want them, though I don't have time right now. Be assured that you get a more detailed answer once you gave me the version numbers.
hi, and thanks for replying so quickly!
my version numbers are Unity 4.1.2 (latest one), and the latest version of the decal system
I also have some more specific information, I.E. how to reproduce:
1 ) create and set up a decal system (with uv rectangle, material... all the normal stuff up to the point that it looks the way you want it to)
2 ) set the path for the prefab mesh to the appropriate folder
2 ) make the decal system a child of another game object
3 ) make that game object and all it's contents into a prefab (this is essential for us, it needs to happen this way)
4 ) delete the prefab instance in the scene
5 ) re-import the prefab instance (just put it back into the scene)
6 ) go down the game object hierarchy
7 ) click on a decal
at this point, the system creates an asset in the root assets folder, which is the problem i'm trying to solve / get solved - the path pointing to the decal mesh apparently doesn't get saved into the prefab, which is what I think goes wrong.
Unfortunately this is really really bad for us since we are putting in the prefabs using scripting, not manually. Even then, doing it manually would take much too long for us to do considering the amount of decals we are using.
also worth noting is that while it doesn't seem to remember the mesh path, it does not cause any trouble when the asset files are in fact left in the root assets folder, but I guess that's because they are referred there in the code itself, before the user sets the path he/she wants
We would sincerely appreciate it if you could help us find a solution to this problem, but considering prefabs tend to indeed lose parameters because of the way they work internally, we would understand if it's not immedeatly possible.
this all said, it's still an awesome system, and we are really really happy with it great work guys!
@MaVCArt: I tried to reproduce your problem with the Mesh Asset Folder, but I couldn't with the latest version of the Decal System from the Asset Store.
Which operating system are you using? I only tested it on Windows and no matter what I tried, the Mesh Asset Folder was preserved in the prefab. Could you make sure that you have version 1.3 or maybe import it again from the Asset Store. In the case that this issue still exists, you may reach me on Skype to show me exactly what you are doing to find the cause for the issue.
in the meantime I managed to get it to work - What must have gone wrong is that when updating the prefab, I lost prefab connection multiple times when adding or removing parts of it, and in so doing I may have lost the mesh asset folder connection.
otherwise it's working perfectly right now, so, no complaints whatsoever great system, and thanks again for the help!
What do you mean exactly with lost the mesh asset folder connection? The actual path should always be stored and not be reset to the root asset folder, even the the prefab connection is lost. Please let me know if that happens, because that would be a bug. The other behavior you report is as expected. It is the way prefabs work.
I am glad you got it working!
is it possible that the mesh asset path gets reset if you duplicate a decal system? that would make sense I think, and I did duplicate systems multiple times (systems, not projectors - they needed a different material)
I will test that. It is absolutely possible that this kind of scenario has side effects I am not yet aware of.
With the previous updates a lot of things happened in Unity regarding prefabs. I had to change quite some code to get it working with each version. I expect that Unity changes lots of internal stuff to prepare the integration of nested prefabs (just guessing).
Dantus, amazing plugin. Great usability and powerful features with great documentation. Thank you so much for putting something like this together and releasing it for free.
I was trying to conceive of how one would implement it so that if you say, shot a gun, at different materials in the world, that the appropriate material of decal would appear.
For example, you have a large level that has walls, floors, and static furniture such as tables. As you run through the level, as you shoot different surfaces such as the table, then a wood decal would show. Or if you shot a metal cabinet, then a metal decal would show. I thought of several different ways this could maybe be implemented but I wanted to hear your thoughts before committing any ideas to code.
If you were to implement that type of system for static objects, what would be your basic setup? Would you create a DS_Decals instance for every single decal type in Start()? And then depending on what material is on the object you shot, apply a projector to that particular DS_Decals instance? Or would you change the decal material at runtime as you detect the different surfaces that you're hitting? Or would you differentiate the different UV's by name, and depending on the material hit, use different decal UV's. Or something totally different? My project only has 6 different decal types (e.g. wood, metal, glass, earth, concrete, generic). I figure this number may influence the type of implementation that works best.
Looking forward to hearing your thoughts.
@justinl: The decision whether you want to use one or more DS_Decals instances depends on several factors. If you want to use the normals of the target surface, you may even have to use one DS_Decals instance per projector or a DS_Decals instance per target surface. A similar solution would be needed if the decals have to take lightmaps into account. But I have the impression that you are not looking for such a complex solution.
From a performance point of view the best solution is to use only one DS_Decals instance as long as only one mesh is generated with it. That depends on the number of projectors that have to be created and the target mesh complexities (number of vertices that are affected by the decals). So the decision is extremely project dependent.
Hope this helps.
Thanks Dantus. That's helpful. I'm curious why I would need to use one DS_Decal instance per projector if I want to use the normals of the target surface.
Also, as a follow up, is having 50-100 DS_Decal instances going to kill my performance (f each DS_Decal instance only had 1 projector on it because I'm using it for bullet holes and nothing else really)? Or is that an acceptable amount in your experience.
I meant the normal map of the target surface. In that case you need it, because the normal map of the hit object is a texture that you have to reuse for your decal material. And those bump textures obviously vary from object to object.
Try it out. That depends on your project. If you can avoid it, I would suggest you to do so, but it may even work with one projector per DS_Decals instance. But as I wrote this is usually only needed of you want take the lightmap or (this time correct) the bump map of the target objects.
Keep in mind, decals are expensive when you add a projector. But once it is there, it is noting else than a mesh with a transparent shader. The question for you would be if it kills your performance if you have 50-100 additional transparent meshes in the scene.
Okay that's prefect. I think I have a good understanding of how to tackle this after your messages. I'll probably implement something where when I shoot a wall (or any object), I'll check to see if there's already a DS_Decal instance for that mesh. If there isn't one, I'll generate one and if there's already a DS_Decal instance for the mesh, then I'll just add another projector to it. So unless the user is shooting only 1 bullet at 50-100 different meshes, then that's the only time where there would actually be that many DS_Decal instances. Otherwise we'll be re-using the DS_Decal instances.
Thank you so much, you've given me the information I need to implement something more confidently!
I totally forgot: Hopefully you already checked the demo scenes, because there is quite some example code.
Yes I have looked through the demo scenes. These examples are invaluable Thanks!
Is it possible to attain this functionality through an editor script? I can't find anything on a generic way to trigger a button in the editor GUI through code, so is there anyway you could post code that / explain how to implement this functionality? I'm having a similar problem where even though I'm following the examples (and experimenting with the code to try to get it to work), the decal meshes aren't created / don't appear until the "Update All Projectors" button is pressed.
Edit: I noticed there's an "IsActiveProjector" boolean on the projectors in script, and it's set to false (read-only). Alternatively, is there a way to set this to active so the decal meshes are created?
Hi Dantus, quick question: I'm doing decals for a window right now and I'd like to be able to see the bullet hole decal from both sides of the glass. This is easy to do if it's a manually placed decal because I just move the projector box through the glass, however, I can't seem to do the same when the decal is placed via script. I tried increasing the Y value of the decal projector scale, and also increased the cullingAngle to 180 but nothing still shows on the other side of the glass. Any thoughts?
In which situation do you need this functionality? Usually there should be other, better ways to achieve that. Do you need it in the editor or at runtime?
"IsActiveProjector" is true for the last projector in the decals mesh. If mesh data is added and the cutting has to be performed, this active projector's information is used for the generation. If you want that a decals mesh is shown, you have to call:
The demo scenes contain several examples with runtime code, in the case you haven't checked them yet.