Skip to content

Commit

Permalink
Merge branch 'feat/new-shaders' of https://github.com/decentraland/we…
Browse files Browse the repository at this point in the history
…arable-preview into feat/new-shaders
  • Loading branch information
mayankdigii committed Nov 25, 2024
2 parents b28e8b9 + 3e6337a commit dc694ed
Showing 1 changed file with 53 additions and 81 deletions.
134 changes: 53 additions & 81 deletions src/lib/babylon/explorer-alpha-shader/fragment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,61 @@ precision highp float;
#define INT_MAX 0x7FFFFFFF
#define rsqrt 1.0/sqrt
// Lights
in vec3 vPositionW;
in vec3 vNormalW;
in vec2 vUV;
//in vec3 normalDir;
//in vec3 tangentDir;
//in vec3 bitangentDir;
//in float mirrorFlag;
//in vec4 positionCS;
// Babylon Defaults
uniform vec4 _WorldSpaceCameraPos;
uniform mat4 world;
uniform mat4 worldView;
#define unity_ObjectToWorld world
#define UNITY_MATRIX_V worldView
// Decentraland Material Specific
uniform vec4 _Emissive_Color; // 0.00, 0.00, 0.00, 1.00
// Decentraland Scene Specific
uniform vec4 _LightDirection; // Distance Attenuation in the final w slot
uniform vec4 _LightColor;
// Texture sampler inputs
uniform sampler2D textureSampler;
uniform sampler2D sampler_BaseMap;
uniform sampler2D sampler_BumpMap;
uniform sampler2D sampler_EmissionMap;
uniform sampler2D sampler_MainTex;
uniform sampler2D sampler_1st_ShadeMap;
uniform sampler2D sampler_2nd_ShadeMap;
uniform sampler2D sampler_NormalMap;
uniform sampler2D sampler_ClippingMask;
uniform sampler2D sampler_OcclusionMap;
uniform sampler2D sampler_MetallicGlossMap;
uniform sampler2D sampler_Set_1st_ShadePosition;
uniform sampler2D sampler_Set_2nd_ShadePosition;
uniform sampler2D sampler_ShadingGradeMap;
uniform sampler2D sampler_HighColor_Tex;
uniform sampler2D sampler_Set_HighColorMask;
uniform sampler2D sampler_Set_RimLightMask;
uniform sampler2D sampler_MatCap_Sampler;
uniform sampler2D sampler_NormalMapForMatCap;
uniform sampler2D sampler_Set_MatcapMask;
uniform sampler2D sampler_Emissive_Tex;
uniform sampler2D sampler_AngelRing_Sampler;
uniform sampler2D sampler_Outline_Sampler;
uniform sampler2D sampler_OutlineTex;
uniform sampler2D sampler_BakedNormal;
// Refs
// Output
out vec4 fragColor;
// Unity Material and Scene Inputs - Hardcoded for ease
float _AlphaToMaskAvailable = 1.0;
float _Clipping_Level = 0.0;
float _Unlit_Intensity = 4.0;
Expand Down Expand Up @@ -110,8 +158,6 @@ float _BumpScale = 1.0;
vec4 _EmissionColor = vec4(0.0, 0.0, -3.77099e+15, 4.59037e-41);
vec4 _GlossyEnvironmentColor = vec4(0.0, 0.0, 0.0, 0.0);
uniform vec4 _Emissive_Color; // 0.00, 0.00, 0.00, 1.00
// SH block feature
real4 unity_SHAr = vec4( 0.00f, -0.00973f, 0.00f, 0.41196f );
real4 unity_SHAg = vec4( 0.00f, 0.10704f, 0.00f, 0.30608f );
Expand All @@ -121,54 +167,6 @@ real4 unity_SHBg = vec4( 0.00f, 0.00f, 0.02523f, 0.00f );
real4 unity_SHBb = vec4( 0.00f, 0.00f, 0.05021f, 0.00f );
real4 unity_SHC = vec4( 0.0337f, 0.02523f, 0.05021f, 1.00f );
uniform vec4 _WorldSpaceCameraPos;
uniform mat4 world;
uniform mat4 worldView;
#define UNITY_MATRIX_V worldView
uniform sampler2D textureSampler;
uniform sampler2D sampler_BaseMap;
uniform sampler2D sampler_BumpMap;
uniform sampler2D sampler_EmissionMap;
uniform sampler2D sampler_MainTex;
uniform sampler2D sampler_1st_ShadeMap;
uniform sampler2D sampler_2nd_ShadeMap;
uniform sampler2D sampler_NormalMap;
uniform sampler2D sampler_ClippingMask;
uniform sampler2D sampler_OcclusionMap;
uniform sampler2D sampler_MetallicGlossMap;
uniform sampler2D sampler_Set_1st_ShadePosition;
uniform sampler2D sampler_Set_2nd_ShadePosition;
uniform sampler2D sampler_ShadingGradeMap;
uniform sampler2D sampler_HighColor_Tex;
uniform sampler2D sampler_Set_HighColorMask;
uniform sampler2D sampler_Set_RimLightMask;
uniform sampler2D sampler_MatCap_Sampler;
uniform sampler2D sampler_NormalMapForMatCap;
uniform sampler2D sampler_Set_MatcapMask;
uniform sampler2D sampler_Emissive_Tex;
uniform sampler2D sampler_AngelRing_Sampler;
uniform sampler2D sampler_Outline_Sampler;
uniform sampler2D sampler_OutlineTex;
uniform sampler2D sampler_BakedNormal;
out vec4 fragColor;
//in vec2 vUV;
//in vec4 posWorld;
//in vec3 normalDir;
//in vec3 tangentDir;
//in vec3 bitangentDir;
//in float mirrorFlag;
//in vec4 positionCS;
//uniform sampler2D textureSampler;
//out vec4 fragColor;
#define SAMPLE_BASEMAP(uv,texArrayID) texture(sampler_BaseMap, uv)
#define SAMPLE_BUMPMAP(uv,texArrayID) texture(sampler_BumpMap, uv)
#define SAMPLE_EMISSIONMAP(uv,texArrayID) texture(sampler_EmissionMap, uv)
Expand Down Expand Up @@ -196,7 +194,6 @@ out vec4 fragColor;
//#define TRANSFORM_TEX(tex, name) ((tex.xy) * name##_ST.xy + name##_ST.zw)
#define TRANSFORM_TEX(tex, name) tex.xy
#define unity_ObjectToWorld world
int _MainTexArr_ID = 0;
int _1st_ShadeMapArr_ID = 0;
Expand Down Expand Up @@ -303,8 +300,6 @@ struct InputData
half3x3 tangentToWorld;
};
bool anyPos(vec3 _v)
{
return length(_v) > 0.0;
Expand Down Expand Up @@ -341,7 +336,6 @@ void clip(float _clip)
discard;
}
// When AlphaToMask is available: Returns a modified alpha value that should be exported from the shader so it can be combined with the sample mask
// When AlphaToMask is not available: Terminates the current invocation if the alpha value is below the cutoff and returns the input alpha value otherwise
Expand Down Expand Up @@ -369,10 +363,6 @@ half AlphaClip(half alpha, half cutoff)
return alpha;
}
bool IsAlphaDiscardEnabled()
{
//#if defined(DEBUG_DISPLAY)
Expand Down Expand Up @@ -405,8 +395,6 @@ half Alpha(half albedoAlpha, half4 color, half cutoff)
return alpha;
}
half4 SampleMetallicSpecGloss(float2 uv, half albedoAlpha)
{
half4 specGloss;
Expand Down Expand Up @@ -461,8 +449,6 @@ half3 SampleEmission(float2 uv, half3 emissionColor)
#endif
}
void InitializeStandardLitSurfaceDataUTS(float2 uv, out SurfaceData outSurfaceData)
{
//outSurfaceData = (SurfaceData)0;
Expand All @@ -488,8 +474,6 @@ void InitializeStandardLitSurfaceDataUTS(float2 uv, out SurfaceData outSurfaceDa
outSurfaceData.emission = SampleEmission(uv, _EmissionColor.rgb);
}
float3 GetCameraPositionWS()
{
return vec3(worldView[3][0], worldView[3][1], worldView[3][2]);
Expand All @@ -502,8 +486,6 @@ half3 GetWorldSpaceNormalizeViewDir(float3 positionWS)
return half3(normalize(V));
}
// Normalize that account for vectors with zero length
real3 SafeNormalize(float3 inVec)
{
Expand Down Expand Up @@ -602,8 +584,6 @@ void InitializeInputData(Varyings varyings_input, half3 normalTS, out InputData
//inputData.shadowMask = SAMPLE_SHADOWMASK(varyings_input.staticLightmapUV);
}
real PerceptualSmoothnessToPerceptualRoughness(real perceptualSmoothness)
{
return (1.0 - perceptualSmoothness);
Expand Down Expand Up @@ -672,8 +652,6 @@ void InitializeBRDFData(half3 albedo, half metallic, half3 specular, half smooth
InitializeBRDFDataDirect(albedo, brdfDiffuse, brdfSpecular, reflectivity, oneMinusReflectivity, smoothness, alpha, outBRDFData);
}
real3 UnpackNormalAG(real4 packedNormal, real scale)
{
real3 normal;
Expand Down Expand Up @@ -748,8 +726,6 @@ float Pow4(float x)
// return (decodeInstructions.x * PositivePow(alpha, decodeInstructions.y)) * encodedIrradiance.rgb;
// }
half3 GlossyEnvironmentReflection(half3 reflectVector, half perceptualRoughness, half occlusion)
{
// #if !defined(_ENVIRONMENTREFLECTIONS_OFF)
Expand Down Expand Up @@ -796,8 +772,6 @@ half3 GlobalIlluminationUTS(BRDFData brdfData, half3 bakedGI, half occlusion, ha
//return half3(0.0);
}
half3 LinearToGammaSpace (half3 linRGB)
{
linRGB = max(linRGB, half3(0.0, 0.0, 0.0));
Expand Down Expand Up @@ -863,7 +837,6 @@ half3 GetLightColor(UtsLight light)
return light.color * light.distanceAttenuation;
}
float4 fragDoubleShadeFeather(VertexOutput i)
{
float2 Set_UV0 = i.uv0;
Expand Down Expand Up @@ -931,9 +904,9 @@ float4 fragDoubleShadeFeather(VertexOutput i)
envColor *= 1.8f;
UtsLight mainLight;// = GetMainUtsLightByID(i.mainLightID, i.posWorld.xyz, inputData.shadowCoord, i.positionCS);
mainLight.direction = float3(0.0, 0.0, 0.0);
mainLight.color = float3(0.0, 0.0, 0.0);
mainLight.distanceAttenuation = 1.0f;
mainLight.direction = _LightDirection.xyz;
mainLight.color = _LightColor.xyz;
mainLight.distanceAttenuation = _LightDirection.w;
mainLight.shadowAttenuation = 1.0f;
mainLight.type = int(0);
Expand Down Expand Up @@ -1145,7 +1118,6 @@ float4 fragDoubleShadeFeather(VertexOutput i)
return finalRGBA;
}
void main(void)
{
VertexOutput vertOutput;
Expand Down

0 comments on commit dc694ed

Please sign in to comment.