- Home /
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.
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.
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
![](https://koobas.hobune.stream/wayback/20220613062841im_/https://answers.unity.com/themes/thub/images/avi.jpg)