Skip to content
This repository was archived by the owner on Dec 24, 2019. It is now read-only.

Commit e9fef09

Browse files
committed
Unknown issue
trying to revert wrong changes
1 parent 711842c commit e9fef09

3 files changed

Lines changed: 41 additions & 18 deletions

File tree

Serie 4/Computergrafik-Basecode-master/jrtr/shaders/custom.frag

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ void main()
5454
sum.x = 0; sum.y = 0; sum.z=0;
5555

5656
for (int i=0; i<nLights; i++){
57-
// sum.x = sum.x + specularRadience[i].x * specularReflection.x * pow(R.x * E.x, p);
58-
// sum.y = sum.y + specularRadience[i].y * specularReflection.y * pow(R.y * E.y, p);
59-
// sum.z = sum.z + specularRadience[i].z * specularReflection.z * pow(R.z * E.z, p);
57+
sum.x = sum.x + specularRadience[i].x * specularReflection.x * pow(R[i].x * E.x, p);
58+
sum.y = sum.y + specularRadience[i].y * specularReflection.y * pow(R[i].y * E.y, p);
59+
sum.z = sum.z + specularRadience[i].z * specularReflection.z * pow(R[i].z * E.z, p);
6060
}
6161

62-
//frag_shaded.x = frag_shaded.x + sum.x;
63-
//frag_shaded.y = frag_shaded.y + sum.y;
64-
//frag_shaded.z = frag_shaded.z + sum.z;
62+
frag_shaded.x = frag_shaded.x + sum.x;
63+
frag_shaded.y = frag_shaded.y + sum.y;
64+
frag_shaded.z = frag_shaded.z + sum.z;
6565
// --------------------------------------------------------------------------------------------
6666

6767
}

Serie 4/Computergrafik-Basecode-master/jrtr/shaders/custom.vert

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ uniform mat4 projection;
88
uniform mat4 modelview;
99
uniform int nLights;
1010
uniform vec4 lightDirection[8];
11-
uniform vec4 camerPosition;
11+
uniform vec4 cameraPosition;
1212

1313
// Input vertex attributes; passed in from host program to shader
1414
// via vertex buffer objects
@@ -37,20 +37,21 @@ void main()
3737
for (int i=0; i< nLights; i++){
3838
ndotl[i] = max(dot(modelview * vec4(normal,0), lightDirection[i]),0);
3939
}
40-
40+
41+
// --------------------------------------------------
42+
4143
for (int i=0; i< nLights; i++){
4244
R[i].x = max(2 * dot(lightDirection[i], vec4(normal,0)) * normal.x - lightDirection[i].x, 0);
4345
R[i].y = max(2 * dot(lightDirection[i], vec4(normal,0)) * normal.y - lightDirection[i].y, 0);
4446
R[i].z = max(2 * dot(lightDirection[i], vec4(normal,0)) * normal.z - lightDirection[i].z, 0);
4547
R[i].w = 0;
4648
}
4749

48-
// --------------------------------------------------
50+
E.x = position.x - cameraPosition.x;
51+
E.y = position.y - cameraPosition.y;
52+
E.z = position.z - cameraPosition.z;
53+
E.w = 0;
4954

50-
// COMPONENTS?
51-
E.x = position.x - cameraPosition.x;
52-
E.y = position.y - cameraPosition.y;
53-
E.z = position.z - cameraPosition.z;
5455
// --------------------------------------------------
5556

5657

Serie 4/Computergrafik-Basecode-master/simple/src/main/java/simple/simple.java

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,14 @@ public void init(RenderContext r) {
8989
// TODO: Add light sources
9090
Light l = new Light();
9191
l.direction = new Vector3f(-1, 0, 0);
92+
l.diffuse = new Vector3f(1, 1, 1);
93+
l.specular = new Vector3f(1, 1, 1);
9294
sceneManager.addLight(l);
9395

9496
l = new Light();
9597
l.direction = new Vector3f(1, 0, 0);
98+
l.diffuse = new Vector3f(1, 1, 1);
99+
l.specular = new Vector3f(1, 1, 1);
96100
sceneManager.addLight(l);
97101

98102
// Add the scene to the renderer
@@ -231,20 +235,38 @@ public void keyPressed(KeyEvent e) {
231235
break;
232236
}
233237
case 'm': {
234-
// Set a material for more complex shading of the shape
238+
235239
if (shape.getMaterial() == null) {
240+
material.shader = diffuseShader;
236241
shape.setMaterial(material);
237242
} else {
238243
shape.setMaterial(null);
239244
renderContext.useDefaultShader();
240245
}
246+
// Set a material for more complex shading of the shape
247+
/*if (shape.getMaterial() == null) {
248+
Material diffuseMaterial = new Material();
249+
diffuseMaterial.shader = diffuseShader;
250+
diffuseMaterial.texture = renderContext.makeTexture();
251+
try {
252+
diffuseMaterial.texture.load("../textures/plant.jpg");
253+
} catch (Exception ex) {
254+
System.out.print("Could not load texture.\n");
255+
System.out.print(ex.getMessage());
256+
}
257+
258+
shape.setMaterial(diffuseMaterial);
259+
} else {
260+
shape.setMaterial(null);
261+
renderContext.useDefaultShader();
262+
}*/
241263
break;
242264
}
243-
265+
244266
case 'c': {
245267
// Set a material for more complex shading of the shape
246268
if (shape.getMaterial() == null) {
247-
269+
248270
Material customMaterial = new Material();
249271
customMaterial.shader = customShader;
250272
customMaterial.texture = renderContext.makeTexture();
@@ -254,8 +276,8 @@ public void keyPressed(KeyEvent e) {
254276
System.out.print("Could not load texture.\n");
255277
System.out.print(ex.getMessage());
256278
}
257-
258-
shape.setMaterial(material);
279+
280+
shape.setMaterial(customMaterial);
259281
} else {
260282
shape.setMaterial(null);
261283
renderContext.useDefaultShader();

0 commit comments

Comments
 (0)