x


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

more ▼

asked Mar 18 '12 at 10:17 PM

Redlazer gravatar image

Redlazer
61 7 9 12

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 ?

Mar 19 '12 at 02:34 AM Dakwamine

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.

Mar 19 '12 at 03:08 AM Eric5h5

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?

Mar 19 '12 at 03:10 AM Redlazer

As I said, you don't use separate gameobjects. And yes, you're crazy trying to use SetPixel for this. ;)

Mar 19 '12 at 03:14 AM Eric5h5

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!

Mar 19 '12 at 03:14 AM Redlazer
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Could you use Projector instead of working with Texture2D.SetPixel()?

With a Projector you can:

  • Create shadows.
  • Make a real world projector on a tripod with another Camera that films some other part of the world using a Render Texture.
  • Create bullet marks.
  • Funky lighting effects.
more ▼

answered Mar 19 '12 at 01:01 AM

Dakwamine gravatar image

Dakwamine
534 4 7 10

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)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x83
x22
x15

asked: Mar 18 '12 at 10:17 PM

Seen: 882 times

Last Updated: Mar 19 '12 at 01:19 PM