This assignment makes use of the files contained in this zip file. This assignment is due Monday, November 3.
This assignment is based on a new version of the renderer, basic_renderer_2. The new version of the renderer is a "programmable renderer" (much like a modern graphics card). It lets you add new stages to the rendering pipeline. These new stages are usually called "shaders". In this assignment you will write a "shader program". This gives you practice in using the ideas that we covered in class when we talked about the various pipeline stages of the renderer. (The jar files that you need from the new version of the renderer are already in the homework zip file.)
In the zip file there is code for three demonstration shaders called DropShader.java
, ShrinkShader.java
, and ColorShader.java
. There are also three client programs that use these shaders, DropShaderClient.java
ShrinkShaderClient.java
, and ColorShaderClient.java
. These programs give you an idea of how to write a shader program and how to write a client program that builds a custom rendering pipeline that uses the shader.
For the first part of this assignment, you need to write a shader called DashedShader.java
. The Dashed shader takes every line segment in a model and makes the line segment into a "dashed line". The shader should do this by replacing each line segment with three new shorter line segments that have gaps between them. More specifically, the shader should divide each line segment into five equal sized parts and then create three new line segments that are equal to the first, third, and fifth parts of the original line segment (and so the gaps are the second and fourth parts of the original line segment).
<\p>
Recall from class that the line segment from vertex v[0]
to vertex v[1]
can be parameterized as
(1-t) * v[0] + t * v[1] with 0 <= t <= 1.
This parameterization is the main trick that you need for cutting a line segment up into five equal size pieces.
A shader program is a pipeline stage, so you use a shader by putting it in the list of PipelineStage
objects in a SceneRender
object. An important question to ask about any shader is where in the pipeline it should be placed. The Dashed shader can be place in a pipeline anywhere before the rasterizer stage. But this shader will give different results depending on exactly where it is placed in the pipeline. As the second part of this assignment, write a text file that gives an explanation of why, for a given Scene
, the rendered image of that Scene
can change if the DashedShader is moved from one place in the pipeline to a different place in the pipeline.
Then, as the third part of this assignment, write the client program DashedShaderClient.java
so that it gives a demonstration of how moving the location of DashedShader in the pipeline can change the resulting image from rendering a particular scene.
The demonstration shader ColorShader.java
is like DashedShader in that it produces different results depending on where the shader is placed in a pipeline. The client program ColorShaderClient.java
shows this by creating a specific Scene
, then creating two SceneRender
objects, each with the ColorShader in a different place in the pipeline, and then rendering the scene twice into two side-by-side viewports. The resulting framebuffer shows two renderings of the same scene. Use the outline of ColorShaderClient.java
to help you write your version of DashedShaderClient.java
.
Turn in a zip file called CS455Hw3Surname.zip
(where Surname
is your last name) containing your versions of DashedShader.java
, DashedShaderClient.java
, and your explanation for part two.
This assignment is due Monday, November 3.