Explorar o código

Minor refactoring

Panagiotis Christopoulos Charitos %!s(int64=10) %!d(string=hai) anos
pai
achega
8dcb0739f9
Modificáronse 2 ficheiros con 23 adicións e 25 borrados
  1. 3 6
      include/anki/util/Filesystem.h
  2. 20 19
      shaders/PpsSslf.frag.glsl

+ 3 - 6
include/anki/util/Filesystem.h

@@ -3,8 +3,7 @@
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 
-#ifndef ANKI_UTIL_DIRECTORY_H
-#define ANKI_UTIL_DIRECTORY_H
+#pragma once
 
 #include "anki/util/String.h"
 
@@ -31,8 +30,8 @@ Bool directoryExists(const CString& dir);
 /// - 3rd parameter: True if it's directory, false if it's regular file.
 using WalkDirectoryTreeCallback = Error(*)(const CString&, void*, Bool);
 
-/// Walk a directory and it's subdirectories. Will walk and list all the
-// directories and files of a directory.
+/// Walk a directory and it's subdirectories. Will walk and list all
+/// directories and files of a directory.
 ANKI_USE_RESULT Error walkDirectoryTree(
 	const CString& dir,
 	void* userData,
@@ -54,5 +53,3 @@ ANKI_USE_RESULT Error getHomeDirectory(
 
 } // end namespace anki
 
-#endif
-

+ 20 - 19
shaders/PpsSslf.frag.glsl

@@ -12,22 +12,23 @@
 #define MAX_GHOSTS 4
 #define GHOST_DISPERSAL (0.7)
 #define HALO_WIDTH 0.4
-#define CHROMATIC_DISTORTION 4.0
+#define CHROMATIC_DISTORTION 6.0
 #define ENABLE_CHROMATIC_DISTORTION 1
 #define ENABLE_HALO 1
+#define HALO_OPACITY 0.5
 
-layout(location = 0) in vec2 inTexCoord;
+layout(location = 0) in vec2 in_texCoord;
 
-layout(binding = 0) uniform sampler2D uRt;
-layout(binding = 1) uniform sampler2D uLensDirtTex;
+layout(binding = 0) uniform sampler2D u_rt;
+layout(binding = 1) uniform sampler2D u_lensDirtTex;
 
-layout(location = 0) out vec3 outColor;
+layout(location = 0) out vec3 out_color;
 
 vec3 textureDistorted(
 	in sampler2D tex,
 	in vec2 texcoord,
 	in vec2 direction, // direction of distortion
-	in vec3 distortion) // per-channel distortion factor  
+	in vec3 distortion) // per-channel distortion factor
 {
 #if ENABLE_CHROMATIC_DISTORTION
 	return vec3(
@@ -41,15 +42,15 @@ vec3 textureDistorted(
 
 void main()
 {
-	vec2 texcoord = vec2(1.0) - inTexCoord;
+	vec2 texcoord = vec2(1.0) - in_texCoord;
 
 	vec2 ghostVec = (vec2(0.5) - texcoord) * GHOST_DISPERSAL;
 
 	const vec2 texelSize = 1.0 / vec2(TEX_DIMENSIONS);
 
 	const vec3 distortion = vec3(
-		-texelSize.x * CHROMATIC_DISTORTION, 
-		0.0, 
+		-texelSize.x * CHROMATIC_DISTORTION,
+		0.0,
 		texelSize.x * CHROMATIC_DISTORTION);
 
 	const float lenOfHalf = length(vec2(0.5));
@@ -58,31 +59,31 @@ void main()
 
 	vec3 result = vec3(0.0);
 
-	// sample ghosts:  
-	for(int i = 0; i < MAX_GHOSTS; ++i) 
-	{ 
+	// sample ghosts:
+	for(int i = 0; i < MAX_GHOSTS; ++i)
+	{
 		vec2 offset = fract(texcoord + ghostVec * float(i));
 
 		float weight = length(vec2(0.5) - offset) / lenOfHalf;
 		weight = pow(1.0 - weight, 10.0);
 
-		result += 
-			textureDistorted(uRt, offset, direction, distortion) * weight;
+		result +=
+			textureDistorted(u_rt, offset, direction, distortion) * weight;
 	}
 
 	// sample halo
 #if ENABLE_HALO
 	vec2 haloVec = normalize(ghostVec) * HALO_WIDTH;
-	float weight = 
+	float weight =
 		length(vec2(0.5) - fract(texcoord + haloVec)) / lenOfHalf;
 	weight = pow(1.0 - weight, 20.0);
-	result += textureDistorted(uRt, texcoord + haloVec, direction, distortion) 
-		* weight;
+	result += textureDistorted(u_rt, texcoord + haloVec, direction, distortion)
+		* (weight * HALO_OPACITY);
 #endif
 
 	// lens dirt
-	result *= texture(uLensDirtTex, inTexCoord).rgb;
+	result *= texture(u_lensDirtTex, in_texCoord).rgb;
 
 	// Write
-	outColor = result;
+	out_color = result;
 }