Comments (6)
蓝色点也会出现错误,浮点数的时候,中心是包括的,计算出来坐标是(0.5, 1.66666667),显然中心在三角形内,转换为整数后,计算出来(0.5, 1.25),这个时候这个像素不管是左上角还是中心,已经都不在三角形内部,也出现了,在浮点数坐标下,原本属于三角形内部的像素点,转换为整数后,反而这个点不属于三角形了
from renderhelp.
实际上使用定点数,情况会好不少
from renderhelp.
转整数,有算少的点,同样也有算多的点,整体面积不变,再,实际显卡内部用定点数,误差会小很多。
from renderhelp.
我曾经考虑要不要换成定点数,最后没换,因为定点数会让可读性变差很多,这是个教程,强调这里应该是一个整数即可,换成定点只是一步之遥,自己换吧。
from renderhelp.
整体这里我觉的不好理解的地方,主要还要考虑TopLeft的情况,如果按照标准的浮点数计算来说,最简单的代码,就是 像素坐标 + 0.5 带入边界函数里,可以不考虑TopLeft的情况,唯一的问题是浮点数精度误差问题,容易出现接缝处有个别点不渲染的问题,使用整数是一种近似方法,在数值稳定性和计算速度能快不少,这块我网上看来不少教程,感觉都没说到近似问题,从斜率上感觉就是不精准,所以找了一个范例,但是如果按照这里的TopLeft的情况来做,其实会出现少点和不增加点的情况,比如一个直角三角形,(0, 0), (10.2,5) (10.2,23.5)这样,右边的一列中心点不包括在浮点数三角形上,考虑TopLeft,整数三角形也把它剔除了,但是斜边就不好保证了,目前看确实是定点数最合理,考虑现实设备的尺寸,32bit的int类型,16bit整数部分,16bit小数部分,精度不输double
from renderhelp.
24 bit 整数,8 bit 浮点足够了。
from renderhelp.
Related Issues (10)
- 关于向量转颜色的放大系数 HOT 2
- sample_03_box.cpp定点着色器中的VARYING_COLOR没有在像素着色器被使用,可以去除吗? HOT 2
- 三角形接缝处不连续,有遗漏的点 HOT 5
- win10 wsl 编辑示例报错
- Bitmap::Sample2D方法有一个像素的偏差
- 读取其他格式的纹理图 HOT 3
- 请教: 深度缓存记录 1/w HOT 3
- 关于平移变换矩阵的问题 HOT 2
- 请教 整数颜色到矢量 转换问题 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from renderhelp.