Exemple #1
0
        /// <summary>
        /// Get the output from the vertex shader.
        /// </summary>
        /// <param name="primitiveID"></param>
        /// <param name="instanceID"></param>
        private void GetVertexShaderOutput(int primitiveID, int instanceID)
        {
            if (DrawCall?.cmd?.Count == 0)
            {
                return;
            }

            // load patch data from vertex shader
            var patch = DrawCall.GetPatch(primitiveID);

            DebugGetError(new StackTrace(true));

            gl_PatchVerticesIn = patch.Length;
            gl_PrimitiveID     = primitiveID;

            for (int i = 0; i < gl_PatchVerticesIn; i++)
            {
                // compute vertex shader data
                VertShader.Execute(Convert.ToInt32(patch.GetValue(i)), instanceID);
                // set input data for the vertex
                gl_in[i].gl_Position  = VertShader.GetOutputVarying <vec4>("gl_Position");
                gl_in[i].gl_PointSize = VertShader.GetOutputVarying <float>("gl_PointSize");
                var clipDistance = VertShader.GetOutputVarying <float[]>("gl_ClipDistance");
                for (int j = 0; j < clipDistance.Length; j++)
                {
                    gl_in[i].gl_ClipDistance[j] = clipDistance[j];
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Get the vertex shader output for the
        /// respective primitive ID and instance.
        /// </summary>
        /// <param name="primitiveID"></param>
        /// <param name="instanceID"></param>
        private void GetVertexShaderOutput(int primitiveID, int instanceID)
        {
            if (DrawCall?.cmd?.Count == 0)
            {
                return;
            }
            var vertexShader = VertexShader;

            // set shader input
            gl_PrimitiveIDIn = primitiveID;

            // load patch data from vertex shader
            var patch = DrawCall.GetPatch(primitiveID);

            DebugGetError(new StackTrace(true));
            gl_in = __InOut.Create(patch.Length);
            for (int i = 0; i < patch.Length; i++)
            {
                // compute vertex shader output
                var vertexID = Convert.ToInt32(patch.GetValue(i));
                vertexShader.Execute(vertexID, instanceID);
                // set geometry shader built in input varyings
                gl_in[i].gl_Position  = vertexShader.GetOutputVarying <vec4>("gl_Position");
                gl_in[i].gl_PointSize = vertexShader.GetOutputVarying <float>("gl_PointSize");
                var clipDistance = vertexShader.GetOutputVarying <float[]>("gl_ClipDistance");
                for (int j = 0; j < clipDistance.Length; j++)
                {
                    gl_in[i].gl_ClipDistance[j] = clipDistance[j];
                }
                // set geometry shader user input varyings
                ProcessFields(this, ProcessInField, new[] { typeof(__in) }, i);
            }
        }