Unity3d 在Unity WebGL中是否有生成3d热图的方法/着色器?

Unity3d 在Unity WebGL中是否有生成3d热图的方法/着色器?,unity3d,glsl,shader,unity-webgl,Unity3d,Glsl,Shader,Unity Webgl,我正在Unity Webgl的一个项目中工作,该项目将不同位置的温度传感器值编码为建筑物的三维热图。我尝试使用粒子系统和着色器根据这些值为粒子着色,但效果不是很理想。我现在正在寻找一种解决方案或着色器,它可以使用温度值(例如,带颜色的体积照明)为半透明对象着色。应该是这样的: 我搜索了互联网,但只发现许多体积着色器不支持OpenGL或只支持单色 我想知道是否还有其他解决办法。提前谢谢你的帮助 在示例中,您不需要着色器来实现效果。您可以将热图数据的水平切片加载到纹理中,并将其放置在平面上。这是我举

我正在Unity Webgl的一个项目中工作,该项目将不同位置的温度传感器值编码为建筑物的三维热图。我尝试使用粒子系统和着色器根据这些值为粒子着色,但效果不是很理想。我现在正在寻找一种解决方案或着色器,它可以使用温度值(例如,带颜色的体积照明)为半透明对象着色。应该是这样的:

我搜索了互联网,但只发现许多体积着色器不支持OpenGL或只支持单色


我想知道是否还有其他解决办法。提前谢谢你的帮助

在示例中,您不需要着色器来实现效果。您可以将热图数据的水平切片加载到纹理中,并将其放置在平面上。这是我举的一个例子,它使用柏林噪声作为热量数据。你可以从这里得到柏林噪声函数

公共类热图行为:单行为
{
public int x_size=128;//纹理的宽度
public int y_size=128;//纹理的高度
public int num_shells=10;//数据的切片数
公共游戏对象平面_prefate;//切片几何体和着色器
//这个预制件只是一个面积相同的平面
//作为一个建筑,用一种材料
//着色器设置为未照明/透明
公共浮动高度=10;//数据集的高度(以世界单位表示)
公共颜色LowColor;//冷色
公共颜色HiColor;//热门颜色
void Start()
{
对于(int i=0;i

如果要在建筑内的场景中以交互方式飞行,解决方案将更加复杂。您需要将壳与相机对齐,根据相机视图截头体计算壳需要多大,并根据壳的旋转方向采样热图数据。

也许这有帮助:@BooNonMooN我也读过,但这不是我想要的。但是谢谢你的帮助,谢谢!非常感谢您的回复!这很有帮助。我在一个演示中试用过,效果看起来非常理想。但是我在WebGL中遇到了一些
GL\u无效\u帧缓冲区\u操作
错误。我想知道你是否有什么想法。奇怪的是,它在实际项目中起作用,我一定是做错了什么。
public class HeatmapBehavior : MonoBehaviour
{
    public int x_size = 128; //width of the textures
    public int y_size = 128; //height of the textures
    public int num_shells = 10; //number of slices of the data
    public GameObject plane_prefab; //the slice geometry and shader
                                    //this prefab is just a plane with the same area 
                                    //as the building, with a material that has its
                                    //shader set to Unlit/Transparent

    public float height = 10; //how tall in world units the dataset is
    public Color LowColor; //the cold color
    public Color HiColor; //the hot color

    void Start()
    {
        for (int i = 0; i < num_shells; i++)
        {

            var shell = GameObject.Instantiate(this.plane_prefab);  //create a slice
            shell.transform.parent = this.transform;
            shell.transform.position += new Vector3(0, (float)i / (float)this.num_shells * this.height, 0);

            var texture = new Texture2D(x_size, y_size);
            //for each texel in the shell's texture
            for(int x = 0; x < x_size; x++)
            {
                for(int y = 0; y < y_size; y++)
                {
                    var heatLocation = new Vector3((float)x / (float)x_size, (float)y / (float)y_size, (float)i / (float)num_shells); //find the coordinate in the heatmap for this texel
                    var heat = (Perlin.Fbm(heatLocation, 4) + 1)/2f; //grab the heat map data
                    texture.SetPixel(x, y, Color.Lerp(this.LowColor, this.HiColor, heat)); //interpolate the color based on heat map
                }
            }

            texture.Apply();


            shell.GetComponent<MeshRenderer>().material.SetTexture("_MainTex", texture);

        }
    }
}