Unity虚拟天文馆
程序员文章站
2022-03-25 20:25:37
...
12万颗星,用了gpu instancing以后帧率还行
效果图:(猎户座和昴星团)
3d模式可以在星海*视角转悠
星星类
struct Star
{
public Vector3 position;
public float mag;
public float abMag;
public float colorIndex;
}
ui部分
private void OnGUI()
{
if (showUI)
{
GUILayout.Label("H: Hide ui");
UpdatePerFrame = GUILayout.Toggle(UpdatePerFrame, "Update Per Frame");
if (!tDMode)//天文馆
{
GUILayout.Label("Size Multiplier:");
sizeMultiplier = GUILayout.HorizontalSlider(sizeMultiplier, 0, 1);
GUILayout.Label("Pow Damp:");
powDamp = GUILayout.HorizontalSlider(powDamp, 0, 1000000);
GUILayout.Label("Pow Multiplier:");
powMultiplier = GUILayout.HorizontalSlider(powMultiplier, 0, 10f);
GUILayout.Label("Distance Multiplier:");
distanceMultiplier = GUILayout.HorizontalSlider(distanceMultiplier, 0, 100000);
}
else//3d
{
GUILayout.Label("Size Multiplier:");
sizeMultiplier = GUILayout.HorizontalSlider(sizeMultiplier, 0, 50);
GUILayout.Label("Distance Multiplier:");
distanceMultiplier = GUILayout.HorizontalSlider(distanceMultiplier, 0, 1);
GUILayout.Label("Speed:");
moveSpeed = GUILayout.HorizontalSlider(moveSpeed, 0, 20000);
}
sun = GUILayout.Toggle(sun,"Sun");
string mode = "3D Mode";
if (tDMode == true)
mode = "Flat Mode";
if(GUILayout.Button(mode))
{
tDMode = !tDMode;
if (tDMode)
{
sizeMultiplier = 20f;
powMultiplier = 1f;
powDamp = 0.5f;
distanceMultiplier = 0.1f;
GetComponent<Camera>().clearFlags = CameraClearFlags.Color;
}
else
{
sizeMultiplier = 0.05f;
powMultiplier = 4.41f;
powDamp = 960f;
distanceMultiplier = 10000f;
GetComponent<Camera>().clearFlags = CameraClearFlags.Skybox;
}
transform.position = Vector3.zero;
SetStars();
}
}
}
推荐阅读
-
虚拟DOM,差异对象,打补丁的简单实现-IreneTang-SegmentFault思否
-
Apache 配置多端口 多虚拟主机 局域网访问示例
-
专访HTC CEO&中国区总裁:打造最全能的虚拟现实生态 Vive Cosmos系列不惧竞争
-
LNMP添加、删除虚拟主机及伪静态使用教程
-
使用Dudrop美国虚拟主机架设网站的购买流程及评测分享
-
买虚拟主机可以建站吗?如何选择虚拟主机建站?
-
给VM虚拟机中的CentOS Linux系统挂载U盘的方法图文教程
-
jvm虚拟机笔记<三> 类文件结构与类加载机制
-
HostEase:最佳PHP虚拟主机
-
windows2003 apache配置虚拟主机和绑定域名服务