Skip to content

Commit

Permalink
v30
Browse files Browse the repository at this point in the history
  • Loading branch information
DarthShader committed Sep 10, 2020
1 parent f70ccfe commit d44684d
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 86 deletions.
3 changes: 2 additions & 1 deletion Shaders/Kaj/Editor/KajShaderEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ public enum UVMapping
XYObjectPlanar,
YZObjectPlanar,
ZXObjectPlanar,
Screenspace
Screenspace,
Panosphere
}

// Simple indent and unindent decorators
Expand Down
11 changes: 10 additions & 1 deletion Shaders/Kaj/Editor/KajShaderOptimizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ public class ShaderOptimizer
// by hard-removing the shadowcaster and fwdadd passes from the shader being optimized.
public static readonly string DisabledLightModesPropertyName = "_LightModes";

// Property that determines whether or not to evaluate KSOInlineSamplerState comments.
// Inline samplers can be used to get a wider variety of wrap/filter combinations at the cost
// of only having 1x anisotropic filtering on all textures
public static readonly string UseInlineSamplerStatesPropertyName = "_InlineSamplerStates";
private static bool UseInlineSamplerStates = true;

// Properties can be assigned to preprocessor defined keywords via the optimizer (//KSOPropertyKeyword)
// This is mainly targeted at culling interpolators and lines that rely on that input.
// (The compiler is not smart enough to cull VS output that isn't used anywhere in the PS)
Expand Down Expand Up @@ -177,6 +183,9 @@ public static bool Lock(Material material, MaterialProperty[] props)
// Properties ending with convention suffix will be skipped!
if (prop.name.EndsWith(AnimatedPropertySuffix)) continue;

if (prop.name == UseInlineSamplerStatesPropertyName)
UseInlineSamplerStates = (prop.floatValue == 1);

// Check for the convention 'Animated' Property to be true otherwise assume all properties are constant
MaterialProperty animatedProp = Array.Find(props, x => x.name == prop.name + AnimatedPropertySuffix);
if (animatedProp != null && animatedProp.floatValue == 1)
Expand Down Expand Up @@ -471,7 +480,7 @@ private static bool ParseShaderFilesRecursiveNew(List<ParsedShaderFile> filesPar
}
}
// Specifically requires no whitespace between // and KSOEvaluateMacro
else if (lineParsed == "//KSOEvaluateMacro")
else if (UseInlineSamplerStates && lineParsed == "//KSOEvaluateMacro")
{
string macro = "";
string lineTrimmed = null;
Expand Down
Loading

0 comments on commit d44684d

Please sign in to comment.