diff options
| author | yum <yum.food.vr@gmail.com> | 2025-02-12 01:24:49 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2025-02-12 01:24:49 -0800 |
| commit | caf02458737f93b20978f41613ad5b56e074e154 (patch) | |
| tree | b7b3c0ab468d858d71f4fa96f2b420b7ad5ab98a /2ner.cginc | |
| parent | 498ffebe9524871e9442e58eb0c3760a5463ffbc (diff) | |
Add a bunch of features
* stereo instancing
* outlines
* shadows (casting & receiving)
* unity fog
* blend modes
* wrapped lighting (generalized half lambertian)
* diffuse & specular have independent knobs
Also:
* fix bug where shadow caster wouldn't clip in cutout mode.
* remove a bunch of unused params
* use ifex to minimize size of locked materials (more to be done
probably)
* improve formatting
Diffstat (limited to '2ner.cginc')
| -rw-r--r-- | 2ner.cginc | 39 |
1 files changed, 36 insertions, 3 deletions
@@ -4,6 +4,7 @@ #include "UnityCG.cginc"
#include "UnityLightingCommon.cginc"
+#include "features.cginc"
#include "globals.cginc"
#include "interpolators.cginc"
#include "poi.cginc"
@@ -14,31 +15,63 @@ v2f vert (appdata v) {
v2f o;
+ UNITY_SETUP_INSTANCE_ID(v);
+ UNITY_INITIALIZE_OUTPUT(v2f, o);
+ UNITY_TRANSFER_INSTANCE_ID(v, o);
+ UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+
+#if defined(OUTLINE_PASS)
+#if defined(_OUTLINE_MASK)
+ float thickness = _Outline_Mask.SampleLevel(linear_repeat_s, v.uv, 0);
+#else
+ float thickness = 1;
+#endif
+ v.vertex.xyz += _Outline_Width * v.normal * thickness;
+ v.normal *= -1;
+ v.tangent *= -1;
+#endif // OUTLINE_PASS
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
o.worldPos = mul(unity_ObjectToWorld, v.vertex);
+ o.eyeVec.xyz = normalize(o.worldPos - _WorldSpaceCameraPos);
// Calculate TBN matrix
o.normal = UnityObjectToWorldNormal(v.normal);
o.tangent = UnityObjectToWorldDir(v.tangent.xyz);
o.bitangent = cross(o.normal, o.tangent) * v.tangent.w;
+ UNITY_TRANSFER_LIGHTING(o, v.uv1);
+ UNITY_TRANSFER_FOG_COMBINED_WITH_EYE_VEC(o, o.pos);
+#if defined(SHADOW_CASTER_PASS)
+ TRANSFER_SHADOW_CASTER_NORMALOFFSET(o);
+#endif
return o;
}
float4 frag (v2f i) : SV_Target {
+ UNITY_APPLY_DITHER_CROSSFADE(i.pos.xy);
+ UNITY_SETUP_INSTANCE_ID(i);
+ UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
+
YumPbr pbr = GetYumPbr(i);
UNITY_BRANCH
- if (_Mode == 1) {
- clip(pbr.albedo.a - _Clip);
- }
+ if (_Mode == 1) {
+ clip(pbr.albedo.a - _Clip);
+ pbr.albedo.a = 1;
+ }
+#if defined(FORWARD_BASE_PASS) || defined(FORWARD_ADD_PASS) || defined(OUTLINE_PASS)
YumLighting l = GetYumLighting(i, pbr);
float4 lit = YumBRDF(i, l, pbr);
+ UNITY_EXTRACT_FOG_FROM_EYE_VEC(i);
+ UNITY_APPLY_FOG(_unity_fogCoord, lit.rgb);
return lit;
+#elif defined(SHADOW_CASTER_PASS)
+ return 0;
+#endif
}
#endif // __2NER_INC
|
