|
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
(comments are locked)
|
|
Could you use Projector instead of working with Texture2D.SetPixel()? With a Projector you can:
I looked into using the projector, but I couldn't get it to work. If you could shed some light on it, I would appreciate it however. I was using it to leave bootprints in the terrain, but my texture would stretch into infinity. Any idea why? Also, I heard that using projectors on such a large scale would be expensive, whereas using SetPixel is "free". Thanks for the response!
Mar 19 '12 at 02:22 AM
Redlazer
I will investigate further on the performance problem tomorrow (too tired now haha XD). Concerning the stretching, did you check the projector direction? EDIT : Oh, and please use the "add new comment" button to comment an answer. Comments and Answers are two different concepts on this website. ^^'
Mar 19 '12 at 02:43 AM
Dakwamine
I grabbed the drop-shadow projector prefab, and swapped out the shadow texture with a boot-texture (in black and white). The texture would either repeat vertically into infinity, or in all directions into infinity. I imagine there must be special requirements for a texture used in this case then - do you know what they are? Thanks again!
Mar 19 '12 at 03:07 AM
Redlazer
(comments are locked)
|

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, instead you use the Mesh 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 RAM and VRAM. 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 "instead you use the mesh class", could you explain that? Maybe that's my problem - because using planes looks terrible!