我有一个我加载到Scenekit中的Collada模型。 当我在模型上执行命中测试时,我能够检索命中的模型的纹理坐标。IOS8 Scenekit在纹理坐标上绘画
有了这些纹理坐标,我应该可以用颜色替换纹理坐标。 所以这种方式,我应该可以借鉴模型
如果我错了,纠正我到目前为止。
我读了很多文章到现在,但我只是没有让我的着色器正确。 (虽然我没有得到一些时髦的效果;-)
我的顶点着色器:
precision highp float;
attribute vec4 position;
attribute vec2 textureCoordinate;
attribute vec2 aTexureCoordForColor; //coordinates from the hittest
uniform mat4 modelViewProjection;
varying vec2 aTexureCoordForColorVarying; // passing to the fragment shader here
varying vec2 texCoord;
void main(void) {
// Pass along to the fragment shader
texCoord = textureCoordinate;
aTexureCoordForColorVarying = aTexureCoordForColor; //assigning here
// output the projected position
gl_Position = modelViewProjection * position;
}
我的片段着色器
precision highp float;
uniform sampler2D yourTexture;
uniform vec2 uResolution;
uniform int uTexureCoordsCount;
varying vec2 texCoord;
varying vec2 aTexureCoordForColorVarying;
void main(void) {
??????????? no idea anymore what to do here
gl_FragColor = texture2D(yourTexture, texCoord);
//
如果您需要更多的代码,请让我知道。
哇......这是迄今为止最好的信息......谢谢。我将处理这些信息,并让您知道哪些方法最有效。 – Vilois 2014-10-01 09:14:06
是的..谢谢....事情现在有了很多更清楚的.....我添加了shaderModifier,稍微加大了上面的代码,但总的来说它是一样的.....非常感谢你 – Vilois 2014-10-01 11:43:45
@rickster你的回答很清楚,我认为这会帮助我解决我自己的问题。它没有解决,所以我已经发布了一个问题http://stackoverflow.com/questions/38999782/how-to-use-a-shadermodifier-to-alter-the-color-of-specific-triangles希望像你这样的人能够帮助你。顺便说一句,你提供的第一个链接“这个答案”实际上链接到相同的“SCNShadable参考”;那是故意的。另外,在你最后的笔记中你提到_surface.color,我认为你的意思是_surface.diffuse。 – PKCLsoft 2016-08-19 03:34:37