Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
4
Question by Sam Shiels · Sep 14, 2010 at 11:05 AM · texture2dbakedecalsetpixelsgetpixels

Baking decals into a texture

Hi. I'm currently developing a top down 2d shooter in Unity that's mainly focused around decals (e.g splats, scorches etc). At the moment I'm using simple planes for each decal and, as you can imagine, a lot of them start to hinder performance (even when combined to one draw call).

Is the a method of baking them into the ground texture at any position using Texture2d.SetPixels and Texture2d.GetPixels?

Thanks.

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Julian-Glenn · Sep 14, 2010 at 03:31 PM 0
Share

SetPixels will just change the color of a block of pixels - so it won't work unless you just want a coloured blocky shape on your mesh. The method I see everyone use is the same: Instantiate("splatObject") followed by a timed (Destroy("splatObject")

avatar image Sam Shiels · Sep 14, 2010 at 04:50 PM 0
Share

Thanks for the reply. I've actually managed to duplicate a texture from one object to another using GetPixels and SetPixels (with alpha) and it looks perfect. So what I need to know is how to bake the decal at any position on the ground.

avatar image skovacs1 · Sep 15, 2010 at 06:09 PM 0
Share

If that's the case wouldn't something like texpix=tex.GetPixels();splatPix=splat.GetPixels();for(var i:int=0;jtex.width+startX+j](1-splatPix[j*splat.width+i].a)+splatPix[j*splat.width+i]*splatPix[j*splat.width+i].a;tex.SetPixels(texPix); do the trick? just decide where you want the splat, iterate through the texture and splat arrays, blending the values and then set the pixels to the blended values.

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by peacemaker · Nov 25, 2010 at 03:40 PM

If you are still having problems with this I came across a Unity Decal Framwork here:

(link removed)

Might be of use! Good luck :)

Edit: I added this link YEARS ago and it's just come to my attention that the original website has since shut down and been replaced by a spyware/spam site so I have removed the link.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Coltenney · Sep 21, 2015 at 07:48 PM 0
Share

The link goes to malicious page, I recommend it be changed or removed.

avatar image raxxillion · Sep 25, 2015 at 10:56 PM 0
Share

This is a link to spyware.

avatar image peacemaker · Nov 20, 2015 at 08:44 PM 0
Share

Thanks for pointing this out @Coltenney and @raxxilion. It was originally a nice framework but it seems it has since gone out of business so I have updated this.

avatar image
0

Answer by yoyo · Dec 03, 2010 at 07:18 PM

If you only need a limited number of decals per object you could potentially place them with additional texture inputs to a custom shader. Use a uv-transform (scale/offset) to place the decal on top of the base.

I once did a (non-Unity) demo project like this to make ants crawl across a face. Probably not the best solution (makes for expensive pixel shaders), but it's a neat technique.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by LawyerOfGod · Sep 11, 2014 at 09:46 PM

There is a way to bake decals shadows (only shadows) into lightmap..

1) Go to asset store and get "Simple Decals" (for free) and install it into your project 2) open the scene contained on the package you just installed 3) select one of the decals that are in scene, drag and drop it into the project folder (to create a prefab) 4) return to your scene where you want to put decals in, drag the prefab you have created into sene and adjust it to fit 5) mark the decal object as "static" on the property panel. 6) reduce the decal´s material alpha value to 25% (so the baked decal won´t look so bold) 7) bake scene ..

Shadows are B/W not textured..
this is good to make a dirty implementation on the scene.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

getPixel/setPixels or stencil eraser brush 2 Answers

Draw one texture on to another? Get Set Pixels. 0 Answers

Scramble GetPixels function... 1 Answer

Changing color of Texture2d with transparency 1 Answer

Resetting a Material's Texture After GetPixels/SetPixels 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges