Pipeline scripts can also be used to render simple 3D scenes by using the (optional) OBJ and STL loading modules. The following scripts load and reanders the Teapot object :
TEXTURE_FORMAT:outputFormat(512, 512, GL_RGB, GL_UNSIGNED_BYTE)
ADD_PATH(Resources/)
CALL:LOAD_OBJ_GEOMETRY(teapot.obj, teapot)
SOURCE:vertexShader
{
#version 130
out vec3 outN;
uniform float ax = 0.0,
ay = 0.0,
s = 1.0;
uniform vec3 offset = vec3(0.0);
void main()
{
mat3 Mx = mat3( 1.0, 0.0, 0.0,
0.0, cos(ax), sin(ax),
0.0, -sin(ax), cos(ax));
mat3 My = mat3( cos(ay), 0.0, sin(ay),
0.0, 1.0, 0.0,
-sin(ay), 0.0, cos(ay));
gl_Position = vec4(Mx*My*s*gl_Vertex.xyz - offset, 1);
outN = gl_Normal.xyz;
}
}
SOURCE:fragmentShader
{
#version 130
in vec3 outN;
out vec4 outputTexture;
uniform vec3 light = vec3(1.0, 0.0, 1.0);
uniform float alpha = 0.1;
void main()
{
vec3 c = abs(outN.xzy);
outputTexture.rgb = alpha*c + (1.0-alpha)*c*max(dot(outN.xyz,normalize(light)),0.0);
}
}
FILTER_LAYOUT:showTeapotFilter(outputFormat)
{
GL_VERTEX_SHADER(vertexShader)
GL_FRAGMENT_SHADER(fragmentShader)
GL_RENDER(teapot)
GL_DEPTH_TEST(GL_LESS)
}
PIPELINE_MAIN:showTeapotPipeline
{
OUTPUT_PORTS(outputTexture)
FILTER_INSTANCE:showTeapotFilter
}
Sample output :