- Home /
Fastest way to combine two textures.
coming from an XNA and Flash background I'm used to having surfaces to copy images too.
What I want to ask is what's the fastest way to combine one texture with another? The equivalent of copying a rectangular area of pixels of one texture with a drawing surface?
I.e.
public void CombineTextures(Rect srcArea,Texture2D src,int destX,int destY,Texture2D dest);
I don't like using planes for 2D stuff, as camera zooming tends to lead to artifacts such as wobbly edges.
I've already looked up and tried using: texture2d.GetPixels/texture2d.SetPixels/Apply() The problem was that Apply() runs too slowly. Even if it's called once each frame on a 1024*1024 texture (power of 2 uncompressed).
I remember hearing shaders mentioned occasionally as a possible solution. If so how would I write a shader to do just that?
Please help this issue, has really been driving me mad the past two days.
Answer by tomekkie2 · Jan 06, 2013 at 08:14 AM
The Decal shader does that. You can modify the shader's code to change the way how it combines or add more textures into that.
I was also using CombineTextures in some projects, but only once at start or just after loading the new texture at runtime and that worked well.
I think it is better to get done by shader if you need that each frame.
Your answer
![](https://koobas.hobune.stream/wayback/20220613090502im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
shaders question (3DS Max involved) 0 Answers
Generating Textures in Shaders? 1 Answer
RenderTexture being wiped/changed on play or undo. 0 Answers
Weird shader dark spots when using normal maps 0 Answers
Texture distortion at poles on sphere - projecting texture on the inside of the spehre 0 Answers