1

In the documentation of SCNView it is stated that:

SceneKit supports OpenGL ES 3.0, but some features are disabled when rendering in a OpenGL ES 3.0 context

I could not find anywhere which features were disabled. I wanted to use my own shader with SceneKit (assigning a SCNProgram to my material) and I tried to use a 3D texture. But I got the following error:

SceneKit: error, C3DBaseTypeFromString: unknown type name 'sampler3D'

So I'm guessing that 3D textures are part of the disabled features but I could not find a confirmation anywhere. Do I have to give up on SceneKit and do all my rendering with OpenGL manually just to use 3D textures?

Bonus question: Why Apple would support only a subset of OpenGL ES 3.0 in SceneKit since iOS has full support?

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
morph208
  • 110
  • 9
  • I managed to make it work by sharing the context. What I mean by that is that I created an OpenGL context and set it as current with `EAGLContext.setCurrentContext(context)`. After that, I can do all my setup code to send my data as a 3D texture on the GPU. By setting the context of my view to the same context `scnView.eaglContext = context`, SceneKit has access to my texture by placing the following code in `handleBindingOfSymbol("name_of_uniform_for_my_3D_texture")`: `glUniform1i( GLint(location), 0 )`. Visually it works, but the error `unknown type name 'sampler3D'` is still here. – morph208 Aug 29 '14 at 13:28

1 Answers1

0

Some features of SceneKit don't work in an ES3 context. You should still be able to use all ES3 features in your OpenGL code.

This looks like an error in SceneKit detecting the uniform declaration for use with its higher-level APIs... so you won't be able to, say, bind an SCNMaterialProperty to that uniform with setValue:forKey:. However, you should still be able to use the shader program -- you'll have to bind it with glBindTexture/glActiveTexture instead (inside a block you set up with handleBindingOfSymbol:usingBlock:).

rickster
  • 124,678
  • 26
  • 272
  • 326
  • Thank you for your answer. It's what I tried to do. I saw that I could not use `SCNMaterialProperty` to set an uniform of type `sampler3D`. So I did the setup manually (using `glActiveTexture` and `glBindTexture`). But I guess I did not put this setup code at the right place. If I put it in the block of `handleBindingOfSymbol` as you suggested, it seems to be working but my code is slow. The code within the block of `handleBindingOfSymbol ` is being called before each frame, right? Where do I put it to be called only once? – morph208 Aug 27 '14 at 17:15