- Home /
Question by
Major · Mar 06, 2015 at 05:20 AM ·
gameobjecttransformproceduralskyboxspace
Normal Texture to Skybox
I have been tinkering with making a real scale space scenes and ran into the problem of rendering the massive distances between the celestial bodies. I figured the best solution is to render a skybox. So that is the background story. I was able to render a normal texture that shows all the objects I want to show as dots with a black background. But I can't figure out how to convert this image into a skybox. Here is what I am working with:
Texture2D skyTex = new Texture2D(1024, 1024);
stars = GameObject.FindGameObjectsWithTag("Respawn");
for(int y=0; y<1024; y++){
for(int x=0; x<1024; x++){
skyTex.SetPixel(x, y, Color.black);
}
}
foreach(GameObject s in stars){
Vector3 coords = _camera.WorldToScreenPoint(s.transform.position);
skyTex.SetPixel(Mathf.RoundToInt(coords.x), Mathf.RoundToInt(coords.y), Color.yellow);
}
skyTex.Apply();
MeshRenderer mr = GetComponent<MeshRenderer>();
mr.sharedMaterials[0].mainTexture = skyTex;
skyTex.wrapMode = TextureWrapMode.Repeat;
I would appreciate any help on this topic. Thanks!
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613185223im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Procedural Skyboxes Based on Scene Data 1 Answer
Extremely Fast Travel 1 Answer
Render Extremely Far off Objects 1 Answer
How to move a Game Object from a script not attached to it. 1 Answer