Skip to content

Commit

Permalink
Merge pull request #24 from Xiexe/development
Browse files Browse the repository at this point in the history
fix small bug with stippling and add example mat
  • Loading branch information
Xiexe committed Jul 5, 2020
2 parents e820a3d + 516d851 commit 744eb05
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 6 deletions.
17 changes: 11 additions & 6 deletions Main/CGIncludes/XSLighting.cginc
Expand Up @@ -51,7 +51,9 @@ half4 BRDF_XSLighting(XSLighting i)
half4 outlineColor = calcOutlineColor(i, d, indirectDiffuse, lightCol);

half lineHalftone = 0;
half stippling = 0;
half stipplingDirect = 0;
half stipplingRim = 0;
half stipplingIndirect = 0;
bool usingLineHalftone = 0;
if(_HalftoneType == 0 || _HalftoneType == 2)
{
Expand All @@ -61,10 +63,13 @@ half4 BRDF_XSLighting(XSLighting i)

if(_HalftoneType == 1 || _HalftoneType == 2)
{
stippling = DotHalftone(i, saturate(dot(directSpecular + rimLight + directSpecular, grayscaleVec))) * saturate(dot(shadowRim * ramp, grayscaleVec));
directSpecular *= stippling;
indirectSpecular *= lerp(0.5, 1, stippling); // Don't want these to go completely black, looks weird
rimLight *= stippling;
stipplingDirect = DotHalftone(i, saturate(dot(directSpecular, grayscaleVec))) * saturate(dot(shadowRim * ramp, grayscaleVec));
stipplingRim = DotHalftone(i, saturate(dot(rimLight, grayscaleVec))) * saturate(dot(shadowRim * ramp, grayscaleVec));
stipplingIndirect = DotHalftone(i, saturate(dot(indirectSpecular, grayscaleVec))) * saturate(dot(shadowRim * ramp, grayscaleVec));

directSpecular *= stipplingDirect;
rimLight *= stipplingRim;
indirectSpecular *= lerp(0.5, 1, stipplingIndirect); // Don't want these to go completely black, looks weird
}

half4 col;
Expand All @@ -77,6 +82,6 @@ half4 BRDF_XSLighting(XSLighting i)
col += calcEmission(i, lightAvg);

float4 finalColor = lerp(col, outlineColor, i.isOutline) * lerp(1, lineHalftone, _HalftoneLineIntensity * usingLineHalftone);
//finalColor = lerp(finalColor, stippling, 0.9999);
//finalColor = lerp(finalColor, rimLight.xyzz, 0.9999);
return finalColor;
}
145 changes: 145 additions & 0 deletions XSToon 2.0 _ StippledHalftone.mat
@@ -0,0 +1,145 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: XSToon 2.0
m_Shader: {fileID: 4800000, guid: 85c615217d617204cb497ae6838b8bae, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 6
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BakedCubemap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Matcap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OutlineMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Ramp:
m_Texture: {fileID: 2800000, guid: 529b95e318b684643b47bd73e037118a, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _RampSelectionMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ReflectivityMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecularMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ThicknessMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AdvMode: 0
- _AnisotropicAX: 0.25
- _AnisotropicAY: 0.75
- _BumpScale: 1
- _ClearCoat: 0
- _ClearcoatSmoothness: 0.8
- _ClearcoatStrength: 1
- _Culling: 2
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _EmissionToDiffuse: 0
- _Glossiness: 0
- _HalftoneDotAmount: 50
- _HalftoneDotSize: 1.7
- _HalftoneLineAmount: 150
- _Metallic: 0
- _OutlineWidth: 1
- _ReflectionBlendMode: 0
- _ReflectionMode: 3
- _Reflectivity: 1
- _RimIntensity: 0
- _RimRange: 0.7
- _RimSharpness: 0.1
- _RimThreshold: 0.1
- _SSDistortion: 1
- _SSPower: 1
- _SSSRange: 1
- _SSSSharpness: 0.2
- _SSScale: 1
- _Saturation: 1
- _ScaleWithLight: 1
- _ScaleWithLightSensitivity: 1
- _ShadowRimRange: 0.7
- _ShadowRimSharpness: 0.3
- _ShadowRimThreshold: 0.1
- _ShadowSharpness: 0.5
- _SpecMode: 0
- _SpecularAlbedoTint: 1
- _SpecularArea: 0.5
- _SpecularIntensity: 0
- _SpecularStyle: 0
- _Stencil: 0
- _StencilComp: 0
- _StencilOp: 0
- _TilingMode: 0
- _UVSetAlbedo: 0
- _UVSetDetMask: 0
- _UVSetDetNormal: 0
- _UVSetEmission: 0
- _UVSetMetallic: 0
- _UVSetNormal: 0
- _UVSetOcclusion: 0
- _UVSetReflectivity: 0
- _UVSetSpecular: 0
- _UVSetThickness: 0
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 0}
- _MatcapTint: {r: 1, g: 1, b: 1, a: 1}
- _OcclusionColor: {r: 0, g: 0, b: 0, a: 0}
- _OutlineColor: {r: 0, g: 0, b: 0, a: 1}
- _RimColor: {r: 1, g: 1, b: 1, a: 1}
- _SSColor: {r: 0, g: 0, b: 0, a: 0}
- _ShadowRim: {r: 1, g: 1, b: 1, a: 1}
8 changes: 8 additions & 0 deletions XSToon 2.0 _ StippledHalftone.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 744eb05

Please sign in to comment.