Uniform

Evenly distributing n points on a sphere

偶尔善良 提交于 2019-11-25 23:36:53
I need an algorithm that can give me positions around a sphere for N points (less than 20, probably) that vaguely spreads them out. There's no need for "perfection", but I just need it so none of them are bunched together. This question provided good code, but I couldn't find a way to make this uniform, as this seemed 100% randomized. This blog post recommended had two ways allowing input of number of points on the sphere, but the Saff and Kuijlaars algorithm is exactly in psuedocode I could transcribe, and the code example I found contained "node[k]", which I couldn't see explained and ruined

NanoVG 优化笔记:性能提高5倍的秘密

旧巷老猫 提交于 2019-11-25 17:01:56
NanoVG 优化笔记 nanovg 正如其名称所示的那样,是一个非常小巧的矢量绘图函数库。相比cairo和skia的数十万行代码,nanovg不足5000行的C语言代码,称为nano也是名副其实了。nanovg的设计、接口和代码质量都堪称典范,唯一美中不足的就是性能不太理想。特别是在Android的低端机型和大屏幕的机型上,一个简单的界面每秒只能画十几帧。最近我把 AWTK 移植到Android上时,就碰到了这个尴尬的问题。 经过优化之后, AWTK 在低端机型上,整体渲染性能有了3到5倍的提升。这里做个笔记,供有需要的朋友参考。 nanovg的性能瓶颈在于片段着色器(fragment shader),片段着色器可以认为是为GPU提供的一个回调函数,该回调函数在处理每个像素时被调用,在每一帧绘制时都会执行数百万次,可见该函数的对性能的影响是很大的。 我们先看看nanovg的片段着色器(fragment shader)代码: static const char* fillFragShader = "#ifdef GL_ES\n" "#if defined(GL_FRAGMENT_PRECISION_HIGH) || defined(NANOVG_GL3)\n" " precision highp float;\n" "#else\n" " precision mediump