Soft_Job 板


LINE

先说心得: Web 3D程式会Eat the World。以後Desktop的3D程式(游戏除外)会被淘汰,虽然需要很长一段时间。 但Web程式要考虑很多,不要一不小心重踏Insomniac Games的惨痛经验 https://www.gdcvault.com/play/1024465/Insomniac-s-Web-Tools-A 我来分享一些自己写Webgl的心得。 首先TypedArrays不好用,Javascript 没有pointer,所以无法指向某member当base,一定要用subarray()或new ArrayBuffer()来做类似vec3的结构。可是 https://stackoverflow.com/questions/45803829/memory-overhead-of-typed-arrays-vs-strings 所以这样做的话,记忆体爆炸性成长,效能也差。所以Js的glmatrix library根本是误导人走错的方向。 现在我正在准备完全重写matrix library,(顺便用wasm?)适合Js TypedArray的。 Webgl好用,Webgl2更好用,Webgl2-compute出来就真的不得了。如果不介意暂时的相容性问题,请直接使用Webgl2,当你的程式可上线的时候,Webgl2应该是90%+了。 第三programmable vertex pull超赞。OpenGL Insight Chapter21,应该是始祖。 https://github.com/OpenGLInsights/OpenGLInsightsCode/tree/master/Chapter%2021%20Programmable%20Vertex%20Pulling 另外一个example https://github.com/nlguillemot/ProgrammablePulling Webgl没有1d texture要用2d texture来代替,需要确定gpu有vertex texture的支援(99%),然後需要oes_texture_float的extension(80%)。只能用float所以有16million index的限制。 programmable vertex pulling简化程式,把computation移到gpu刚好适合web,请多多利用。如果有碰到问题,我乐意回答,如果我有时间的话。 我正在写3d model editing的程式,browser处理几十万个polygons是没问题,现在我改写用vertex pulling希望能处理几百万个polygons。 --



※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 59.115.100.225
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Soft_Job/M.1553247063.A.941.html
1F:推 dreamnook: 03/22 17:50
2F:→ MOONY135: 分享文 赞赞 03/22 18:00
3F:推 pkro12345: 那你觉得three.js如何? 03/22 18:00
three.js就普及的SceneGraph,看你的用途。展示Model很好。
4F:嘘 EricTCartman: 晕倒 TypedArrays不是这样用的 根本没有必要用到 03/22 19:17
就不好用啊。但必须要到啊,webgl只接收TypedArrays,要用glMatrix Library就必须用subarray()转换成vec3。所以我才说要重写适合TypedArrays的。还是你有高明作法? ※ 编辑: oopFoo (180.217.178.79), 03/22/2019 19:29:04
5F:→ EricTCartman: subarray()或new ArrayBuffer()... 03/22 19:17
6F:→ EricTCartman: gltf当时的设计就是把多个mesh的vertex、indice等 03/22 19:18
7F:→ EricTCartman: 全部放到同块buffer 再藉由json去描述个别mesh的资 03/22 19:18
8F:→ EricTCartman: 料区块解读(stride、offset、glsl type) 03/22 19:19
9F:→ EricTCartman: JS重头到尾只要持有一块buffer记忆体就好 03/22 19:21
10F:→ EricTCartman: 你是要用glMatrix处理什麽? 03/22 19:33
11F:→ oopFoo: 我是持有几个大buffers没错,但要用glMatrix处理就必须用 03/22 19:34
12F:→ oopFoo: DataView没错啊。 03/22 19:35
13F:→ EricTCartman: 抱歉 不是很懂你的问题症结点 glMatrix应该是用来处 03/22 19:38
14F:→ EricTCartman: 理数学矩阵运算的 除非你是做animation 否则应该不 03/22 19:38
15F:→ EricTCartman: 会需要用到那麽大量的记忆体来存transform 03/22 19:39
16F:→ EricTCartman: 至於vec3的问题 由於transform我都是在shader做的 03/22 19:41
17F:→ EricTCartman: 你只要VBO、shader的input会bind 照理来说应该是不 03/22 19:42
18F:→ EricTCartman: 需要额外处理 03/22 19:42
19F:→ oopFoo: 程式是model editing。所以需要Js处理运算3d points。 03/22 19:46
20F:→ oopFoo: 我也想只用Shader就好XDDD 03/22 19:46
21F:→ oopFoo: http://glmatrix.net/是我用的Library,我一直误解 03/22 19:49
22F:→ oopFoo: subarray()的shallow view很cheap,其实超expensive的 03/22 19:50
23F:→ oopFoo: 一直被stupid fast骗。花了很多时间,才发现问题在这。 03/22 19:54
24F:→ EricTCartman: 你做model editing的话 intersection演算法应该是自 03/22 19:57
25F:→ EricTCartman: 己写的吧? 建议直接对typedarray作access就好 03/22 19:57
26F:→ oopFoo: dot(), normalize(), scaleAndAdd(), multi()是常常需要的 03/22 19:59
27F:→ oopFoo: 就懒的重新写,想说需要的时候就shallow view一下,那知道 03/22 20:00
28F:→ oopFoo: shallow view需要这麽大的一个结构。所以才来分享问题。 03/22 20:02
29F:→ EricTCartman: 你shallow view一次会处理多少vertex? 03/22 20:03
30F:→ oopFoo: 本来预先都抓出来,随时可以处理。现在改成edit的时候才抓 03/22 20:06
31F:→ oopFoo: 出来,处理完再release。所以之後要重写dot()....这部份。 03/22 20:07
32F:→ oopFoo: 就不须要subarray()再放掉。 03/22 20:08
33F:推 Bencrie: 听起来就像 java 会取代 c++ 这样 XD 03/22 23:33
34F:→ oopFoo: Web真的会取代Desktop。Autodesk现在是用wasm把autocad带 03/23 05:17
35F:→ oopFoo: 到web上,但我觉的直接写Js会比较好。 03/23 05:18
36F:推 Bencrie: 希望 Blender 不会变成这样 03/23 13:14
37F:推 gravity067: 赞 谢谢分享 03/23 15:26
38F:→ oopFoo: 我有想过要port Blender to Web。还在想,哈哈。 03/23 21:16
39F:推 iven00000000: 还真的可能取代,现在连游戏都可串流了 03/29 23:14







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:Tech_Job 或 站内搜寻

TOP