[Solved] Graphics Lab2-Toon Shading

$25

File Name: Graphics_Lab2-Toon_Shading.zip
File Size: 244.92 KB

SKU: [Solved] Graphics Lab2-Toon Shading Category: Tag:
5/5 - (1 vote)

In this lab we are going to write a simple Toon Shader. However before creating the shader we are going to modify the application code to make the process of linking to shaders uniforms easier. Download and open up the shader.h file. You will see new functions have been added. These functions allow us to set the values of the shaders uniform variables using glUniform and glGetUniformLocation. This code will be discussed in the lecture.

As our shader get more complex there will be certain details that we will want to pass to the shaders, in particular the model, view, and project matrices

Todo:

In the Camera.h file write two getters, one for the view matrix and one for the projection matrix.

Create a new vertex and a new fragment shader

Vertex Shader

Pass in the positions and the normals, these are stored in the vbos, i.e

layout (location = 0) in vec3 Position;

layout (location = 2) in vec3 Normals;

Create two variables one for our normals and the other for our transforms

varying vec3 normal;

uniform mat4 transform;

Inside the main method pass our normals to the fragment shader and set our new positions

normal = VertexNormal;

gl_Position = transform * vec4(VertexPosition, 1.0);

In the fragment shader

Create two variables one two hold the light direction and on is our normals from the vertex shader.

uniform vec3 lightDir;

varying vec3 normal;

Complete the following main

void main()

{

float intensity;

vec4 color;

to do: calculate intensity and control color based on intensity

gl_FragColor = color;

}

Now go back to the main game class and create a method that passes the light direction to the shader and run the code.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] Graphics Lab2-Toon Shading
$25