- Home /
Add "burn marks" on hit directly to a texture using pixel coordinates
Hey guys,
I'm working on a school project, and I'm having some trouble getting some of the final touches done.
We were using textured planes to apply bullet and burn marks to things, but frankly it just doesn't look very good, and get's expensive pretty quickly.
I've read as much as I can about getting a UV coordinate from a raycast, but I haven't found any examples in C#, so I'm not quite sure how to proceed. Can anyone point me in the right direction or provide any tips?
I found this example, and although I can read JS pretty well, I'm not entirely certain what's going on: http://unity3d.com/support/documentation/ScriptReference/RaycastHit-textureCoord.html
For one thing, that'll paint individual pixels, and I want to load a bullet texture in. How do I do that? What should it (the texture) look like - will it be full colour? What about transparency?
Any help would be appreciated!
Thanks,
Fred
it just doesn't look very good, and get's expensive pretty quickly
Can we have a screenshot to know exactly which effect you do not want to get ?
Using geometry to apply decals is standard. (Naturally you don't want a separate gameobject for each one, ins$$anonymous$$d you use the $$anonymous$$esh class.) Trying to write directly to the textures won't work except for very small areas, because the entire area must be uniquely textured, which means 1) no tiling, therefore 2) large memory usage, especially since 3) no compressed textures and 4) they have to be set to read/write enabled, which means using both RA$$anonymous$$ and VRA$$anonymous$$. Plus uploading the changed textures is relatively slow.
Well, they can hang off the corners of objects for one thing. There's also sometimes a z-fighting issue, but I realize the position just needs to be played with.
It's also a whole plane laid on top of another object - a whole other gameobject, renderer, and transform.
Why doesn't anyone seem to know about the SetPixel? Am I crazy in trying to use it?
As I said, you don't use separate gameobjects. And yes, you're crazy trying to use SetPixel for this. ;)
Our game currently uses no tiling, and all of the characters use mesh colliders. The requirements of SetPixel are not an issue. It even suggests in the Unity Docs to consider using it for bullet marks and whatnot.
As far as I'm aware, the texture changes are made directly in memory, which is a reasonably faster operation.
I am also not familiar with what you mean by "ins$$anonymous$$d you use the mesh class", could you explain that? $$anonymous$$aybe that's my problem - because using planes looks terrible!
Your answer
Follow this Question
Related Questions
How do I select a sprite's pixel by mouse click? 1 Answer
getPixel co-ordinates not screen co-ordinates based on mouse position 2 Answers
How to pixelate an image texture for faster pixel color recognition? 2 Answers
Getting pixel color on ray hit 2 Answers
Can I get perfect 2d tile alignment using grid snap AND vertex snap on 1x1x1 unit cubes?? 2 Answers