SCNProgram不影响SCNFloor [英] SCNProgram not affecting SCNFloor
问题描述
在使用shader修饰符的实验中,我发现无法将数组数据传输到shader.
In my experiments using the shader modifier, I saw that the array data could not be transferred to the shader.
Scenekit在将数组数据传递到openGL着色器中的统一数组时给出缓冲区大小错误
由于这个原因,我决定尝试SCNProgram.但是现在我意识到我使用SCNProgram添加的着色器在SCNFloor上不起作用.
For this reason I decided to try SCNProgram. But now I realize that the shaders I added using SCNProgram do not work on SCNFloor.
此问题是否有特定原因?
Is there a particular reason for this problem?
我用于测试的超级简单着色器;
Super simple shaders which I use for testing;
顶点着色器
precision highp float;
attribute vec3 vertex;
uniform mat4 ModelViewProjectionMatrix;
void main()
{
gl_Position = ModelViewProjectionMatrix * vec4(vertex, 1.0);
}
片段着色器
precision mediump float;
void main( void )
{
gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
}
推荐答案
最后,Apple开发者技术支持回答了我问这个问题的问题.
Finally Apple Developer Technical Support answered the question I asked about this issue.
这是他们给出的答案.
不幸的是,没有这样的方法可以遮盖地板.这 SceneKit团队承认SCNFloor是另一种对象, 不适用于SCNProgram.此外,使用 .fragment着色器入口点也不起作用(例如:)
Unfortunately, there is not a way to shade floor as such. The SceneKit team admits that SCNFloor is a different kind of object that is not intended for use with SCNProgram. Furthermore, using the .fragment shader entry point does not work either (such as:)
func setFragmentEntryPoint( _ node: SCNNode ) {
print( #function + " setting fragment entry point for \(node)" )
DispatchQueue.main.asyncAfter( deadline: DispatchTime.now() + DispatchTimeInterval.milliseconds( 2500 ) ) {
let geometry = node.geometry!
let dict: [SCNShaderModifierEntryPoint:String] = [.fragment :
"_output.color = vec4( 0.0, 1.0, 0.0, 1.0 );"]
geometry.shaderModifiers = dict
}
}
尽管SceneKit团队认为此行为是预期的,但您 可能仍会提交错误报告,在这种情况下,错误报告将被解释为 API增强请求.
Though the SceneKit team considered this behavior to be expected, you may still file a bug report which in this case will be interpreted as an API enhancement request.
这篇关于SCNProgram不影响SCNFloor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!