//
// Generated by Microsoft (R) D3DX9 Shader Compiler 9.08.299.0000
//
//   vsa shaderdump19/PAR2022.pso /Fcshaderdump19/PAR2022.pso.dis
//
//
// Parameters:
//
sampler2D TESR_samplerBaseMap : register(s0) = sampler_state { MINFILTER = LINEAR; };
float4 Toggles : register(c7);
//
//
// Registers:
//
//   Name         Reg   Size
//   ------------ ----- ----
//   Toggles      const_7        1
//   TESR_samplerBaseMap      texture_0       1
//

// Structures:

struct VS_OUTPUT {
    // PAR2028.vso

    float2 BaseUV : TEXCOORD0;
    float3 CameraDir : TEXCOORD6_centroid;
    float3 Color : COLOR0;
};

struct PS_OUTPUT {
    float4 Color : COLOR0;
};

// Code:

#define	  nolight
#include "includes/PAR.hlsl"

PS_OUTPUT main(VS_OUTPUT IN) {
    PS_OUTPUT OUT;

#define	uvtile(w)		(((w) * 0.04) - 0.02)

    float4 r0;
    float2 uv;
    float  ao;
    float  hg;
    float3 cm = normalize(IN.CameraDir);

    /* calculate parallaxed position */
    hg = tex2D(TESR_samplerBaseMap, IN.BaseUV.xy).a;
    uv.xy = (uvtile(hg) * (cm.xy / length(cm.xyz))) + IN.BaseUV.xy;
    ao = 1.0;

    /* modifying shader --------------------------------------- */

    psParallax(IN.BaseUV, IN.CameraDir, uv, ao);

    /* fetch Base from parallaxed position */
    r0.rgb = tex2D(TESR_samplerBaseMap, uv.xy).rgb;

    OUT.Color.a = 1;
    OUT.Color.rgb = (Toggles.x <= 0.0 ? r0.xyz : (r0.xyz * IN.Color.rgb)) * ao;

    return OUT;
};

// approximately 11 instruction slots used (2 texture, 9 arithmetic)
