[SOLVED] CS代考计算机代写 // phong vertex shader WITH TEXTURES

30 $

File Name: CS代考计算机代写_//_phong_vertex_shader_WITH_TEXTURES.zip
File Size: 565.2 KB

SKU: 0396943985 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


// phong vertex shader WITH TEXTURES

#version 300 es

uniform mat4 MVP;// OCS-to-CCS
uniform mat4 MV;// OCS-to-VCS

layout (location = 0) in vec3 vertPosition;
layout (location = 1) in vec3 vertNormal;
layout (location = 2) in vec2 vertTexCoords; // just another vertex attribute

smooth out mediump vec3 colour;// smooth = interpolated across triangle
smooth out mediump vec3 normal;
smooth out mediump vec2 texCoords;
smooth out mediump float depth;

void main()

{
// calc vertex position in CCS

mediump vec4 ccs_pos = MVP * vec4( vertPosition, 1.0f );
gl_Position = ccs_pos;

// Depth

depth = 0.5 * ((ccs_pos.z / ccs_pos.w) + 1.0); /* depth in [0,1] */

// assign (r,g,b) colour

colour = 2.0 * vec3( 0.33, 0.42, 0.18 );

// calc normal in VCS
//
// To do this, apply the non-translational parts of MV to the model
// normal.The 0.0 as the fourth component of the normal ensures
// that no translational component is added.

normal = vec3( MV * vec4( vertNormal, 0.0 ) );

// Texture coordinates

texCoords = vertTexCoords;
}

Reviews

There are no reviews yet.

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

Shopping Cart
[SOLVED] CS代考计算机代写 // phong vertex shader WITH TEXTURES
30 $