- Home /
Is it possible to draw on a texture lines, shapes and have a transparency mask like DirectX 2d or Open GL 2d does?
Hello, I want to port my drawing engine to Unity. I have a major drawing app on Windows 10 with over half a million users. The drawing engine is written in DirectX 2D with C++. Basically drawing on a texture. I would love to port it to Unity as I am now a Unity master as well! I am trying to decide between Xamarin or Unity as I am only 1 person and I cannot program for each platform. Xamarin does what I need with Open GL but I would rather use Unity if I can.
Is it possible to draw on a texture lines, rectangles, ellipses and have a transparency mask like DirectX 2d or Open GL 2d does?
Thanks
The question is a bit vague. What do you mean by transparency mask? By "DirectX 2d" you mean DirectDraw? Open GL always was a 3d framework which of course can be used equally for 2d. Though OpenGL doesn't have any dedicated shape drawing functions so i'm not sure what you mean. Can you be more clear about what exact functionality you're after?
Actually I mean the Direct2D portion of DirectX on Windows UWP apps. With it I can create a bitmap then draw to that bitmap; lines, splines, rectangles, ellipses, polygons, other bitmaps at different alpha levels. I can then apply an opacity (alpha) mask, of the same type of objects but in 8 bit, over that before it is rendered as a 32 bit bitmap. Basically it is a texture/bitmap that is being drawn to.
From what I looked into in OpenGL it has similar features but is organized in command format.
Thanks
Answer by Bunny83 · Mar 29, 2018 at 11:01 PM
Well, I'm still not sure what exactly you mean, however a texture can have an alpha channel which can be used to do alpha blending in a shader. It's usually used for transparency and masking. Unity doesn't have any "functions" to draw lines, rectangle or ellipse shapes, though OpenGL doesn't have them either. You have to create/ draw an actual mesh. Of course those can be procedurally generated. Using appropriate shaders, vertex colors, texture coordinates and textures you can do everything you want.
A camera can be rendered into a RenderTexture. You can also use Graphics.Blit and other low level rendering commands to combine textures on top of each other using a specific shader.
If you need further help you have to get much more concrete about what you want to do. Keep in mind that Unity is a game engine. It uses either DirectX or OpenGL for the lowlevel rendering stuff but it's generally not meant for pure image composition or image editing. However that doesn't mean you can't create the next Photoshop in Unity. It's possible if you invest enough time.
Your answer
Follow this Question
Related Questions
Do I need DirectX? 1 Answer
How does Texture2D.CreateExternalTexture work? 1 Answer
No Realtime Lighting on Build in OpenGL 0 Answers
Ripped model requires skinned mesh 1 Answer
DirectX screwing all this up? 1 Answer