如何动态地为 3D 对象着色/纹理?
我有一个由三角形组成的 3D 模型。我想做的是,给定靠近模型的点,我想将模型(三角形)着色为另一种颜色,例如蓝色。
现在,我有一个关于模型的边界球体,当碰撞发生时,我只想对发生碰撞的模型部分进行近似着色。
有人可以建议我一些我可以使用并实现这一目标的东西吗?
谢谢
I have a 3D model, composed of triangles. What I want to do is, given a point near to the model, I would like to color the model (triangles) to another color, say blue.
Right now, I have a bounding sphere about the model, and when the collision occurs, I just want to approximately color the portions of model from where the collision occurred.
Can someone please suggest me something that I can use and make this happen ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您只有一个或少量点要测试,最快的渲染方法可能是在 GLSL 中编写一个着色器,根据到您的点的世界空间距离有条件地修改片段颜色。
如果您从未进行过 GLSL 编程,则另一种可能更简单的选择是使用顶点数组并维护从三角形顶点到索引顶点数组的坐标的映射;然后您可以采用触发碰撞测试的任何顶点,并手动修改每帧上与其相关的颜色数据。
If you just have one or a small number of points to test against, the fastest-to-render method would probably be to write a shader in GLSL that conditionally modifies fragment colors based on world-space distance to your point(s).
An alternative that may be simpler if you've never done GLSL programming would be to use vertex arrays and maintain a map from your triangle vertices to coordinates indexing the vertex arrays; then you can take whatever vertices trigger the collision test and manually modify their associated color data on each frame.