Thursday, July 14, 2022
HomeGame DevelopmentUnity terrain particulars have transparency in editor, however are on black in...

Unity terrain particulars have transparency in editor, however are on black in builds


I am coping with a regarding bug in my Unity construct.

I’ve a terrain system which populates its element layer with procedural grass textures. The textures are on transparency within the editor, as they need to be.

grass in-editor

Nonetheless, after a construct (and I’ve tried each OpenGL and Vulkan) all the transparency is changed with matte black.

grass in-build

As you may see, the one factor affected is textures; the meshes of the timber and flowers behave usually.

That is clearly a extremely large drawback for me. It is particularly taking place on the Linux platform, however I am doubting that that’s related right here. I’ve reported it as a bug, however does anybody else who understands terrain particulars have a possible answer for me?

I’m presently utilizing the LTS construct (2021.3.1f LTS). I will strive a more moderen model of the identical construct, however that first load takes time…

ADDENDUM: I attempted 2021.3.6f LTS and acquired the identical consequence; however then I tried so as to add painted-on grass as a substitute of simply utilizing the procedurally generated stuff. I acquired the transparency within the construct! This leads me to consider that there could also be a setting that’s getting mechanically toggled for the editor, however not for the construct?

To make clear, my code for including the grass is thus:

                //element mesh technology
                DetailPrototype flower = new DetailPrototype();
                flower.useInstancing = true;
                flower.usePrototypeMesh = true;
                flower.renderMode = DetailRenderMode.VertexLit;
                flower.prototype = Assets.Load<GameObject>("flower.02");
                
                //element texture technology
                DetailPrototype grass = new DetailPrototype();
                grass.prototypeTexture = Assets.Load<Texture2D>("Grass"); 
                 
                _data.detailPrototypes = new DetailPrototype[]{
                    grass,
                    flower
                    };
                
                //generate discipline for element mesh
                int[] grassMap = flattenDetails(_data.GetDetailLayer(0, 0, _data.detailWidth, _data.detailHeight, 0));
                int[] flowerMap = flattenDetails(_data.GetDetailLayer(0, 0, _data.detailWidth, _data.detailHeight, 1));

                //plan: Create a grid array that matches every level on the map to plant maturity/well being. Use this to generate grass and
                //flower distribution. Lastly, masks with dotted slope regular.
                float[] fertility = new float[_data.detailWidth * _data.detailHeight];
                float totalFertility = 0f;
                
                float scale = 100.0f;
                float origin_x = rework.place.x / _data.measurement.x;
                float origin_z = rework.place.z / _data.measurement.z;
                float row_width = _data.detailWidth;
                float row_height = grassMap.Size/_data.detailHeight;
                int index = 0;
                for(int z = 0; z < row_height; z++) {
                    for(int x = 0; x < row_width; x++) {
                        index = z * _data.detailWidth + x;
                        //grassMap[z * _data.detailWidth + x] = (int)(Mathf.PerlinNoise(origin_x + x/row_width, origin_z + z/row_height) * 12f);
                        
                        fertility[index] = Mathf.PerlinNoise(scale * (origin_x + x/row_width), scale * (origin_z + z/row_height));
                        grassMap[index] = (int)(fertility[index] * 3f);
                        flowerMap[index] = fertility[index] > 0.5f ? (int)(((fertility[index] - 0.5f)/0.5f) * 3f) : 0;
                        
                        totalFertility += fertility[index];
                    }
                }

As a reminder, the flowers are rendering fantastic; however the grass is not. (I am principally mapping the relative soil fertility on the map to the plant focus, so it appears to be like prefer it is smart.)

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments