// AUTOMATICALLY CONVERTED FROM SHADER FIXES 
//
// Generated by Microsoft (R) HLSL Shader Compiler 10.1
//
//   using 3Dmigoto v0.6.164 on Wed Oct 28 14:29:02 2026
//
//
// Buffer Definitions:
//
// cbuffer FogParams
// {
//
//   float3 g_xFogColour;               // Offset:    0 Size:    12
//   float g_fFogNearPlane;             // Offset:   12 Size:     4
//   float g_fRcpFogVolumeDepth;        // Offset:   16 Size:     4
//   float g_fFarClipPlane;             // Offset:   20 Size:     4 [unused]
//   bool g_bFogEnabled;                // Offset:   24 Size:     4
//
// }
//
// cbuffer Material1
// {
//
//   struct
//   {
//
//       float m_fMaterialIndex;        // Offset:    0
//       float m_fReflectivity;         // Offset:    4
//       float m_fRefractivity;         // Offset:    8
//       float m_fParallaxScale;        // Offset:   12
//       float m_fParallaxBias;         // Offset:   16
//       float m_fAlbedoDetailUVScale;  // Offset:   20
//       float m_fAlbedoDetailValueScale;// Offset:   24
//       float m_fNormalDetailUVScale;  // Offset:   28
//       float m_fNormalDetailValueScale;// Offset:   32
//       bool m_bRefractionBlendBackground;// Offset:   36
//       bool m_bIsDecal;               // Offset:   40
//
//   } g_xMaterial1;                    // Offset:    0 Size:    44
//
// }
//
// cbuffer PrimitiveConstants
// {
//
//   float4 g_xRedSH;                   // Offset:    0 Size:    16
//   float4 g_xGreenSH;                 // Offset:   16 Size:    16
//   float4 g_xBlueSH;                  // Offset:   32 Size:    16
//   float3 g_xSHLightDirection;        // Offset:   48 Size:    12
//   float g_fFogColourMult;            // Offset:   60 Size:     4
//   float4 g_xSHLightColour;           // Offset:   64 Size:    16
//   float4 g_xSelfIlluminationParameters;// Offset:   80 Size:    16
//   float3 g_xAlbedoModifier;          // Offset:   96 Size:    12 [unused]
//   float4 g_xUV_Offsets;              // Offset:  112 Size:    16 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// g_xTrilinearClamp_s               sampler      NA          NA    3        1
// g_xFilteredWrap_s                 sampler      NA          NA    4        1
// g_xMaterialsTexture               texture  float4          2d    0        1
// g_xAlbedoMap                      texture  float4          2d    4        1
// g_xTransparencyMap                texture  float4          2d    7        1
// g_xFogTexture                     texture  float4          1d  104        1
// Material1                         cbuffer      NA          NA    1        1
// PrimitiveConstants                cbuffer      NA          NA    3        1
// FogParams                         cbuffer      NA          NA   12        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float
// TANGENT                  0   xyz         1     NONE   float
// BINORMAL                 0   xyz         2     NONE   float
// NORMAL                   0   xyz         3     NONE   float   xyz
// TEXCOORD                 0   xyzw        4     NONE   float   xy
// TEXCOORD                 1   xyzw        5     NONE   float   xyzw
// TEXCOORD                 2   xyzw        6     NONE   float
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_4_0
dcl_constantbuffer CB12[2], immediateIndexed
dcl_constantbuffer CB1[1], immediateIndexed
dcl_constantbuffer CB3[6], immediateIndexed
dcl_sampler s3, mode_default
dcl_sampler s4, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t4
dcl_resource_texture2d (float,float,float,float) t7
dcl_resource_texture1d (float,float,float,float) t104
dcl_input_ps linear v3.xyz
dcl_input_ps linear v4.xy
dcl_input_ps linear v5.xyzw
dcl_output o0.xyzw
dcl_temps 7
dp3 r0.x, v3.xyzx, v3.xyzx
rsq r0.x, r0.x
mul r0.xyz, r0.xxxx, v3.xyzx
dp3 r1.x, v5.xyzx, v5.xyzx
rsq r1.x, r1.x
mul r1.xyz, r1.xxxx, v5.xyzx
mov r0.w, l(1.000000)
dp4 r2.x, r0.xyzw, cb3[0].xyzw
dp4 r2.y, r0.xyzw, cb3[1].xyzw
dp4 r2.z, r0.xyzw, cb3[2].xyzw
max r2.xyz, r2.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
sample r3.xyzw, v4.xyxx, t4.xyzw, s4
sample r4.xyzw, v4.xyxx, t7.xyzw, s4
dp3 r0.w, r0.xyzx, cb3[3].xyzx
min r0.w, r0.w, l(1.000000)
mul r4.xyz, r0.xyzx, r0.wwww
mad r4.xyz, r4.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), -cb3[3].xyzx
dp3 r1.w, r4.xyzx, r1.xyzx
min r1.w, r1.w, l(1.000000)
mad r5.x, r0.w, l(0.490234375), l(0.492187500)
mov r5.yw, cb1[0].xxxx
sample r6.xyzw, r5.xyxx, t0.xyzw, s3
mul r2.xyz, r2.xyzx, r6.xxxx
mad r5.z, r1.w, l(0.490234375), l(0.492187500)
sample r5.xyzw, r5.zwzz, t0.xyzw, s3
mul r4.xyz, r5.yyyy, cb3[4].xyzx
mad r2.xyz, r2.xyzx, r3.xyzx, r4.xyzx
dp3 r0.x, r0.xyzx, r1.xyzx
min r0.x, r0.x, l(1.000000)
mad r0.x, r0.x, l(0.490234375), l(0.492187500)
mov r0.y, cb1[0].x
sample r0.xyzw, r0.xyxx, t0.xyzw, s3
mad r0.xyw, r3.xyxz, cb3[5].wwww, cb3[5].xyxz
add r0.xyw, r0.xyxw, r2.xyxz
mul o0.w, r0.z, r4.w
movc r0.z, cb12[1].z, l(1), l(0)
if_nz r0.z
  add r0.z, v5.w, -cb12[0].w
  mul r0.z, r0.z, cb12[1].x
  sample r1.xyzw, r0.zzzz, t104.xyzw, s3
  mad r1.xyz, cb12[0].xyzx, cb3[3].wwww, -r0.xywx
  mad r0.xyw, r1.wwww, r1.xyxz, r0.xyxw
endif
min o0.xyz, r0.xywx, l(31.875000, 31.875000, 31.875000, 0.000000)
ret
// Approximately 45 instruction slots used

///////////////////////////////// HLSL Code /////////////////////////////////
// // ---- Created with 3Dmigoto v0.6.164 on Wed Oct 28 14:29:02 2026
//
// cbuffer FogParams : register(b12)
// {
//   float3 g_xFogColour : packoffset(c0);
//   float g_fFogNearPlane : packoffset(c0.w);
//   float g_fRcpFogVolumeDepth : packoffset(c1);
//   float g_fFarClipPlane : packoffset(c1.y);
//   bool g_bFogEnabled : packoffset(c1.z);
// }
//
// cbuffer Material1 : register(b1)
// {
//
//   struct
//   {
//     float m_fMaterialIndex;
//     float m_fReflectivity;
//     float m_fRefractivity;
//     float m_fParallaxScale;
//     float m_fParallaxBias;
//     float m_fAlbedoDetailUVScale;
//     float m_fAlbedoDetailValueScale;
//     float m_fNormalDetailUVScale;
//     float m_fNormalDetailValueScale;
//     bool m_bRefractionBlendBackground;
//     bool m_bIsDecal;
//   } g_xMaterial1 : packoffset(c0);
//
// }
//
// cbuffer PrimitiveConstants : register(b3)
// {
//   float4 g_xRedSH : packoffset(c0);
//   float4 g_xGreenSH : packoffset(c1);
//   float4 g_xBlueSH : packoffset(c2);
//   float3 g_xSHLightDirection : packoffset(c3);
//   float g_fFogColourMult : packoffset(c3.w);
//   float4 g_xSHLightColour : packoffset(c4);
//   float4 g_xSelfIlluminationParameters : packoffset(c5);
//   float3 g_xAlbedoModifier : packoffset(c6);
//   float4 g_xUV_Offsets : packoffset(c7);
// }
//
// SamplerState g_xTrilinearClamp_s_s : register(s3);
// SamplerState g_xFilteredWrap_s_s : register(s4);
// Texture2D<float4> g_xMaterialsTexture : register(t0);
// Texture2D<float4> g_xAlbedoMap : register(t4);
// Texture2D<float4> g_xTransparencyMap : register(t7);
// Texture1D<float4> g_xFogTexture : register(t104);
//
//
// // 3Dmigoto declarations
// #define cmp -
// Texture1D<float4> IniParams : register(t120);
// Buffer<float4> StereoParams : register(t125);
//
//
// void main(
//   float4 v0 : SV_Position0,
//   float3 v1 : TANGENT0,
//   float3 v2 : BINORMAL0,
//   float3 v3 : NORMAL0,
//   float4 v4 : TEXCOORD0,
//   float4 v5 : TEXCOORD1,
//   float4 v6 : TEXCOORD2,
//   out float4 o0 : SV_Target0)
// {
// // Needs manual fix for instruction:
// // unknown dcl_: dcl_resource_texture1d (float,float,float,float) t104
//   float4 r0,r1,r2,r3,r4,r5,r6;
//   uint4 bitmask, uiDest;
//   float4 fDest;
//
//   r0.x = dot(v3.xyz, v3.xyz);
//   r0.x = rsqrt(r0.x);
//   r0.xyz = v3.xyz * r0.xxx;
//   r1.x = dot(v5.xyz, v5.xyz);
//   r1.x = rsqrt(r1.x);
//   r1.xyz = v5.xyz * r1.xxx;
//   r0.w = 1;
//   r2.x = dot(r0.xyzw, g_xRedSH.xyzw);
//   r2.y = dot(r0.xyzw, g_xGreenSH.xyzw);
//   r2.z = dot(r0.xyzw, g_xBlueSH.xyzw);
//   r2.xyz = max(float3(0,0,0), r2.xyz);
//   r3.xyzw = g_xAlbedoMap.Sample(g_xFilteredWrap_s_s, v4.xy).xyzw;
//   r4.xyzw = g_xTransparencyMap.Sample(g_xFilteredWrap_s_s, v4.xy).xyzw;
//   r0.w = dot(r0.xyz, g_xSHLightDirection.xyz);
//   r0.w = min(1, r0.w);
//   r4.xyz = r0.www * r0.xyz;
//   r4.xyz = r4.xyz * float3(2,2,2) + -g_xSHLightDirection.xyz;
//   r1.w = dot(r4.xyz, r1.xyz);
//   r1.w = min(1, r1.w);
//   r5.x = r0.w * 0.490234375 + 0.4921875;
//   r5.yw = g_xMaterial1.m_fMaterialIndex;
//   r6.xyzw = g_xMaterialsTexture.Sample(g_xTrilinearClamp_s_s, r5.xy).xyzw;
//   r2.xyz = r6.xxx * r2.xyz;
//   r5.z = r1.w * 0.490234375 + 0.4921875;
//   r5.xyzw = g_xMaterialsTexture.Sample(g_xTrilinearClamp_s_s, r5.zw).xyzw;
//   r4.xyz = g_xSHLightColour.xyz * r5.yyy;
//   r2.xyz = r2.xyz * r3.xyz + r4.xyz;
//   r0.x = dot(r0.xyz, r1.xyz);
//   r0.x = min(1, r0.x);
//   r0.x = r0.x * 0.490234375 + 0.4921875;
//   r0.y = g_xMaterial1.m_fMaterialIndex;
//   r0.xyzw = g_xMaterialsTexture.Sample(g_xTrilinearClamp_s_s, r0.xy).xyzw;
//   r0.xyw = r3.xyz * g_xSelfIlluminationParameters.www + g_xSelfIlluminationParameters.xyz;
//   r0.xyw = r2.xyz + r0.xyw;
//   o0.w = r4.w * r0.z;
//   r0.z = g_bFogEnabled ? 1 : 0;
//   if (r0.z != 0) {
//     r0.z = -g_fFogNearPlane + v5.w;
//     r0.z = g_fRcpFogVolumeDepth * r0.z;
//     r1.xyzw = g_xFogTexture.Sample(g_xTrilinearClamp_s_s, r0.z).xyzw;
//     r1.xyz = g_xFogColour.xyz * g_fFogColourMult + -r0.xyw;
//     r0.xyw = r1.www * r1.xyz + r0.xyw;
//   }
//   o0.xyz = min(float3(31.875,31.875,31.875), r0.xyw);
//   return;
// }
/////////////////////////////////////////////////////////////////////////////
