Premier commit du cinquième front. Trois parties : - `unity/MyInfoMateVR/` : le projet Unity (6000.0.83f1, URP, Meta XR SDK 205), un APK unique pour tous les clients. Menu flottant à sélection au regard, appairage, chargement de scène GLB, POI, cache de contenu, télémétrie. - `unity-overlay/` : les mêmes scripts à recopier sur un projet Unity neuf, avec les pièges rencontrés consignés dans son README. - `viewer/` : viewer et éditeur de scène web autonome (Vite, TypeScript, three.js), partagé avec les autres fronts. - `docs/` : état des lieux, setup Unity, décisions d'architecture et plan d'exécution en 9 étapes. La scène est décrite par un `scene.json` poussé par `adb push` : l'app le préfère à celui embarqué dans l'APK. Les binaires (GLB, textures de l'échantillon Sponza, DLL Meta XR) passent par Git LFS dès ce premier commit — les y faire entrer après coup demanderait de réécrire l'historique. Les artefacts régénérés par l'éditeur et par CMake (`Library/`, `.utmp/`, Burst debug) sont ignorés. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
85 lines
2.2 KiB
HLSL
85 lines
2.2 KiB
HLSL
float2 UnpackUV(float uv)
|
|
{
|
|
float2 output;
|
|
output.x = floor(uv / 4096);
|
|
output.y = uv - 4096 * output.x;
|
|
|
|
return output * 0.001953125;
|
|
}
|
|
|
|
fixed4 GetColor(half d, fixed4 faceColor, fixed4 outlineColor, half outline, half softness)
|
|
{
|
|
half faceAlpha = 1-saturate((d - outline * 0.5 + softness * 0.5) / (1.0 + softness));
|
|
half outlineAlpha = saturate((d + outline * 0.5)) * sqrt(min(1.0, outline));
|
|
|
|
faceColor.rgb *= faceColor.a;
|
|
outlineColor.rgb *= outlineColor.a;
|
|
|
|
faceColor = lerp(faceColor, outlineColor, outlineAlpha);
|
|
|
|
faceColor *= faceAlpha;
|
|
|
|
return faceColor;
|
|
}
|
|
|
|
float3 GetSurfaceNormal(float4 h, float bias)
|
|
{
|
|
bool raisedBevel = step(1, fmod(_ShaderFlags, 2));
|
|
|
|
h += bias+_BevelOffset;
|
|
|
|
float bevelWidth = max(.01, _OutlineWidth+_BevelWidth);
|
|
|
|
// Track outline
|
|
h -= .5;
|
|
h /= bevelWidth;
|
|
h = saturate(h+.5);
|
|
|
|
if(raisedBevel) h = 1 - abs(h*2.0 - 1.0);
|
|
h = lerp(h, sin(h*3.141592/2.0), _BevelRoundness);
|
|
h = min(h, 1.0-_BevelClamp);
|
|
h *= _Bevel * bevelWidth * _GradientScale * -2.0;
|
|
|
|
float3 va = normalize(float3(1.0, 0.0, h.y - h.x));
|
|
float3 vb = normalize(float3(0.0, -1.0, h.w - h.z));
|
|
|
|
return cross(va, vb);
|
|
}
|
|
|
|
float3 GetSurfaceNormal(float2 uv, float bias, float3 delta)
|
|
{
|
|
// Read "height field"
|
|
float4 h = {tex2D(_MainTex, uv - delta.xz).a,
|
|
tex2D(_MainTex, uv + delta.xz).a,
|
|
tex2D(_MainTex, uv - delta.zy).a,
|
|
tex2D(_MainTex, uv + delta.zy).a};
|
|
|
|
return GetSurfaceNormal(h, bias);
|
|
}
|
|
|
|
float3 GetSpecular(float3 n, float3 l)
|
|
{
|
|
float spec = pow(max(0.0, dot(n, l)), _Reflectivity);
|
|
return _SpecularColor.rgb * spec * _SpecularPower;
|
|
}
|
|
|
|
float4 GetGlowColor(float d, float scale)
|
|
{
|
|
float glow = d - (_GlowOffset*_ScaleRatioB) * 0.5 * scale;
|
|
float t = lerp(_GlowInner, (_GlowOuter * _ScaleRatioB), step(0.0, glow)) * 0.5 * scale;
|
|
glow = saturate(abs(glow/(1.0 + t)));
|
|
glow = 1.0-pow(glow, _GlowPower);
|
|
glow *= sqrt(min(1.0, t)); // Fade off glow thinner than 1 screen pixel
|
|
return float4(_GlowColor.rgb, saturate(_GlowColor.a * glow * 2));
|
|
}
|
|
|
|
float4 BlendARGB(float4 overlying, float4 underlying)
|
|
{
|
|
overlying.rgb *= overlying.a;
|
|
underlying.rgb *= underlying.a;
|
|
float3 blended = overlying.rgb + ((1-overlying.a)*underlying.rgb);
|
|
float alpha = underlying.a + (1-underlying.a)*overlying.a;
|
|
return float4(blended, alpha);
|
|
}
|
|
|