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
1
Question by Ray-Pendergraph · Jun 23, 2010 at 05:36 PM · shadertexturemap

Rendering oval map texture with Graphics.DrawTexture()

For a mini map, we are using a static image rather than a live, overhead camera. The map's texture is either pieced together from snapped images of an overhead texture (taking snapshots of the immediate tiles around the character) or a stylistically enhanced version of the terrain's features.

Either way, we have a map Texture2D that represents the terrain. The mini map is currently a panning square at the top left of the screen. I pan the map texture by only drawing a portion of the whole map texture with the Graphics.DrawTexture(...), always centering on the player. This all works (just giving some background).

Now it's required that the map not be a square. I have seen a couple of places on answers where people are culling live cameras like here., but I have a texture. I have applied a culling shader (mask) by passing a material into Graphics.DrawTexture. As you would expect, this applies the shader to the underlying texture, not what is rendered in the viewport.

  • Is there a clever way to do this with the Graphics.DrawTexture() call or am I going to have to Get/Set pixel the area that I want in the map into a texture and then draw that with the shader?
  • Does all this sound insane and there a much easier way to approach handling the map texture?

Edit[6/24]: Since I was already calculating all the offsets for a panned view over the map texture, manually copying the viewport sized pixel block from the main texture to the veiwport texture was not a problem. Then I could post process it with a shader that does a few things to the texture. Seems like this pixel yanking must be basically what's happening in the DrawTexture call anyway.

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
2
Best Answer

Answer by Tetrad · Jun 23, 2010 at 06:25 PM

Why not just put the material on an oval piece of geometry and let the system draw it itself instead of you drawing it by hand? You'll probably have to do some math to figure out what the correct UV offsets are, but it'll be a lot more flexible. You'll also probably want a special non-fogged, non-lit shader. Probably on a separate layer rendered with a different camera.

Comment
Add comment · Show 1 · 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 Ray-Pendergraph · Jun 24, 2010 at 04:45 PM 0
Share

Thanks for the answer. That's that's an interesting idea. I actually went the way I was leaning in the original post but this has given me some interesting ideas for some other stuff that we are doing.

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

No one has followed this question yet.

Related Questions

Assigning UV Map to model at runtime 0 Answers

Shader Texture Change 3 Answers

How to apply different textures to one model? 1 Answer

apply a map to a surface shader using its original size and tiling 0 Answers

How to use a displacement map to create a ripple effect on a texture? 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