I’m currently trying to create a custom shader for a custom primitive.
The primitive constructor needs an Appearance, so I started implemented my own, based on one of the existing Appearances.
So I looked for example at DebugApperance, and here’s the construction of the vertex shader code:
var vs =
‘attribute vec3 position3DHigh;\n’ +
‘attribute vec3 position3DLow;\n’ +
'attribute ’ + glslDatatype + ’ ’ + attributeName + ‘;\n’ +
'varying ’ + glslDatatype + ’ ’ + varyingName + ‘;\n’ +
‘void main()\n’ +
‘{\n’ +
‘vec4 p = czm_translateRelativeToEye(position3DHigh, position3DLow);\n’ +
varyingName + ’ = ’ + attributeName + ‘;\n’ +
‘gl_Position = czm_modelViewProjectionRelativeToEye * p;\n’ +
‘}’;
For starters, there’s things missing here, this is not a complete vertex shader. No uniforms defined, and it is using undefined functions.
Ok, of course somewhere, Cesium is concatenating the undefined stuff. I’m still trying to find where, if someone call orient me, it would be nice.
I found the file Renderer/createShaderSource.js, but this seems to just concat #defines and sources, and I dont see any extra source being added in the DebugAppearance besides that code snippet I posted.
I searched a bit I found out about AutomaticUniform class, this is probably the main responsible for generating that missing stuff, however I still do not know how this all works together.
So my question is, how to make an Appearance use a pure vertex/fragment shader without it including any of the Cesium builtin stuff?
Or the Appearance class is only expected to work with shader code managed by Cesium and as such, I need go to deeper and use something lower level?
If that’s necessary, it worries me because Primitives cannot render themselves, they only provide geometry and materials to Cesium (unless materials can bypass default matrices and attributes).
PS:I’m rendering something that is not related to the globe at all, so I want to provide my own modelview/project matrices and use floats instead of doubles for the position attribute.