Hardware Based Rendering of 3D Geometry

Create Hardware and Render a 3D Geometry

To render a 3D geometry, a shader, buffers and render state are required. None of them can work without each other.

  • Buffers - Triangle lists are individual triangles specified in an array that is sometimes referred to as a buffer. In a triangle list, each triangle is individually specified. Points of a triangle can be shared by using indices to reduce the amount of data that must be passed to the graphics hardware.
  • Shaders - It defines how to transform the triangles from world space into screen space and calculate the final pixel color in GPU side
  • Render States - It provides parameters for the GPU to rasterize the triangles into pixels.

The OpenGL Shading Language (GLSL) is the standard high level shading language for the OpenGL graphics API. The InitRenderer method in AssetBrowser/Controls/RenderView.cs file under the demo application (name:AssetBrowser) demonstrates the simple use of GLSL using Aspose.3D API. There are three shader types commonly used: Vertex Shaders, Fragment Shaders and Geometry Shaders.

GLSLSource class tells the renderer, the source code is for OpenGL shading language, it can be compiled to ShaderProgram class. The ShaderVariable class defines the variables used in the shader. The VariableSemantic class is used to identify the shader variable’s semantic, Aspose.3D renderer will automatically prepare shader variable values depends on the semantics.

Programming Sample for Shader

This code example initializes renderer and Shader for the grid. You can download complete working project of this example from here.

Programming Sample for the Buffer and Render State

This code example initializes the buffer and render state for the grid.