diff --git a/Assets/Examples/ExampleScene.unity b/Assets/Examples/ExampleScene.unity index 48eac9c..4d2bda4 100644 --- a/Assets/Examples/ExampleScene.unity +++ b/Assets/Examples/ExampleScene.unity @@ -297,6 +297,99 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &182411961 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 182411965} + - component: {fileID: 182411964} + - component: {fileID: 182411963} + - component: {fileID: 182411962} + m_Layer: 0 + m_Name: ORL Standard GradientMap + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!135 &182411962 +SphereCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 182411961} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Radius: 0.5 + m_Center: {x: 0, y: 0, z: 0} +--- !u!23 &182411963 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 182411961} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 7266852b7b67dc3498823563fcf1076f, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &182411964 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 182411961} + m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &182411965 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 182411961} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 3.707} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &195397332 GameObject: m_ObjectHideFlags: 0 diff --git a/Packages/com.lackofbindings.orlmodules/Runtime/Modules/GrabGradientMap.orlsource b/Packages/com.lackofbindings.orlmodules/Runtime/Modules/GrabGradientMap.orlsource new file mode 100644 index 0000000..f0f3a6b --- /dev/null +++ b/Packages/com.lackofbindings.orlmodules/Runtime/Modules/GrabGradientMap.orlsource @@ -0,0 +1,65 @@ +%Properties() +{ + UI_GradientMapHeader("# Gradient Map (Grab Pass)", Float) = 0 + _GradientMap ("Gradient (RGB) %Gradient()", 2D) = "white" {} + _DistortMagnitude("Distortion Magnitude", Range(0,1)) = 0.05 + _DistortThreshold("Distortion Threshold", Range(0,1)) = 0.01 +} + +%ShaderDefines() +{ + #define EXTRA_V2F_0 +} + +%PrePasses() +{ + GrabPass { "_GrabTexture1" } + + Pass + { + ZWrite On Lighting Off Cull Off Fog{ Mode Off } Blend One Zero + LOD 200 + } +} + +%Variables() +{ + half _DistortThreshold; + half _DistortMagnitude; +} + +%Textures() +{ + TEXTURE2D(_GradientMap); + SAMPLER(sampler_GradientMap); + SAMPLER(_GrabTexture1); +} + +%Vertex("GrabPassVertex") +{ + void GrabPassVertex(VertexData v, inout FragmentData o) + { + half4 vertex = UnityObjectToClipPos(v.vertex); + o.extraV2F0 = ComputeGrabScreenPos(vertex); // GrabPass UV + } +} + +%Fragment("GrabPassFragment") +{ + float linearToGamma(fixed4 c) + { + return pow(sqrt(c.rgb) + 0.25, 2.0); + } + + void GrabPassFragment(FragmentData i, inout SurfaceData o) + { + // Distortion: offset the UV data of the grab texture based on the normal map + i.extraV2F0.xy += (saturate(o.Normal.rg - _DistortThreshold)) * _DistortMagnitude; + + // Sample grab texture and map Luminance to value on input gradient + fixed4 color_GrabTex = tex2Dproj(_GrabTexture1, UNITY_PROJ_COORD(i.extraV2F0)); // apply the screen texture in the correct position + float2 gradientUV = float2(linearToGamma(Luminance(color_GrabTex.rgb)), 0.0); // convert luminance to UV X coordinate on gradient + fixed4 color_Result = SAMPLE_TEXTURE2D(_GradientMap, sampler_GradientMap, gradientUV); + o.Albedo *= sqrt(color_Result.rgb); //sqrt makes sRGB gradient textures have the right color values. + } +} diff --git a/Packages/com.lackofbindings.orlmodules/Runtime/Modules/GrabGradientMap.orlsource.meta b/Packages/com.lackofbindings.orlmodules/Runtime/Modules/GrabGradientMap.orlsource.meta new file mode 100644 index 0000000..4e78c1f --- /dev/null +++ b/Packages/com.lackofbindings.orlmodules/Runtime/Modules/GrabGradientMap.orlsource.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: c5b0827983b27294082ade4d1d1b5539 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: f43ee36a0ee244f697129b1aba052424, type: 3} diff --git a/Packages/com.lackofbindings.orlmodules/Runtime/Shaders/ORL Standard Gradient Map.orlshader b/Packages/com.lackofbindings.orlmodules/Runtime/Shaders/ORL Standard Gradient Map.orlshader new file mode 100644 index 0000000..1a65fcc --- /dev/null +++ b/Packages/com.lackofbindings.orlmodules/Runtime/Shaders/ORL Standard Gradient Map.orlshader @@ -0,0 +1,16 @@ +%ShaderName("orels1/Standard Gradient Map") +%CustomEditor("ORL.ShaderInspector.InspectorGUI") + +%Includes() +{ + "@/Shaders/ORL Standard", + "/Packages/com.lackofbindings.orlmodules/Runtime/Modules/GrabGradientMap", + "self" +} + +%ShaderTags() +{ + "Queue" = "Transparent" + "IgnoreProjector" = "True" + "RenderType" = "Opaque" +} \ No newline at end of file diff --git a/Packages/com.lackofbindings.orlmodules/Runtime/Shaders/ORL Standard Gradient Map.orlshader.meta b/Packages/com.lackofbindings.orlmodules/Runtime/Shaders/ORL Standard Gradient Map.orlshader.meta new file mode 100644 index 0000000..c362667 --- /dev/null +++ b/Packages/com.lackofbindings.orlmodules/Runtime/Shaders/ORL Standard Gradient Map.orlshader.meta @@ -0,0 +1,56 @@ +fileFormatVersion: 2 +guid: 59f6cd35009e3e94a9922e4deb7b5ae6 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 14030a0b230d45068f811d1ad116f246, type: 3} + serializationData: + SerializedFormat: 2 + SerializedBytes: + ReferencedUnityObjects: [] + SerializedBytesString: + Prefab: {instanceID: 0} + PrefabModificationsReferencedUnityObjects: [] + PrefabModifications: [] + SerializationNodes: + - Name: FunctionErrors + Entry: 7 + Data: 0|System.Collections.Generic.Dictionary`2[[UnityShaderParser.HLSL.FunctionDefinitionNode, + UnityShaderParser],[System.String, mscorlib]], mscorlib + - Name: comparer + Entry: 7 + Data: 1|System.Collections.Generic.ObjectEqualityComparer`1[[UnityShaderParser.HLSL.FunctionDefinitionNode, + UnityShaderParser]], mscorlib + - Name: + Entry: 8 + Data: + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: Errors + Entry: 7 + Data: 2|System.Collections.Generic.List`1[[ORL.ShaderGenerator.ShaderDefinitionImporter+ShaderError, + ORL.ShaderGenerator]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + debugBuild: 0 + samplerCount: 0 + textureCount: 0 + featureCount: 0 diff --git a/README.md b/README.md index 561d504..8bd2a8a 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,11 @@ This VPM provides custom modules for the [ORL shader suite](https://shaders.orel ## Included Modules: -#### Stencil Options +### Stencil Options This Module provides the standard stencil masking options (stencil mask value, pass/fail/comparison, etc.) -#### AudioLink Pathing +### AudioLink Pathing This module ports the AudioLink code from [Silent's Cell Shading Shader](https://gitlab.com/s-ilent/SCSS) to ORL Standard. This provides Furality/Poiyomi-Pathing style AudioLink. @@ -17,12 +17,16 @@ This module ports the AudioLink code from [Silent's Cell Shading Shader](https:/ 2. Furality-style with a separate channel (AL band) map and sweep (direction) map. 3. A simplified Furality-style mode that loses the 4th AL band in favor of packing in the sweep (direction) map into the alpha channel, thus only requiring one texture. -This module also features a toggle to flip the direction of the sweep, since some shaders (Poiyomi, Furality, SCSS) interpret the sweep map differently. +This module also features a toggle to flip the direction of the sweep, since some shaders (Poiyomi) interpret the sweep map differently. -#### 2nd Emission +### 2nd Emission This module adds a secondary emission texture slot. It provides its own tint color, UV channel, and RGB channel options. It shares the same tiling, offsets, sampler, and keyword with the base emission slot. +### Gradient Map (Grab Pass) + +This module multiplies the albedo by a grab pass, where the grab pass has been mapped to a color gradient based on its luminance value (think "Color Ramp" in Blender or "Gradient Map" in Photoshop). This is mostly a novelty, but could be used to make a glass surface that stylizes other objects viewed through it. + ## How to Install ### Dependencies @@ -51,6 +55,7 @@ Ready-to-use variants of ORL Standard can be found when making a new material: - `orels1/Standard Stencil` - `orels1/Standard Audiolink Pathing` - `orels1/Standard 2nd Emission` +- `orels1/Standard Gradient Map` #### As a module