如下内容是对 https://tips.hecomi.com/entry/2018/01/05/192332 进行翻译同时增补得到笔记
体积渲染概述
体积渲染是一种在 2D 屏幕上渲染 3D Texture 的技术,其中 3D Texture 来源有:
- 从 CT 扫描、MRI 等获得的数据;
- 预先准备好或实时计算的 3D 数据(例如云和效果)
3D Texture 的种类
.raw
.pvm
DICOM
NRRD 文件(.nrrd)
NRRD(Nearly Raw Raster Data)是一种轻量级、灵活的科学数据格式,专为多维栅格数据设计。
通常由两个部分组成:
.nrrd 文件:纯文本头文件,包含维度、数据类型、空间方向、原点、间距等元数据。
.raw 文件:二进制体数据(可选,也可内联在 .nrrd 中)。
特点:
开源、跨平台、易于解析。
支持任意维度(2D、3D、4D…)、多种数据类型。
被 3D Slicer、ITK、VTK 等主流科学可视化工具广泛支持。
可压缩(如 gzip)。
生成 3D Texture
运行时候生成
using UnityEngine;public class Create3DTex : MonoBehaviour
{[SerializeField]int size = 16;void Start(){var tex = new Texture3D(size, size, size, TextureFormat.ARGB32, true);var colors = new Color[size * size * size];float a = 1f / (size - 1);int i = 0;Color c = Color.white;for (int z = 0; z < size; ++z){for (int y = 0; y < size; ++y){for (int x = 0; x < size; ++x, ++i){c.r = ((x & 1) != 0) ? x * a : 1 - x * a;c.g = ((y & 1) != 0) ? y * a : 1 - y * a;c.b = ((z & 1) != 0) ? z * a : 1 - z * a;colors[i] = c;}}}tex.SetPixels(colors);tex.Apply();var renderer = GetComponent<Renderer>();renderer.material.SetTexture("_Volume", tex);}
}
生成 3D Texture 并序列化
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;public class EditorCreateTexture3DTest : Editor
{[MenuItem("GameTools/CreateTexture3D")]static void CreateTexture3D(){// Configure the textureint size = 128;TextureFormat format = TextureFormat.RGBA32;TextureWrapMode wrapMode = TextureWrapMode.Clamp;// Create the texture and apply the configurationTexture3D texture = new Texture3D(size, size, size, format, false);texture.wrapMode = wrapMode;// Create a 3-dimensional array to store color dataColor[] colors = new Color[size * size * size];// Populate the array so that the x, y, and z values of the texture will map to red, blue, and green colorsfloat inverseResolution = 1.0f / (size - 1.0f);for (int z = 0; z < size; z++){int zOffset = z * size * size;for (int y = 0; y < size; y++){int yOffset = y * size;for (int x = 0; x < size; x++){colors[x + yOffset + zOffset] = new Color(x * inverseResolution,y * inverseResolution, z * inverseResolution, 1.0f);}}}// Copy the color values to the texturetexture.SetPixels(colors);// Apply the changes to the texture and upload the updated texture to the GPUtexture.Apply();// Save the texture to your Unity ProjectAssetDatabase.CreateAsset(texture, "Assets/Texture3DApply/testtexture3d.asset");}
}
引用
https://github.com/hecomi/UnityVolumeRendering
https://github.com/mlavik1/UnityVolumeRendering
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/908912.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!相关文章
深入解析:线程安全相关的注解
pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …
go语言的结构体和指针
go语言的结构体和指针type Person struct {Name stringAge int
}func updateName(p *Person, newName string) {p.Name = newName // 通过指针修改结构体字段
}func main() {p := Person{Name: "Tom", Age:…
通过主机监控发现路径遍历漏洞的实战技巧
本文介绍如何利用简单的Bash脚本监控主机在线状态,通过实时Telegram通知及时发现目标系统上线,并成功挖掘出Jira系统的路径遍历高危漏洞的实战经验。通过主机监控发现路径遍历漏洞
脚本功能概述
我最近编写了一个简单…
Code New Roman 字体的正确下载方式
Code New Roman 字体的上游已经不知所踪,而各大字体网站上流传的版本在 VS Code 里的显示效果也有些问题。(具体来说,字符的上边界会顶到一行的上边界。)但是我在网上冲浪时发现 Nerd Font 里有修复了这个问题的 r…
go语言中的数组类型
go语言中的数组类型var arr1 [3]int // 声明一个长度为3的整型数组
arr2 := [3]int{1, 2, 3} // 声明并初始化
arr3 := [...]string{"a", "b"} // 自动推断长度fmt.Printl…
多态是对于处理不同的变量,但是使用相同或者类似的方式。多态核心分为两种形式:编译时多态(静态多态)和运行时多态(动态多态)C++中多态通常使用虚函数或者指针(引用)实现。
多态是对于处理不同的变量,但是使用相同或者类似的方式。多态核心分为两种形式:编译时多态(静态多态)和运行时多态(动态多态)C++中多态通常使用虚函数或者指针(引用)实现。pre { white-space: pre !important;…
从 C++ 到 Python
从 C++ 到 Python
一、注释
#单行注释多行注释"""多行注释"""二、字符串
Hello, python!
#单、双引号都可以,没有区别
#倾向于用单引号三、I/O与变量
#输出
print(Hello, python!)
#Py…
在 Unity 中实现 0GC(零垃圾回收)对象池 — 实战指南 - 实践
pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …
Nipper 3.9.0 for Windows Linux - 网络设备漏洞评估
Nipper 3.9.0 for Windows & Linux - 网络设备漏洞评估Nipper 3.9.0 for Windows & Linux - 网络设备漏洞评估
Nipper for routers, switches & firewalls | Nipper Network Configuration Audit Tool
请访…
个人项目-软件工程第二次作业 - Nyanya-
这个作业属于哪个课程
计科23级34班这个作业要求在哪里
个人项目这个作业的目标
进行个人编程,设计论文查重算法Github仓库
https://github.com/username/PaperCheck一、PSP表格PSP2.1
Personal Software Process Sta…
go语言中的复杂数据类型
go语言中的复杂数据类型package mainimport ("fmt"
)func main() {// 基本类型var a int = 10var b float64 = 3.14var c bool = truevar d byte = Avar e rune = 中var f string = "Hello, Go!"v…
详细介绍:互联网医院品牌IP的用户体验和生态构建
详细介绍:互联网医院品牌IP的用户体验和生态构建pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas",…
实用指南:认知语义学中的象似性对人工智能自然语言处理深层语义分析的影响与启示
pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …
支持 SSL 中等强度密码组(SWEET32) - 漏洞检查与修复
突发奇想,把漏洞修复的事情也记录一个文档,之前也修复过很多的漏洞,但是总是修复了就完事了,没有留存记录,以后的漏洞我会留一个tag专门记录,如果正好其他人也有遇到的这样的问题,可以很快速的有一个处理方向和…
C# WPF CommunityToolkit.MVVM (测试一)
MainWindow.xaml<Window x:Class="CommunityToolkit.MVVM_RelayCommand_测试.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.m…
linux kernel synchronization rcu
Read Copy Update /RCU
可以单个写,多个读,在内核中常用于更新链表。对比顺序锁,只能用指针访问资源,读数据无需加锁,避免多次读数据。
应用场景:多个读
少量写
写相较于读具有更高优先级
rcu保持数据指针的引用…
完整教程:机器学习入门,用Lima在macOS免费搭建Docker环境,彻底解决镜像与收费难题!
pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …