Skip to content

Instantly share code, notes, and snippets.

@xiaobin83
Created November 15, 2017 10:18
Show Gist options
  • Save xiaobin83/b62e3ac1f1f30a86b8312f52533bf29d to your computer and use it in GitHub Desktop.
Save xiaobin83/b62e3ac1f1f30a86b8312f52533bf29d to your computer and use it in GitHub Desktop.
fix shaderforge lightmap (shadowmask, baked-indirect and subtractive)
commit 3a23cbafc92f5dc4b3a1ab04b4a06d0d7733b66f
Author: xiaobin83 <[email protected]>
Date: Wed Nov 15 18:02:07 2017 +0800
fix lightmap issue
diff --git a/Assets/ShaderForge/Editor/Code/_Evaluator/SF_Evaluator.cs b/Assets/ShaderForge/Editor/Code/_Evaluator/SF_Evaluator.cs
index 282d252..59fbd9d 100644
--- a/Assets/ShaderForge/Editor/Code/_Evaluator/SF_Evaluator.cs
+++ b/Assets/ShaderForge/Editor/Code/_Evaluator/SF_Evaluator.cs
@@ -1107,7 +1107,16 @@ namespace ShaderForge {
}
}
- lmbStr = "float3 directDiffuse = " + lmbStr + " * attenColor";
+ if (HasGIData())
+ {
+
+ lmbStr = "float3 directDiffuse = " + lmbStr + " * gi.light.color";
+ }
+ else
+ {
+ lmbStr = "float3 directDiffuse = " + lmbStr + " * attenColor";
+ }
+
lmbStr += ";";
App( lmbStr );
}
@@ -1942,13 +1951,17 @@ namespace ShaderForge {
}
}
+
+ bool HasGIData()
+ {
+ return ( currentPass == PassType.FwdBase || currentPass == PassType.Deferred ) && ( ps.catLighting.lightMode == SFPSC_Lighting.LightMode.PBL || ps.catLighting.reflectprobed || LightmappedAndLit() );
+ }
void CalcGIdata(){
- if( ( currentPass == PassType.FwdBase || currentPass == PassType.Deferred ) && ( ps.catLighting.lightMode == SFPSC_Lighting.LightMode.PBL || ps.catLighting.reflectprobed || LightmappedAndLit() ) ) {
-
+ if (HasGIData()) {
AppDebug("GI Data");
@@ -1960,19 +1973,19 @@ namespace ShaderForge {
App( "light.ndotl = max(0,dot(normalDirection,light.dir));" );
} else {
App( "UnityLight light;" );
- App( "#ifdef LIGHTMAP_OFF" );
- scope++;
+ //App( "#ifdef LIGHTMAP_OFF" );
+ //scope++;
App( "light.color = lightColor;" );
App( "light.dir = lightDirection;" );
App( "light.ndotl = LambertTerm (normalDirection, light.dir);" );
- scope--;
- App( "#else" );
- scope++;
- App( "light.color = half3(0.f, 0.f, 0.f);" );
- App( "light.ndotl = 0.0f;" );
- App( "light.dir = half3(0.f, 0.f, 0.f);" );
- scope--;
- App( "#endif" );
+ //scope--;
+ //App( "#else" );
+ //scope++;
+ //App( "light.color = half3(0.f, 0.f, 0.f);" );
+ //App( "light.ndotl = 0.0f;" );
+ //App( "light.dir = half3(0.f, 0.f, 0.f);" );
+ //scope--;
+ //App( "#endif" );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment