Skip to content

Commit

Permalink
added support for VRSL GI
Browse files Browse the repository at this point in the history
  • Loading branch information
orels1 committed Oct 13, 2024
1 parent 2361ece commit 1caccb1
Show file tree
Hide file tree
Showing 10 changed files with 193 additions and 13 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,6 @@ Assets/AmplifyShaderEditor.meta
Assets/XSToon3
Assets/XSToon3.meta
Assets/AreaLit
Assets/AreaLit.meta
Assets/AreaLit.meta
Assets/VRSL Addons
Assets/VRSL Addons.meta
12 changes: 6 additions & 6 deletions Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.burst": "1.7.3",
"com.unity.2d.sprite": "1.0.0",
"com.unity.mathematics": "1.1.0",
"com.unity.modules.uielements": "1.0.0",
"com.unity.modules.animation": "1.0.0",
"com.unity.burst": "1.7.3"
"com.unity.modules.uielements": "1.0.0"
},
"url": "https://packages.unity.com"
},
Expand All @@ -54,9 +54,9 @@
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.2d.animation": "9.1.1",
"com.unity.2d.common": "8.0.2",
"com.unity.2d.sprite": "1.0.0"
"com.unity.2d.sprite": "1.0.0",
"com.unity.2d.animation": "9.1.1"
},
"url": "https://packages.unity.com"
},
Expand Down Expand Up @@ -212,9 +212,9 @@
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.modules.audio": "1.0.0",
"com.unity.modules.director": "1.0.0",
"com.unity.modules.animation": "1.0.0",
"com.unity.modules.audio": "1.0.0",
"com.unity.modules.particlesystem": "1.0.0"
},
"url": "https://packages.unity.com"
Expand Down Expand Up @@ -243,9 +243,9 @@
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.modules.subsystems": "1.0.0",
"com.unity.modules.vr": "1.0.0",
"com.unity.modules.xr": "1.0.0",
"com.unity.modules.subsystems": "1.0.0",
"com.unity.xr.legacyinputhelpers": "2.1.7"
},
"url": "https://packages.unity.com"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
%Properties()
{
[ToggleUI]UI_VRSLGIHeader("# VRSL GI", Int) = 1
UI_VRSLGIDocs("[This module has documentation](https://shaders.orels.sh/docs/orl-standard/vrslgi)", Int) = 0
[Toggle(_VRSL_GI)]useVRSLGI("Integrate VRSL GI", Float) = 0.0
UI_VRSLGIDownload("[Make sure to download VRSLGI Shader Pack before enabling this option](https://github.com/AcChosen/VR-Stage-Lighting-GI-ShaderPack/releases)", Int) = 0
_VRSLGIStrength("VRSL GI Strength %ShowIf(_VRSL_GI)", Float) = 2
_VRSLDiffuseMix("VRSL Diffuse Mix %ShowIf(_VRSL_GI)", Range(0, 1)) = 0.25
[Toggle(_VRSL_GI_SPECULARHIGHLIGHTS)]useVRSLGISpecular("Use VRSL GI Specular %ShowIf(_VRSL_GI)", Float) = 1.0
[KeywordEnum(GGX, Beckman, Phong)]_VRSL_SPECFUNC("VRSL Specular Function %ShowIf(_VRSL_GI && _VRSL_GI_SPECULARHIGHLIGHTS)", Int) = 0 // Selecting the specular function.
_VRSLGISpecularClamp("Max Specular Brightness %ShowIf(_VRSL_GI && _VRSL_GI_SPECULARHIGHLIGHTS)", Range(1.0, 50000.0)) = 10000
[Toggle(_VRSL_SHADOWMASK1)]_UseVRSLShadowMask1("Use VRSL Shadow Mask 1 %ShowIf(_VRSL_GI)", Int) = 0 // The first shadow mask toggle
_VRSLShadowMask1("VRSL GI ShadowMask 1 > %ShowIf(_VRSL_GI && _VRSL_SHADOWMASK1)", 2D) = "white" {} // The first shadow mask texture
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, UV1_LightmapST, 9)]_VRSLShadowmaskUVSet("VRSL Shadow Mask UV Set %ShowIf(_VRSL_GI && _VRSL_SHADOWMASK1)", Int) = 1
[KeywordEnum(R, RG, RGB, RGBA)]_VRSL_SHADOWMASK("Active Channels %ShowIf(_VRSL_GI && _VRSL_SHADOWMASK1)", Int) = 3
_UseVRSLShadowMask1RStrength("VRSL SM 1 R Strength %ShowIf(_VRSL_GI && _VRSL_SHADOWMASK1)", Range(0.0, 1.0)) = 1.0 // the R strength of the first shadow mask
_UseVRSLShadowMask1GStrength("VRSL SM 1 G Strength %ShowIf(_VRSL_GI && _VRSL_SHADOWMASK1)", Range(0.0, 1.0)) = 1.0 // the G strength of the first shadow mask
_UseVRSLShadowMask1BStrength("VRSL SM 1 B Strength %ShowIf(_VRSL_GI && _VRSL_SHADOWMASK1)", Range(0.0, 1.0)) = 1.0 // the B strength of the first shadow mask
_UseVRSLShadowMask1AStrength("VRSL SM 1 A Strength %ShowIf(_VRSL_GI && _VRSL_SHADOWMASK1)", Range(0.0, 1.0)) = 1.0 // the A strength of the first shadow mask
}

%ShaderFeatures()
{
#pragma shader_feature_local_fragment _VRSL_GI
#pragma shader_feature_local_fragment _VRSL_SPECFUNC_GGX _VRSL_SPECFUNC_BECKMAN _VRSL_SPECFUNC_PHONG
#pragma shader_feature_local_fragment _VRSL_GI_SPECULARHIGHLIGHTS
#pragma shader_feature_local_fragment _VRSL_SHADOWMASK1
#pragma shader_feature_local_fragment _VRSL_GLOBALLIGHTTEXTURE
#pragma shader_feature_local_fragment _ _VRSL_SHADOWMASK_RG _VRSL_SHADOWMASK_RGB _VRSL_SHADOWMASK_RGBA
}

%CheckedInclude("Assets/VRSL Addons/VRSL-GI Shader Package/VRSLGI-Functions.cginc")

%Variables()
{
int _VRSLShadowmaskUVSet;
}

%ShaderDefines()
{
#if !defined(_VRSL_GI)
#define SKIP_VRSLGI
#endif
}

%Color("VRSLGIColor")
{

void VRSLGIColor(MeshData d, SurfaceData o, inout half4 FinalColor)
{
#if defined(PLAT_QUEST)
{
return;
}
#else
{
#if defined(_VRSL_GI) && !defined(SKIP_VRSLGI)
{
float2 uv = d.uv0.xy;
#if defined(LIGHTMAP_ON)
{
if (_VRSLShadowmaskUVSet == 9)
{
uv = d.uv1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
}
}
#else
{
switch (_VRSLShadowmaskUVSet)
{
case 1: uv = d.uv1.xy; break;
case 2: uv = d.uv2.xy; break;
case 3: uv = d.uv3.xy; break;
}
}
#endif

float oneMinusReflectivity = 1.0 - 0.04 - o.Metallic * (1.0 - 0.04);

_VRSLMetallicMapStrength = 1;
_VRSLSpecularShine = 1;
_VRSLSpecularMultiplier = 1;

float3 giOutput = VRSLGI(
d.worldSpacePosition,
Unity_SafeNormalize(mul(o.Normal, d.TBNMatrix)),
1 - o.Smoothness,
d.worldSpaceViewDir,
o.Albedo * oneMinusReflectivity,
float2(o.Metallic, o.Smoothness),
uv,
o.Occlusion
);

FinalColor.rgb += giOutput;
}
#endif
}
#endif
}
}

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

2 changes: 1 addition & 1 deletion Packages/sh.orels.shaders.generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "sh.orels.shaders.generator",
"displayName": "ORL Shader Generator",
"description": "A template-based shader generator utilizing scripted importers",
"version": "7.0.0-dev.1",
"version": "7.0.0-dev.2",
"unity": "2019.4",
"author": {
"name": "orels1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"rootNamespace": "",
"references": [
"GUID:a1653399f63795746b1857281d1e400d",
"GUID:7f2b18295eece7a49ab038d58f0c3037"
"GUID:7f2b18295eece7a49ab038d58f0c3037",
"GUID:45fa8258f46d2b3948d08a08fb82e8e8",
"GUID:a5857e7d50658ab468a75fe6fb42fda9"
],
"includePlatforms": [
"Editor"
Expand Down
2 changes: 1 addition & 1 deletion Packages/sh.orels.shaders.inspector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "sh.orels.shaders.inspector",
"displayName": "ORL Shader Inspector",
"description": "A simple property-based shader inspector with extension support",
"version": "7.0.0-dev.1",
"version": "7.0.0-dev.2",
"unity": "2019.4",
"author": {
"name": "orels1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
%ShaderName("orels1/Standard VRSL GI")
%CustomEditor("ORL.ShaderInspector.InspectorGUI")

%Includes()
{
"@/Shaders/ORL Standard",
"@/Modules/VRSLGI",
"self"
}

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

6 changes: 3 additions & 3 deletions Packages/sh.orels.shaders/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "sh.orels.shaders",
"displayName": "ORL Shaders",
"description": "PBR Unity shaders for the Built-In pipeline built with ORL Shader Generator",
"version": "7.0.0-dev.1",
"version": "7.0.0-dev.2",
"unity": "2019.4",
"author": {
"name": "orels1",
Expand All @@ -17,7 +17,7 @@
"license": "MIT",
"type": "assets",
"vpmDependencies": {
"sh.orels.shaders.generator": "^7.0.0-dev.1",
"sh.orels.shaders.inspector": "^7.0.0-dev.1"
"sh.orels.shaders.generator": "^7.0.0-dev.2",
"sh.orels.shaders.inspector": "^7.0.0-dev.2"
}
}

0 comments on commit 1caccb1

Please sign in to comment.