我有一个Collada模型,我加载到SceneKit.当我在模型上执行hittest时,我能够检索被击中的模型的纹理坐标.
使用这些纹理坐标,我应该能够用颜色替换纹理坐标.所以这种方式我应该可以在模型上绘制
如果我错了,请纠正我.
到目前为止我读了很多文章,但我没有把我的着色器弄好.(虽然我确实得到了一些时髦的效果;-)
我的顶点着色器:
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;
}
Run Code Online (Sandbox Code Playgroud)
我的片段着色器
precision highp float;
uniform sampler2D yourTexture;
uniform vec2 uResolution;
uniform int uTexureCoordsCount;
varying …Run Code Online (Sandbox Code Playgroud)