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
2
Question by roamcel · Jan 02, 2012 at 01:53 PM · shadermeshsurfacedecalprojection

Project vertices on surface, make a shape

Hi all,

I am trying to implement a sort of decal system for projecting very simple 2d figures onto other surfaces. If I understand correctly, the most indicated way to do this is with rendertextures, but I don't have the Pro version, and I was looking for an alternative, even if it's resource intensive, inefficient, and whatnot, since performance is not an issue.

So let's think of a sample case: I have a mesh of a five pointed star, and I need to project that onto the terrain, from Vector3.Up

The "easy" part is raycasting all points down to ground, and actually "projecting" the mesh, but this is frequently a bad approach since projecting on a cone or other bumped surfaces will correctly deploy the vertices of the star, but the star's surface would not adapt to the geometry.

Sadly, projectors don't seem to accomodate a mesh as the cookie source, so I don't know which way to go from here.

I thought about shaders for a second, but I'm illiterate in the field so I don't really know what can be done in that direction.

Any advice is welcome.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Winterblood · Jan 02, 2012 at 02:34 PM

Presumably your mesh is going to deform in some unusual way? Because if it was just rotating and scaling you'd be able to make a star texture offline and rotate/scale the projector.

If it's deforming in a consistent way, and memory is no object, you could render off the deformation into a texture atlas and have the projector project the animation by adjusting the UVs.

Otherwise you may have to roll your own projector, but that will probably take days to do and weeks to iron the bugs out of :/

Comment
Add comment · Show 5 · 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 roamcel · Jan 02, 2012 at 02:45 PM 0
Share

It's not a matter of deformation, but rather the fact that the meshes are created on the fly, by the user. So there's no way to anticipate what will be created or how it will be painted into the surfaces.

avatar image Winterblood · Jan 02, 2012 at 05:21 PM 1
Share

In the absence of render-to-texture, you could manually rasterize the mesh to a texture one pixel at a time (see http://unity3d.com/support/documentation/ScriptReference/Texture2D.html). Slow but doable if you only update it when the user modifies the shape.

Depends on the use-case - if it's unlimited user-generated shapes projecting across a landscape for miles, it might be better to write your own projector and avoid using textures altogether.

avatar image roamcel · Jan 02, 2012 at 06:16 PM 0
Share

@Winterblood This could do, since once the shape is created, it won't change, but I have trouble figuring out HOW you're supposed to perform the process. I mean, I was hoping to find something similar to 'drawline' and 'fill' with the texture2d object, but there's nothing like that. Do you possibly know if this can be achieved by a shader in some manner?

avatar image Winterblood · Jan 02, 2012 at 10:16 PM 0
Share

Not that I'm aware of. Shaders only do per-vertex or per-pixel micro-calculations, not macro-level shape drawing.

A crude method would be to iterate through every pixel in the texture, do a "raycast" (or comparable test) to decide if it's inside or outside your shape, and colour it accordingly. Could do multisamples to reduce aliasing if necessary. That's the best I can suggest without knowing the parameters of the user-designed shape editor...

avatar image roamcel · Jan 03, 2012 at 11:35 AM 0
Share

You've been very helpful. Thanks.

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

Project a shape using a mesh 0 Answers

Mesh Decal System 0 Answers

Shader that only shows mesh at the point where it is colliding with terrain? (A projector?) 0 Answers

What is the best way of drawing/projecting dynamic trajectory on a ground surface 1 Answer

What is the best way to create realistic surfing waves? 0 Answers


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