generated from raccoon/vrchat-project-template
Added textures and materials and scene from half-life 2
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
// Original code from https://gist.github.com/josephbk117/a43f5335cea9b3e12a44f196dc81f30f
|
||||
Shader "Custom/InteriorImposterShader"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
#include "Lighting.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float3 worldPos : TEXCOORD0;
|
||||
float3 worldNormal : TEXCOORD1;
|
||||
float4 pos : SV_POSITION;
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
|
||||
o.worldNormal = UnityObjectToWorldNormal(v.normal);
|
||||
return o;
|
||||
}
|
||||
|
||||
// Snippet from https://github.com/frostbone25/Unity-Improved-Box-Projected-Reflections/blob/main/ImprovedBoxProjectedReflections/Assets/Shaders/ImprovedBoxProjectedReflections.shader#L80
|
||||
float3 BoxProjectReflectionDir(float3 worldPos, float3 worldRefl, out float distanceToHitPoint)
|
||||
{
|
||||
float4 probePos = unity_SpecCube0_ProbePosition;
|
||||
float4 boxMin = unity_SpecCube0_BoxMin;
|
||||
float4 boxMax = unity_SpecCube0_BoxMax;
|
||||
|
||||
// Do we have a valid reflection probe?
|
||||
if (probePos.w > 0.0)
|
||||
{
|
||||
float3 nrdir = normalize(worldRefl);
|
||||
|
||||
float3 rbmax = (boxMax.xyz - worldPos) / nrdir;
|
||||
float3 rbmin = (boxMin.xyz - worldPos) / nrdir;
|
||||
|
||||
float3 rbminmax = (nrdir > 0.0f) ? rbmax : rbmin;
|
||||
|
||||
distanceToHitPoint = min(min(rbminmax.x, rbminmax.y), rbminmax.z);
|
||||
|
||||
worldPos -= probePos.xyz;
|
||||
worldRefl = worldPos + nrdir * distanceToHitPoint;
|
||||
}
|
||||
|
||||
return worldRefl;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float mipLevel = 0.0;
|
||||
|
||||
half3 worldViewDir = normalize(UnityWorldSpaceViewDir(i.worldPos)); // Direction of ray from the camera towards the object surface
|
||||
float3 boxProjection = BoxProjectReflectionDir(i.worldPos, -worldViewDir, mipLevel);
|
||||
|
||||
mipLevel = (mipLevel / UNITY_SPECCUBE_LOD_STEPS) * perceptualRoughnessToMipmapLevel(0.0); // Fixing incorrect mipmap level of cubemap texture
|
||||
|
||||
half4 skyData = UNITY_SAMPLE_TEXCUBE_LOD(unity_SpecCube0, boxProjection, mipLevel);
|
||||
half3 skyColor = DecodeHDR(skyData, unity_SpecCube0_HDR); // This is done becasue the cubemap is stored HDR
|
||||
|
||||
return half4(skyColor, 1.0);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac7ea5adade6d244bbd83b8d2a0a92d1
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user