Some setup.

This commit is contained in:
Alex 2017-04-25 17:19:36 -05:00
parent fa82da8919
commit c92bb00601
4 changed files with 63 additions and 1 deletions

1
A6/README.txt Normal file
View file

@ -0,0 +1 @@
This mesh was initially created using Cosmic Blobs software developed by Dassault Systemes SolidWorks Corp.

37
A6/resources/frag.glsl Normal file
View file

@ -0,0 +1,37 @@
#version 120
uniform mat4 MVL;
uniform vec3 lightPos1;
uniform vec3 lightPos2;
uniform vec3 ka;
uniform vec3 kd;
uniform vec3 ks;
uniform float s;
uniform float i1;
uniform float i2;
varying vec3 color; // passed from the vertex shader
varying vec4 p;
varying vec4 n;
void main()
{
vec4 normal = normalize(n);
vec3 norm = vec3(normal.x, normal.y, normal.z);
vec4 npos = normalize(p);
vec3 pos = vec3(npos.x, npos.y, npos.z);
vec3 lightnorm = vec3(MVL[3].x, MVL[3].y, MVL[3].z);
vec3 light = lightnorm - vec3(p.x, p.y, p.z);
vec3 lnorm = normalize(vec3(light.x,light.y,light.z));
float temp = dot(lnorm, norm);
vec3 cd = kd*max(0, temp);
vec3 h = normalize(lnorm - pos);
vec3 cs = ks*pow(max(0, dot(h, norm)), s);
vec4 c = vec4(ka.r + cd.r + cs.r, ka.g + cd.g + cs.g, ka.b + cd.b + cs.b, 1.0);
gl_FragColor = c;
}

24
A6/resources/vert.glsl Normal file
View file

@ -0,0 +1,24 @@
#version 120
uniform mat4 P;
uniform mat4 MV;
uniform mat4 MVL;
uniform vec3 lightPos1;
uniform vec3 lightPos2;
uniform float i1;
uniform float i2;
attribute vec4 aPos; // in object space
attribute vec3 aNor; // in object space
varying vec3 color; // Pass to fragment shader
varying vec4 p;
varying vec4 n;
void main()
{
gl_Position = P * MV * aPos;
p = MV * aPos;
n = MV * vec4(aNor, 0.0);
color = vec3(0.5, 0.5, 0.5);
}

View file

@ -90,7 +90,7 @@ void loadScene(const string &meshFile, const string &attachmentFile)
// For drawing the grid, etc.
progSimple = make_shared<Program>();
progSimple->setShaderNames(RESOURCE_DIR + "simple_vert.glsl", RESOURCE_DIR + "simple_frag.glsl");
progSimple->setShaderNames(RESOURCE_DIR + "vert.glsl", RESOURCE_DIR + "frag.glsl");
progSimple->setVerbose(true);
// For skinned shape, CPU/GPU