-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Weird issue with one area of texture not being painted #7
Comments
Oh that's really weird, I have a few guesses:
Out of all these guesses, I'd wager that the UV2 has something wrong with it. You mentioned that you tried switching it to uv1 and it had the same problem, though uv1s can be overlapping and off the 0 to 1 UV plane which can cause lots of problems. |
To investigate further, I'd probably need to get my hands on the model! |
Hey, I don't want to upload the model directly but if you do want to take a look it's a free asset on the asset store and I didn't make any modification except to switch on lightmap uvs, and add a DecalableLit material. But I also tried with a completely different model and had basically the same problem still. Maybe I'm doing something wrong with the way I'm using the decal system? Or might be something specific to the built-in render pipeline? I'll see if I can reproduce this in HDRP, once i figure out how to set that up. Asset: https://assetstore.unity.com/packages/3d/characters/creatures/character-monster-1-76640 |
Oh yeah, and I tried messing with the lightmap settings like you suggested, but no luck. Tried changing the projection depth as well and no result. |
Could I see the code that you use to draw the decal? |
Sure:
The collision is between a SphereCollider (bullet) and a BoxCollider (body). |
As for the seams, there's a variety of solutions that can be made for it, a very detailed video that has a very similar approach has good solutions for you here: https://youtu.be/c7HBxBfCsas?t=163 I already use conservative rasterization when possible, though even with it-- there seems to always be a seam or two. |
OK, I made a little progress on figuring this out. In my original scene the camera view was being rendered into a rendertexture which was then being rendered on a different camera (if that makes sense). That seems to be what's causing the problem, I assume due to some kind of screen-space calculations in DecalProjector? I don't really know. |
Actually for my case I can just work around it by avoiding rendering into a rendertexture. But would be cool if there was a way to do use rendertextures without breaking the decal system. |
That sounds very strange! The decal system automatically creates and manages its own render textures. It also will magically delete them when memory constraints are reached. It also manually renders to them using command buffers, so no cameras should actually be involved. I'm very confused |
Ooh I see. That's really strange that it causes a problem. I would think it wouldn't since the command buffers should be all self contained. Since it does cause a problem I must be using a variable in the shader that unintentionally comes from an active camera. I'll try to look into it. However, a quick fix on your end would be for you to do some proper post-processing/procedurals/command buffers rather than pointing cameras at quads. Though I understand that's a big ask. Sorry! |
Hey thank you so much for creating this package and publishing the source!
![Screen Shot 2022-01-20 at 12 25 24 PM](https://user-images.githubusercontent.com/8207025/150390733-fb3463aa-d6ba-4898-ac96-17ea1fd1ddb9.png)
I am trying to use it for painting bullet holes on a humanoid ragdoll and it is working great, except for this strange thing where the decals don't apply to one segment of the model (made the decals huge here to make it obvious):
As you can see there's this portion of the model along the figure's left side that doesn't get painted at all. The other side of the model gets painted fine.
Here's the DecalColorMap where you can clearly see that weird hard edge in the lower right:
![Screen Shot 2022-01-20 at 12 40 37 PM](https://user-images.githubusercontent.com/8207025/150392694-9fb9a96f-8884-4976-ac91-18010049e492.png)
It looks like that edge aligns with edges of tris in the model:
![Screen Shot 2022-01-20 at 12 27 25 PM](https://user-images.githubusercontent.com/8207025/150391218-83fdf67b-15bd-4f39-9068-ce6d9cd936ed.png)
But I have no idea why that particular region wouldn't be painted.
I set up everything according to the instructions (I'm using the built-in pipeline), I switched on lightmap generation to generate the UV2, and the decal textures are set to 'clamp' and mipmaps disabled. I thought there might be some problem with the auto-generated lightmap UV, so I also tried adjusting the shader to use the original UV1 for the decal normal map but it has exactly the same behavior, even though that hard edge doesn't correspond to a seam in the UV map.
I've also tried messing with the position and rotation of the decal projection (e.g. projecting it straight-on to those faces), but it seems to make no difference.
Do you have any idea what might be causing this? Any idea what I could try to debug it further? I've run out of ideas and I'm not good enough with shader programming to dig into the DecalProjector.shader code.
Thank you, any help is much appreciated!
The text was updated successfully, but these errors were encountered: