-
-
Save anonymous/d007acaea501eb478de062cef6dea74a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class CreateVolumeLightTex : MonoBehaviour { | |
public Texture2D input2DTex = null; | |
public Texture3D volumeTex = null; | |
private int resX = 64; | |
private int resY = 64; | |
private int resZ = 64; | |
private Rect sourceRect; | |
Color[] pix; | |
void Awake () { | |
pix = input2DTex.GetPixels (0, 0, 8192, resZ); | |
//This is 24 bit, not 32 bit.。It will need texture combert as 24 bit.// | |
volumeTex = new Texture3D (resX, resY, resZ, TextureFormat.RGB24, false); | |
var colors = new Color[resX*resY*resZ]; | |
int idx = 0; | |
Color c = Color.white; | |
for(int z = 0; z < resZ; ++z) | |
{ | |
for(int y = 0; y < resY; ++y) | |
{ | |
for(int x = 0; x < resX; ++x, ++idx) | |
{ | |
colors[idx] = pix[idx]; | |
} | |
} | |
} | |
volumeTex.SetPixels (colors); | |
volumeTex.Apply(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment