🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Prerendering texture in Unity

Started by
5 comments, last by lawnjelly 6 years, 1 month ago

Hi there unity folks, I want to pre-render a biggish (1024x1024 something like that?) terrain texture by splatting some terrain textures on top of each other with alpha blending (mud grass rock etc). This would be a cinch normally in c++ / opengl etc as I could use software rendering, render to texture etc, however I have no idea the best way of coercing Unity to achieve this, as I haven't managed to google anyone using this basic technique.

I'm guessing there is someway to upload texture data to a texture in Unity, will blending it in software be too slow in C# (this is just a one off loading the level)? Or is it practical to get a camera setup and edit the geometry data to get some kind of alpha blending going on with render to texture? I'm pretty sure getting a camera would be fastest performance, but I need something quick to get going and non-fiddly as I don't want to spend very long on it, so I'm happy to use software rendering. Does anyone have any ideas on best way to achieve this?

Advertisement

I think the developers of Unity wanted people to use the terrain paint tools for this, so I don't think there is just a normal way of doing it if you don't use there tool.

You could achieve the same thing with a custom shader.

Am currently going to try with this:

https://docs.unity3d.com/ScriptReference/Texture2D.SetPixels.html

I think it should work just a question of how slow, if I can get unity to read a png into an array instead of a full blown unity texture. 

terraintex.jpg.99178632c07d79e34ccb24a857208c93.jpg

Got it working with GetPixels and SetPixels on the Texture2D. It's a little slow but bearable. Again am finding this C# incredibly painful to debug. I actually found that not only does Debug.Log crash the Unity editor when called lots of times, but even Debug.Assert crashes the editor even if the asserts don't trip. Astounding.

11 minutes ago, lawnjelly said:

Again am finding this C# incredibly painful to debug.

I agree that debugging isn't as smooth as it could be. In Fact I find that debugging in Unity is more stable with the Print() instead of Debug.Log.

It's something I really don't like because commenting out //Debug.Log() tells other programmers why it is there where //Print() just looks like some random print function.

 

Have you upgrades to Unity 2018 yet? It is more stable and faster than the old versions. Unreal is also a option, then at least you get to keep C++.

I will try and upgrade once I finish the tower defence challenge .. it was a little more involved as I am using unity on linux and I don't know how officially it is supported (I suppose it is good that it works at all though!). It may be worth me trying something different for rapid development like unreal or perhaps a non drag and drop c++ engine. I have used various third party c++ engines in the past.

I can see having everything drag and drop in an editor is great for non-programmers and pre-pubescents but it's just a gigantic pain in the ass for me personally. And don't even get me started on the abomination that is c#, I'd be happy to never be exposed to that pile of **** again, give me a proper language and IDE any day (I'd honestly prefer to write in assembly!!). And the issue of build size bloat is another issue, I have yet to find out how possible this will be to address.

This topic is closed to new replies.

Advertisement