Jelajahi Sumber

Minor fix pbr forward

ShiroSmith 4 tahun lalu
induk
melakukan
4fda69d305

+ 2 - 6
hrt/shader/AnisotropicFoward.hx

@@ -143,7 +143,7 @@ class AnisotropicFoward extends h3d.shader.pbr.DefaultForward {
 				var G = 1. / (1. + lambda_wo + lambda_wi);
 
 				var specular = (D * F * G) / ( 4. * cos_theta(wi) * cos_theta(wo) ) ;
-				var diffuse = albedo / PI * (1.0 - metalness);
+				var diffuse = albedoGamma / PI * (1.0 - metalness);
 
 				result = (diffuse + specular) * lightColor * wg_dot_wi;
 			}
@@ -162,7 +162,7 @@ class AnisotropicFoward extends h3d.shader.pbr.DefaultForward {
 			var rotatedReflecVec = rotateNormal(reflectVec);
 
 			var F = F0 + (max(vec3(1 - roughness), F0) - F0) * exp2( ( -5.55473 * NdV - 6.98316) * NdV );
-			var diffuse = irrDiffuse.get(rotatedNormal).rgb * albedo;
+			var diffuse = irrDiffuse.get(rotatedNormal).rgb * albedoGamma;
 			var envSpec = textureLod(irrSpecular, rotatedReflecVec, roughness * irrSpecularLevels).rgb;
 			var envBRDF = irrLut.get(vec2(roughness, NdV));
 			var specular = envSpec * (F * envBRDF.x + envBRDF.y);
@@ -174,10 +174,6 @@ class AnisotropicFoward extends h3d.shader.pbr.DefaultForward {
 		function init() {
 			view = (cameraPosition - transformedPosition).normalize();
 			NdV = transformedNormal.dot(view).max(0.);
-			metalness = output.metalness;
-			roughness = output.roughness;
-			occlusion = output.occlusion;
-			emissive = output.emissive;
 			var tmp = cross(direction * global.modelView.mat3(), transformedNormal).normalize();
 			bitangentWorld = cross(tmp, transformedNormal).normalize();
 			tangentWorld = cross(bitangentWorld, transformedNormal).normalize();

+ 2 - 2
hrt/shader/ParticleForward.hx

@@ -18,7 +18,7 @@ class ParticleForward extends h3d.shader.pbr.DefaultForward implements h3d.scene
 			var indirect = diffuse * irrPower * indirectLightingIntensity;
 			return indirect;
 		}
-		
+
 		function directLighting( lightColor : Vec3, lightDirection : Vec3) : Vec3 {
 			var result = vec3(0);
 
@@ -45,7 +45,7 @@ class ParticleForward extends h3d.shader.pbr.DefaultForward implements h3d.scene
 				lightAccumulation += evaluateSpotLight(l);
 
 			// Indirect only support the main env from the scene at the moment
-			if( USE_INDIRECT > 0.0)
+			if( USE_INDIRECT )
 				lightAccumulation += indirectLighting();
 
 			return lightAccumulation;

+ 2 - 3
hrt/shader/SpecularColor.hx

@@ -2,10 +2,10 @@ package hrt.shader;
 
 class SpecularColorAlbedo extends hxsl.Shader {
 	static var SRC = {
-		var albedo : Vec3;
+		var albedoGamma : Vec3;
 		var customSpecularColor : Vec3;
 		function fragment() {
-			customSpecularColor = albedo;
+			customSpecularColor = albedoGamma;
 		}
 	}
 }
@@ -38,7 +38,6 @@ class SpecularColor extends hxsl.Shader {
 		@param var specularTint : Float;
 		var customSpecularColor : Vec3;
 		var pbrSpecularColor : Vec3;
-		var albedo : Vec3;
 		
 		function fragment() {
 			pbrSpecularColor = mix(vec3(1.0), customSpecularColor, specularTint) * vec3(specular * 0.08);