Saturday, August 19, 2006

Blender 2006 google夏日代码建议(2)

体绘制的建议。Volumetric Rendering Proposal

IMPLEMENTING VOLUMETRIC RENDERING FOR BLENDER

在 blender 中实现体绘制的建议

Synopsis:

Volumetric rendering is the process of visualizing three dimensional data sets.I would like to implement slice-based rendering of volumes, defined by the volume function like "Fragment getFragment(x,y,z)" where "Fragment" is a data structure containing fields like red, green and blue color channels, alpha channel, normal vector, etc; x, y, z denotes a point in 3D space(local or global). Slice method approximates the volume by projecting volume function on sequential planes. Planes are camera-oriented, meaning their normals always points toward the camera. Slice technic is good for rendering volumes that describe cloud-like objects: explosions, nebulas, smoke. getFragment function allows high variation of possibilities including constructing specific shapes with boolean operations. For example, one cloud can "mask out" another cloud.

Blender currently has no volumetric rendering. Effects like explosions can be produced with particles, but when camera moves around, it is clearly visible that explosion is created from "parts" that behave unnaturally.

在自然环境和计算模型中,许多对象和现象只能用三维数据场表示,对象体不是用几何曲面和曲线表示的三维实体,而是以体素为基本造型单元。例如人体里面就十分复杂,如果仅仅用几何表示各器官的表面,不可能完整显示人体的内部信息。体绘制(Volume Rendering)的目的就在于提供一种基于体素的绘制技术,它有别于传统的基于面的绘制技术,能显示出对象体的丰富的内部细节。体绘制直接研究光线穿过三维体数据场时的变化,得到最终的绘制结果,所以体绘制也被称为直接体绘制。体绘制与传统面绘制的区别见图2-8。从结果图象质量上讲,体绘制优于面绘制,但从交互性能和算法效率上讲,至少在目前的硬件平台上,面绘制优于体绘制,这是因为面绘制是采用的传统的图形学绘制算法,现有的交互算法和图形硬件和图形加速技术能充分发挥作用。

Blender 现在的爆炸效果是用粒子来模拟的,在改变了摄象机位置以后,会感觉不太真实。

Deliverables:

New object type "Volume" will be implemented. This type will have position and dimensions. Also it will have parameters that adjust rendering quality, like quantity of slices, and possibly some other sampling parameters. New pass for sliced volumetric rendering will be implemented and seemlessly integrated. "getFragment(x,y,z)" will be implemented for 3D textures.

在blender当中实现一类“体”的物体类型。有位置和尺寸。当然也有渲染质量控制的参数。采样和3d的纹理的实现也可以无缝的衔接。

Implementation Details:

New blender's rendering process allows for easy integration of new rendering passes. renderVolume function will be implemented to write into RenderPart. Resulting part will be combined by blender's rendering engine.

实现细节:

需要新的渲染流程,和新的前置渲染引擎实现。

中文的关于体绘制的科普:http://www.cgn.net.cn/wsdj/z7.htm

Blender架构和数据结构问题

小小感想.

英文方面,这里已经将源文件中的注释提出专门列了一些题目.

http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture

虽然不完全,但是具备一定的代表性了.

blender作为一个cg软件,数据上面有些特殊性,ton在文章中已经明确指出,为了做到所见即所得,需要有3方面的结构准备:操作结构,显示数据结构,还有存储数据结构.之间有些关联, 通过用c语言,做到面向对象的程序. 例如一个mesh,mesh 和 editmesh 在structs dna的文件中被定义,在interface api中定义显示方式.关于这一点我们可以在 05年soc的nurbs项目中清晰的看到这个脉络.

http://mediawiki.blender.org/index.php/BlenderDev/NurbsCurvesNurbana

这个项目的前期工作其实已经完成,唯一没做的就是整合进bf-bledner.最近其实很希望看这部分代码.机器又出问题,恩恩,先cvs了这个项目再说.

最近在学erlang

据说是门函数性语言,类似的还有 Scheme、ML、Haskell. 主要就是想看看wings3d的内容,其实这些东西都能猜个八九了. 只是里面详细的算法还得深入.wings相对来说是比较简单的,它的点线的挤出是靠欧拉操作来完成的跟blender或者其他高级点的完全不同,blender能够挤出点,wings必须把点周围添加面和边才行.简单化了编程,自然也简单化了用户群. 混合编程以后会常态化,继续学习.
-----------------------------------------------------------------
估计得花点钞票把ml编程这本书请回家来.站在那本书前一直都有些困惑,该拿还是不拿,总在盘算机会成本.呵呵,学习耗费了很大成本,不知道这次的知识储备能够用多少个年头.

[Bf-committers] Doxygen based doc of blender core

那天看到了就下载了,用的doxygen做的。只有core的文件,不过文件引用结构和struct图都已经很清晰了。intern跟extern的没有。看看是比较方便来着。知识并不全在代码中,很多很多也许是10倍 100倍的知识是在其他地方的。很想快快搞定blender的一些事情,不过越深入越mess。局部跟全局。

i've created a doxygen doc (with references and graph calls, collab
diag an so on) of src dir :
http://jlp.nerim.net/dev/blender-doxygen-html.zip

287 Mb unzipped, 25 k files.

Note : due to the time needed to generate this i wont do it often

Lukep

在blender代码中添加新node的过程

小心的读了下blender node的这篇 http://mediawiki.blender.org/index.php/BlenderDev/AddingANode
教程

主要意思就是添加一个node不会有很多困难,最主要的就是两个文件,BKE_node.h里面要声明下新添加的node给它添一个识别号,以前一个id左移一位来写号码。

然后就是在node_shader/node_composite.c 文件里面添加node的实现,最简单的就是写出 bNodeSocketType/bnodetype/bnodefuncction三个部分。
每个接口 声明 如下
/* SocketType syntax:
socket type, max connections (0 is no limit), name, 4 values for default, 2 values for range */
最后用 {-1,0," "} 结束,socket type 有三类,数值/向量/rgba。

然后 将node的实现函数写出,
最后声明 一个 nodetype ,

写完后再在 node_all_shaders[] 这个阵列里面添加 &sh_node_XXX 的字符串。

这是一个基本过程,其他事情node系统会自己做出,比如ui之类的绘制,如果界面有特殊设置,就还要自己在draw_node.c里面添加代码。


还要更仔细深入blender的node的话,就参考这些文章,包括blender的界面api。
学习blendernode 需要读过的文章是 /doc/interface_API.txt 通用ui接口(只是blender能用的),在

源文件中寻找
然后是
http://www.blender.org/cms/Generic_Node_system_fo.742.0.html 基础性介绍文章,讲述

blender node系统的一般情况
当然为了要更深入理解blender的结构形式,还需要看
http://www.blender.org/cms/Blender_Architecture.336.0.html blender的架构 了解下blender的数据

结构,特别是 id 的使用方法

关于ui的东西
http://www.blender.org/cms/Blender_Nodes_UI.745.0.html node的ui有了scoket link

这些概念,有了它会对code有更形象的了解。

最后一篇:http://mediawiki.blender.org/index.php/BlenderDev/AddingANode 一个实例教程,讲解如

何添加一个math node 在shader node 面板里面的

更多,找一个最近版本的cvs blender 里面会有node editor的window选项,这样一边看代码,一边看

blender的这个node就会有更深入的印象。
还有更多,就是看blender的其他代码:DNA_listbase.h DNA_ID.h DNA_node.h draw_node.c node.c前三

个可以在makesdna文件夹里找到,后两个一般就在src里面。


ps:我在按照教程改代码编译时有错误,是draw_node.c里面的问题,所以还要继续学习。
ps2:也许可以用vb来写一个可视化的node开发程序,因为格式固定,所以主要就是修改字段的问题,不过nodefuction怎么用vb来做,思考中,5年没碰过vb了

网上汇款免手续费, 收货满意后卖家才能拿钱,货款都安全