1. Lazar Sumar
  2. Non-photorealistic Rendering

Commits

Lazar Sumar  committed a484880

Added changable toon levels.

  • Participants
  • Parent commits b82a4af
  • Branches default

Comments (0)

Files changed (3)

File NPR/main.cpp

View file
  • Ignore whitespace
 			clearShaders();
 			setShaders("pencil", shaderOutlining);
 		}
-	}  else if (key=='t' || key == 'T') {
+	} else if (key=='t' || key == 'T') {
 		if (shaderFilename != "toon") {
 			clearShaders();
 			setShaders("toon", shaderOutlining);
 		}
+	} else if (key=='[' || key == '{') {
+		if (toonLevels > 1) toonLevels--;
+	} else if (key==']' || key == '}') {
+		toonLevels++;
 	} else if (key>='0' && key <='4') {
 		changeLightDirection(key - '0');
 	} else if (key == '+' || key == '=') {

File NPR/metalic.frag

View file
  • Ignore whitespace
 		vec3 toColour = vec3(0.45, 0.2, 0.3);
 		int i;
 		float low = 0.0, high = 0.0;
+		float criteria = (EN + 1.0) / 2.0;
+
+		finalColour = vec4(toColour, 1.0);
 
 		for (i = 1; i < levels; i++) {
 			low = high;

File NPR/toon.frag

View file
  • Ignore whitespace
 		vec3 toColour = vec3(0.45, 0.2, 0.3);
 		int i;
 		float low = 0.0, high = 0.0;
+		float criteria = (EN + 1.0) / 2.0;
+
+		finalColour = vec4(toColour, 1.0);
 
 		for (i = 1; i < levels; i++) {
 			low = high;
 			high = float(i) * (1.0 / float(levels));
-			if (RE > low && RE < high) {
+			if (EN > low && EN < high) {
 				finalColour = vec4(mix(fromColour, toColour, high), 1.0);
 				break;
 			}