#define t2D texture2D
#define vry varying
#define ufm uniform
#define nmlz normalize
#define smp2D sampler2D
#if defined(NNGLD_OPT_NUM_PARALLEL_LIGHT)&&(NNGLD_OPT_NUM_PARALLEL_LIGHT>=2)
#undef NNGLD_OPT_NUM_PARALLEL_LIGHT
#define NNGLD_OPT_NUM_PARALLEL_LIGHT 1
#endif
#ifndef NNGLD_PROF_NORMALIZE_VTX_NORMAL
#define NNGLD_PROF_NORMALIZE_VTX_NORMAL (1)
#endif
#ifndef NNGLD_PROF_LIGHT_AMBIENT
#define NNGLD_PROF_LIGHT_AMBIENT (0)
#endif
#ifndef NNGLD_PROF_POINTLIGHT_DISTATTEN
#define NNGLD_PROF_POINTLIGHT_DISTATTEN (0)
#endif
#ifndef NNGLD_PROF_CALC_VTX_BINORMAL
#define NNGLD_PROF_CALC_VTX_BINORMAL (1)
#endif
#ifndef NNGLD_PROF_MAX_USER_UNIFORM
#define NNGLD_PROF_MAX_USER_UNIFORM (4)
#endif
#ifndef NNGLD_PROF_DEFAULT_FLOAT_MEDIUMP
#define NNGLD_PROF_DEFAULT_FLOAT_MEDIUMP (1)
#endif
#ifndef NNGLD_PROF_COLOR_LOWP
#define NNGLD_PROF_COLOR_LOWP (1)
#endif
#ifndef NNGLD_PROF_DIRECTION_LOWP
#define NNGLD_PROF_DIRECTION_LOWP (0)
#endif
#ifndef NNGLD_PROF_VTX_SPECULAR
#define NNGLD_PROF_VTX_SPECULAR (0)
#endif
#ifndef NNGLD_OPT_VTX_NORMAL
#define NNGLD_OPT_VTX_NORMAL (1)
#endif
#ifndef NNGLD_OPT_VTX_TANGENT
#define NNGLD_OPT_VTX_TANGENT (0)
#endif
#ifndef NNGLD_OPT_VTX_BINORMAL
#define NNGLD_OPT_VTX_BINORMAL (0)
#endif
#ifndef NNGLD_OPT_VTX_COLOR0
#define NNGLD_OPT_VTX_COLOR0 (0)
#endif
#ifndef NNGLD_OPT_VTX_COLOR1
#define NNGLD_OPT_VTX_COLOR1 (0)
#endif
#ifndef NNGLD_OPT_VTX_TEXCOORD0
#define NNGLD_OPT_VTX_TEXCOORD0 (1)
#endif
#ifndef NNGLD_OPT_VTX_TEXCOORD1
#define NNGLD_OPT_VTX_TEXCOORD1 (0)
#endif
#ifndef NNGLD_OPT_VTX_TEXCOORD2
#define NNGLD_OPT_VTX_TEXCOORD2 (0)
#endif
#ifndef NNGLD_OPT_VTX_TEXCOORD3
#define NNGLD_OPT_VTX_TEXCOORD3 (0)
#endif
#ifndef NNGLD_OPT_LIGHTING
#define NNGLD_OPT_LIGHTING (1)
#endif
#ifndef NNGLD_OPT_FRAG_LIGHTING
#define NNGLD_OPT_FRAG_LIGHTING (1)
#endif
#ifndef NNGLD_OPT_NUM_PARALLEL_LIGHT
#define NNGLD_OPT_NUM_PARALLEL_LIGHT (1)
#endif
#ifndef NNGLD_OPT_SPECULAR
#define NNGLD_OPT_SPECULAR (0)
#endif
#ifndef NNGLD_OPT_TWOSIDED_LIGHTING
#define NNGLD_OPT_TWOSIDED_LIGHTING (0)
#endif
#ifndef NNGLD_OPT_TANGENT_SPACE
#define NNGLD_OPT_TANGENT_SPACE (0)
#endif
#ifndef NNGLD_OPT_NORMALMAP_AXLY
#define NNGLD_OPT_NORMALMAP_AXLY (0)
#endif
#ifndef NNGLD_OPT_TEX_NORMAL
#define NNGLD_OPT_TEX_NORMAL (-1)
#endif
#ifndef NNGLD_OPT_TEXCOORD_NORMAL
#define NNGLD_OPT_TEXCOORD_NORMAL (-1)
#endif
#ifndef NNGLD_OPT_TEX_BASE
#define NNGLD_OPT_TEX_BASE (-1)
#endif
#ifndef NNGLD_OPT_TEXCOORD_BASE
#define NNGLD_OPT_TEXCOORD_BASE (-1)
#endif
#ifndef NNGLD_OPT_TEX_DECAL
#define NNGLD_OPT_TEX_DECAL (-1)
#endif
#ifndef NNGLD_OPT_TEXCOORD_DECAL
#define NNGLD_OPT_TEXCOORD_DECAL (-1)
#endif
#ifndef NNGLD_OPT_TEX_DECAL2
#define NNGLD_OPT_TEX_DECAL2 (-1)
#endif
#ifndef NNGLD_OPT_TEXCOORD_DECAL2
#define NNGLD_OPT_TEXCOORD_DECAL2 (-1)
#endif
#ifndef NNGLD_OPT_TEX_DECAL3
#define NNGLD_OPT_TEX_DECAL3 (-1)
#endif
#ifndef NNGLD_OPT_TEXCOORD_DECAL3
#define NNGLD_OPT_TEXCOORD_DECAL3 (-1)
#endif
#ifndef NNGLD_OPT_TEX_SPECULAR
#define NNGLD_OPT_TEX_SPECULAR (-1)
#endif
#ifndef NNGLD_OPT_TEXCOORD_SPECULAR
#define NNGLD_OPT_TEXCOORD_SPECULAR (-1)
#endif
#ifndef NNGLD_OPT_TEX_SHININESS
#define NNGLD_OPT_TEX_SHININESS (-1)
#endif
#ifndef NNGLD_OPT_TEXCOORD_SHININESS
#define NNGLD_OPT_TEXCOORD_SHININESS (-1)
#endif
#ifndef NNGLD_OPT_TEX_DUALPARABOLOID
#define NNGLD_OPT_TEX_DUALPARABOLOID (-1)
#endif
#ifndef NNGLD_OPT_TEX_ENVMASK
#define NNGLD_OPT_TEX_ENVMASK (-1)
#endif
#ifndef NNGLD_OPT_TEXCOORD_ENVMASK
#define NNGLD_OPT_TEXCOORD_ENVMASK (-1)
#endif
#ifndef NNGLD_OPT_TEX_MODULATE
#define NNGLD_OPT_TEX_MODULATE (-1)
#endif
#ifndef NNGLD_OPT_TEXCOORD_MODULATE
#define NNGLD_OPT_TEXCOORD_MODULATE (-1)
#endif
#ifndef NNGLD_OPT_TEX_ADD
#define NNGLD_OPT_TEX_ADD (-1)
#endif
#ifndef NNGLD_OPT_TEXCOORD_ADD
#define NNGLD_OPT_TEXCOORD_ADD (-1)
#endif
#ifndef NNGLD_OPT_TEX_OPACITY
#define NNGLD_OPT_TEX_OPACITY (-1)
#endif
#ifndef NNGLD_OPT_TEXCOORD_OPACITY
#define NNGLD_OPT_TEXCOORD_OPACITY (-1)
#endif
#ifndef NNGLD_OPT_TEX_USER1
#define NNGLD_OPT_TEX_USER1 (-1)
#endif
#ifndef NNGLD_OPT_TEXCOORD_USER1
#define NNGLD_OPT_TEXCOORD_USER1 (-1)
#endif
#ifndef NNGLD_OPT_TEX_USER2
#define NNGLD_OPT_TEX_USER2 (-1)
#endif
#ifndef NNGLD_OPT_TEXCOORD_USER2
#define NNGLD_OPT_TEXCOORD_USER2 (-1)
#endif
#ifndef NNGLD_OPT_TEX_USER3
#define NNGLD_OPT_TEX_USER3  (-1)
#endif
#ifndef NNGLD_OPT_TEXCOORD_USER3
#define NNGLD_OPT_TEXCOORD_USER3 (-1)
#endif
#ifndef NNGLD_OPT_TEX_USER4
#define NNGLD_OPT_TEX_USER4 (-1)
#endif
#ifndef NNGLD_OPT_TEXCOORD_USER4
#define NNGLD_OPT_TEXCOORD_USER4 (-1)
#endif
#ifndef NNGLD_OPT_TEX_USER5
#define NNGLD_OPT_TEX_USER5 (-1)
#endif
#ifndef NNGLD_OPT_TEXCOORD_USER5
#define NNGLD_OPT_TEXCOORD_USER5 (-1)
#endif
#ifndef NNGLD_OPT_TEX_USER6
#define NNGLD_OPT_TEX_USER6 (-1)
#endif
#ifndef NNGLD_OPT_TEXCOORD_USER6
#define NNGLD_OPT_TEXCOORD_USER6 (-1)
#endif
#ifndef NNGLD_OPT_TEX_USER7
#define NNGLD_OPT_TEX_USER7 (-1)
#endif
#ifndef NNGLD_OPT_TEXCOORD_USER7
#define NNGLD_OPT_TEXCOORD_USER7 (-1)
#endif
#ifndef NNGLD_OPT_TEX_USER8
#define NNGLD_OPT_TEX_USER8 (-1)
#endif
#ifndef NNGLD_OPT_TEXCOORD_USER8
#define NNGLD_OPT_TEXCOORD_USER8 (-1)
#endif
#ifndef NNGLD_OPT_TEX_SAMPLER2D1
#define NNGLD_OPT_TEX_SAMPLER2D1 (-1)
#endif
#ifndef NNGLD_OPT_TEX_SAMPLER2D2
#define NNGLD_OPT_TEX_SAMPLER2D2 (-1)
#endif
#ifndef NNGLD_OPT_TEX_SAMPLER3D1
#define NNGLD_OPT_TEX_SAMPLER3D1 (-1)
#endif
#ifndef NNGLD_OPT_TEX_SAMPLER3D2
#define NNGLD_OPT_TEX_SAMPLER3D2 (-1)
#endif
#ifndef NNGLD_OPT_VERTEX_BLEND
#define NNGLD_OPT_VERTEX_BLEND (0)
#endif
#ifndef NNGLD_OPT_ALPHA_TEST
#define NNGLD_OPT_ALPHA_TEST (0)
#endif
#ifndef NNGLD_USER_PROFILE
#define NNGLD_USER_PROFILE (0)
#endif
#define DFL NNGLD_OPT_FRAG_LIGHTING
#define DT_NR NNGLD_OPT_TEX_NORMAL
#define DT_B NNGLD_OPT_TEX_BASE
#define DT_D1 NNGLD_OPT_TEX_DECAL
#define DT_D2 NNGLD_OPT_TEX_DECAL2
#define DT_D3 NNGLD_OPT_TEX_DECAL3
#define DT_SP NNGLD_OPT_TEX_SPECULAR
#define DT_SN NNGLD_OPT_TEX_SHININESS
#define DT_EM NNGLD_OPT_TEX_ENVMASK
#define DT_MD NNGLD_OPT_TEX_MODULATE
#define DT_AD NNGLD_OPT_TEX_ADD
#define DT_OP NNGLD_OPT_TEX_OPACITY
#define DT_U1 NNGLD_OPT_TEX_USER1
#define DT_U2 NNGLD_OPT_TEX_USER2
#define DT_U3 NNGLD_OPT_TEX_USER3
#define DT_U4 NNGLD_OPT_TEX_USER4
#define DT_U5 NNGLD_OPT_TEX_USER5
#define DT_U6 NNGLD_OPT_TEX_USER6
#define DT_U7 NNGLD_OPT_TEX_USER7
#define DT_U8 NNGLD_OPT_TEX_USER8
#define DT_S22 NNGLD_OPT_TEX_SAMPLER2D2
#define DN_PL NNGLD_OPT_NUM_PARALLEL_LIGHT
#define DP1 (1)
#define DP3 (3)
#define DP31 (1)
#define DP6 (6)
#define DP61 (1)
#define DP7 (7)
#define DP71 (1)
#define DP72 (2)
#define DP8 (8)
#define DP81 (1)
#define DP9 (9)
#define DP91 (1)
#define DP92 (2)
#define DP93 (3)
#define DP94 (4)
#define DP95 (5)
#define DP96 (6)
#define DPC (12)
#define DPD (13)
#define DP_A (10)
#define DP_DN(x) (NNGLD_USER_PROFILE_DRAWOBJ==x)
#define DP_MN(x) (NNGLD_USER_PROFILE==x)
#define DP_DI(id) DP_DN(id)
#define DP_MI(dobjid,matid) (DP_DN(dobjid)&&DP_MN(matid))
#define DP_OMI(matid) (DP_MN(matid))
#define DPU_T (DP_DI(DP1))
#define DPU_FR (DP_MI(DP3,DP31)||DP_MI(DP6,DP61)||DP_MI(DP7,DP71))
#define DPU_HA (DP_DI(DP3)||DP_DI(DP6))
#define DPU_HB (DP_DI(DP3)||DP_DI(DP6))
#define DPU_HE (DPU_HA||DPU_HB)
#define DPU_RT (DP_MI(DP9,DP91))
#define DPU_RB (DP_MI(DP9,DP92))
#define DPU_WR (DP_MI(DP9,DP94))
#define DPU_WS (DP_MI(DP9,DP93)||DP_MI(DP9,DP96))
#define DPU_WF (DP_MI(DP9,DP93)||DP_MI(DP9,DP96))
#define DPU_NR (DP_MI(DP9,DP95))
#define DPU_IC (DP_MI(DP7,DP72))
#if DP_DI(DP1)
#define DUI_T (0)
#endif
#if DP_DI(DP3)
#define DUI_FR  (0)
#define DUI_HA0 (1)
#define DUI_HA1 (2)
#define DUI_HA2 (3)
#define DUI_HB0 (4)
#define DUI_HB1 (5)
#define DUI_HB2 (6)
#endif
#if DP_DI(DP6)
#define DUI_FR  (0)
#define DUI_HA0 (1)
#define DUI_HA1 (2)
#define DUI_HA2 (3)
#define DUI_HB0 (4)
#define DUI_HB1 (5)
#define DUI_HB2 (6)
#endif
#if DP_DI(DP7)
#define DUI_FR  (0)
#endif
#if DP_DI(DP9)
#define DUI_WRS (0)
#define DUI_WF0 (1)
#define DUI_WF1 (2)
#define DUI_WF2 (3)
#define DUI_UVS (4)
#endif
#define DPU_GR DP_DI(DPC)
#define DPU_OC (DP_DI(DP6)||DP_DI(DPD)||DP_DI(DP3))
#if DP_OMI(DP_A)
#undef DFL
#define DFL 0
#endif
#if (DT_D1!=-1)&&!DP_DI(DPD)
#undef DT_D1
#define DT_D1 -1
#endif
#if DPU_WR
#undef DFL
#define DFL 0
#undef NNGLD_OPT_LIGHTING
#define NNGLD_OPT_LIGHTING 0
#undef NNGLD_OPT_ALPHA_TEST
#define NNGLD_OPT_ALPHA_TEST 0
#undef NNGLD_PROF_VTX_SPECULAR
#define NNGLD_PROF_VTX_SPECULAR 0
#undef NNGLD_OPT_SPECULAR
#define NNGLD_OPT_SPECULAR 0
#undef NNGLD_OPT_TANGENT_SPACE
#define NNGLD_OPT_TANGENT_SPACE 0
#undef NNGLD_OPT_VTX_COLOR0
#define NNGLD_OPT_VTX_COLOR0 0
#endif
#if DPU_WS
#undef DFL
#define DFL 0
#undef NNGLD_OPT_LIGHTING
#define NNGLD_OPT_LIGHTING 0
#undef DPU_WF
#define DPU_WF 0
#undef NNGLD_PROF_VTX_SPECULAR
#define NNGLD_PROF_VTX_SPECULAR 0
#undef NNGLD_OPT_SPECULAR
#define NNGLD_OPT_SPECULAR 0
#undef NNGLD_OPT_ALPHA_TEST
#define NNGLD_OPT_ALPHA_TEST 0
#undef NNGLD_OPT_TANGENT_SPACE
#define NNGLD_OPT_TANGENT_SPACE 0
#endif
#if DP_MI(DP9,DP96)
#undef DT_S22
#define DT_S22 -1
#endif
#if DPU_WR||DPU_WS
#if DT_NR!=-1
#if DT_NR==0
#define tc_wn nnglvTexCoord0
#define DT_WN 0
#elif DT_NR==1
#define tc_wn vtc1
#define DT_WN 1
#elif DT_NR==2
#define tc_wn vtc2
#define DT_WN 2
#elif DT_NR==3
#define tc_wn vtc3
#define DT_WN 3
#elif DT_NR==4
#define tc_wn vtc4
#define DT_WN 4
#elif DT_NR==5
#define tc_wn vtc5
#define DT_WN 5
#elif DT_NR==6
#define tc_wn vtc6
#define DT_WN 6
#elif DT_NR==7
#define tc_wn vtc7
#define DT_WN 7
#endif
#undef DT_NR
#define DT_NR -1
ufm mediump smp2D nngltexNormal;
#endif
#endif
#if DPU_GR
#if DT_S22!=-1
#if DT_S22==0
#define DT_GRD 0
#elif DT_S22==1
#define DT_GRD 1
#elif DT_S22==2
#define DT_GRD 2
#elif DT_S22==3
#define DT_GRD 3
#elif DT_S22==4
#define DT_GRD 4
#elif DT_S22==5
#define DT_GRD 5
#elif DT_S22==6
#define DT_GRD 6
#elif DT_S22==7
#define DT_GRD 7
#endif
#undef DT_S22
#define DT_S22 -1
#undef NNGLD_OPT_TEXCOORD_USER2
#define NNGLD_OPT_TEXCOORD_USER2 -1
ufm mediump smp2D nngltexUserSampler2D2;
#endif
#endif
#if !defined(DT_WN)
#define DT_WN -1
#endif
#if !defined(DT_GRD)
#define DT_GRD -1
#endif
#define DV_LT (!DFL&&NNGLD_OPT_LIGHTING)
#if DPU_NR
#extension GL_OES_standard_derivatives : enable
#endif
#if !defined(GL_FRAGMENT_PRECISION_HIGH)||NNGLD_PROF_DEFAULT_FLOAT_MEDIUMP
precision mediump float;
precision mediump int;
#define pvh highp
#define pv mediump
#define pvf mediump
#else
precision highp float;
precision highp int;
#define pvh highp
#define pv highp
#define pvf highp
#endif
#define puv mediump
#if NNGLD_PROF_COLOR_LOWP
#define pcol lowp
#else
#define pcol mediump
#endif
#if NNGLD_PROF_DIRECTION_LOWP
#define pdir lowp
#else
#define pdir mediump
#endif
#if (NNGLD_OPT_TEX_DUALPARABOLOID!=-1||((NNGLD_OPT_TEXCOORD_ADD==-3)||(NNGLD_OPT_TEXCOORD_BASE==-3)||(NNGLD_OPT_TEXCOORD_DECAL==-3)||(NNGLD_OPT_TEXCOORD_DECAL2==-3)||(NNGLD_OPT_TEXCOORD_DECAL3==-3)||(NNGLD_OPT_TEXCOORD_SPECULAR==-3)||(NNGLD_OPT_TEXCOORD_SHININESS==-3)||(NNGLD_OPT_TEXCOORD_MODULATE==-3)||(NNGLD_OPT_TEXCOORD_ADD==-3)||(NNGLD_OPT_TEXCOORD_OPACITY==-3)||(NNGLD_OPT_TEXCOORD_USER1==-3)||(NNGLD_OPT_TEXCOORD_USER2==-3)||(NNGLD_OPT_TEXCOORD_USER3==-3)||(NNGLD_OPT_TEXCOORD_USER4==-3)||(NNGLD_OPT_TEXCOORD_USER5==-3)||(NNGLD_OPT_TEXCOORD_USER6==-3)||(NNGLD_OPT_TEXCOORD_USER7==-3)||(NNGLD_OPT_TEXCOORD_USER8==-3)))
#define DF_DPM (1)
#else
#define DF_DPM (0)
#endif
#if NNGLD_OPT_VTX_COLOR0||DV_LT
vry pcol vec4 vfc;
#endif
#if NNGLD_OPT_SPECULAR
vry pcol vec3 vfsc;
#endif
#if NNGLD_OPT_TWOSIDED_LIGHTING
#if NNGLD_OPT_VTX_COLOR0
vry pcol vec4 vbc;
#endif
#if NNGLD_OPT_SPECULAR
vry pcol vec3 vbsc;
#endif
#endif
#if (DFL||DF_DPM||DPU_WF)||DP_DI(DP8)
vry pvf vec4 vvpf;
#define vvp vvpf.xyz
#define vf vvpf.w
#endif
#if (DFL||DF_DPM)
vry pdir vec3 vn;
#if NNGLD_OPT_TANGENT_SPACE
vry pdir vec3 vt;
vry pdir vec3 vb;
#endif
#endif
#define MAX_TEXCOORD_NO(n) ((DT_NR>=(n))||(DT_WN>=(n))||(DT_B>=(n))||(DT_D1>=(n))||(DT_D2>=(n))||(DT_D3>=(n))||(DT_SP>=(n))||(DT_SN>=(n))||(DT_EM>=(n))||(DT_MD>=(n))||(DT_AD>=(n))||(DT_OP>=(n))||(DT_U1>=(n))||(DT_U2>=(n))||(DT_U3>=(n))||(DT_U4>=(n))||(DT_U5>=(n))||(DT_U6>=(n))||(DT_U7>=(n))||(DT_U8>=(n)))
#if MAX_TEXCOORD_NO(0)
vry puv vec4 vtc01;
#endif
#if MAX_TEXCOORD_NO(2)
vry puv vec4 vtc23;
#endif
#if MAX_TEXCOORD_NO(4)
vry puv vec4 vtc45;
#endif
#if MAX_TEXCOORD_NO(6)
vry puv vec4 vtc67;
#endif
#define nnglvTexCoord0 vtc01.xy
#define vtc1 vtc01.zw
#define vtc2 vtc23.xy
#define vtc3 vtc23.zw
#define vtc4 vtc45.xy
#define vtc5 vtc45.zw
#define vtc6 vtc67.xy
#define vtc7 vtc67.zw
#if DP_DI(DP1)&&(NNGLD_OPT_TEX_SAMPLER2D1!=-1)
vry vec2 vuu;
#endif
#if DPU_HE&&DFL
vry vec3 vhlc;
#endif
#if (DPU_RT)||(DPU_RB)
vry vec4 vpp;
#endif
#if DPU_WR||DPU_WS||DPU_NR||DPU_GR
vry vec4 vphp;
#endif
#if DT_NR==0
#define tc_nr nnglvTexCoord0
#elif DT_NR==1
#define tc_nr vtc1
#elif DT_NR==2
#define tc_nr vtc2
#elif DT_NR==3
#define tc_nr vtc3
#elif DT_NR==4
#define tc_nr vtc4
#elif DT_NR==5
#define tc_nr vtc5
#elif DT_NR==6
#define tc_nr vtc6
#elif DT_NR==7
#define tc_nr vtc7
#endif
#if DT_B==0
#define tc_bn nnglvTexCoord0
#elif DT_B==1
#define tc_bn vtc1
#elif DT_B==2
#define tc_bn vtc2
#elif DT_B==3
#define tc_bn vtc3
#elif DT_B==4
#define tc_bn vtc4
#elif DT_B==5
#define tc_bn vtc5
#elif DT_B==6
#define tc_bn vtc6
#elif DT_B==7
#define tc_bn vtc7
#endif
#if DT_D1==0
#define tc_dc1 nnglvTexCoord0
#elif DT_D1==1
#define tc_dc1 vtc1
#elif DT_D1==2
#define tc_dc1 vtc2
#elif DT_D1==3
#define tc_dc1 vtc3
#elif DT_D1==4
#define tc_dc1 vtc4
#elif DT_D1==5
#define tc_dc1 vtc5
#elif DT_D1==6
#define tc_dc1 vtc6
#elif DT_D1==7
#define tc_dc1 vtc7
#endif
#if DT_D2==0
#define tc_dc2 nnglvTexCoord0
#elif DT_D2==1
#define tc_dc2 vtc1
#elif DT_D2==2
#define tc_dc2 vtc2
#elif DT_D2==3
#define tc_dc2 vtc3
#elif DT_D2==4
#define tc_dc2 vtc4
#elif DT_D2==5
#define tc_dc2 vtc5
#elif DT_D2==6
#define tc_dc2 vtc6
#elif DT_D2==7
#define tc_dc2 vtc7
#endif
#if DT_D3==0
#define tc_dc3 nnglvTexCoord0
#elif DT_D3==1
#define tc_dc3 vtc1
#elif DT_D3==2
#define tc_dc3 vtc2
#elif DT_D3==3
#define tc_dc3 vtc3
#elif DT_D3==4
#define tc_dc3 vtc4
#elif DT_D3==5
#define tc_dc3 vtc5
#elif DT_D3==6
#define tc_dc3 vtc6
#elif DT_D3==7
#define tc_dc3 vtc7
#endif
#if DT_SP==0
#define tc_sp nnglvTexCoord0
#elif DT_SP==1
#define tc_sp vtc1
#elif DT_SP==2
#define tc_sp vtc2
#elif DT_SP==3
#define tc_sp vtc3
#elif DT_SP==4
#define tc_sp vtc4
#elif DT_SP==5
#define tc_sp vtc5
#elif DT_SP==6
#define tc_sp vtc6
#elif DT_SP==7
#define tc_sp vtc7
#endif
#if DT_SN==0
#define tc_sn nnglvTexCoord0
#elif DT_SN==1
#define tc_sn vtc1
#elif DT_SN==2
#define tc_sn vtc2
#elif DT_SN==3
#define tc_sn vtc3
#elif DT_SN==4
#define tc_sn vtc4
#elif DT_SN==5
#define tc_sn vtc5
#elif DT_SN==6
#define tc_sn vtc6
#elif DT_SN==7
#define tc_sn vtc7
#endif
#if DT_EM==0
#define tc_em nnglvTexCoord0
#elif DT_EM==1
#define tc_em vtc1
#elif DT_EM==2
#define tc_em vtc2
#elif DT_EM==3
#define tc_em vtc3
#elif DT_EM==4
#define tc_em vtc4
#elif DT_EM==5
#define tc_em vtc5
#elif DT_EM==6
#define tc_em vtc6
#elif DT_EM==7
#define tc_em vtc7
#endif
#if DT_MD==0
#define tc_md nnglvTexCoord0
#elif DT_MD==1
#define tc_md vtc1
#elif DT_MD==2
#define tc_md vtc2
#elif DT_MD==3
#define tc_md vtc3
#elif DT_MD==4
#define tc_md vtc4
#elif DT_MD==5
#define tc_md vtc5
#elif DT_MD==6
#define tc_md vtc6
#elif DT_MD==7
#define tc_md vtc7
#endif
#if DT_AD==0
#define tc_ad nnglvTexCoord0
#elif DT_AD==1
#define tc_ad vtc1
#elif DT_AD==2
#define tc_ad vtc2
#elif DT_AD==3
#define tc_ad vtc3
#elif DT_AD==4
#define tc_ad vtc4
#elif DT_AD==5
#define tc_ad vtc5
#elif DT_AD==6
#define tc_ad vtc6
#elif DT_AD==7
#define tc_ad vtc7
#endif
#if DT_OP==0
#define tc_op nnglvTexCoord0
#elif DT_OP==1
#define tc_op vtc1
#elif DT_OP==2
#define tc_op vtc2
#elif DT_OP==3
#define tc_op vtc3
#elif DT_OP==4
#define tc_op vtc4
#elif DT_OP==5
#define tc_op vtc5
#elif DT_OP==6
#define tc_op vtc6
#elif DT_OP==7
#define tc_op vtc7
#endif
#if DT_U1==0
#define tc_us1 nnglvTexCoord0
#elif DT_U1==1
#define tc_us1 vtc1
#elif DT_U1==2
#define tc_us1 vtc2
#elif DT_U1==3
#define tc_us1 vtc3
#elif DT_U1==4
#define tc_us1 vtc4
#elif DT_U1==5
#define tc_us1 vtc5
#elif DT_U1==6
#define tc_us1 vtc6
#elif DT_U1==7
#define tc_us1 vtc7
#endif
#if DT_U2==0
#define tc_us2 nnglvTexCoord0
#elif DT_U2==1
#define tc_us2 vtc1
#elif DT_U2==2
#define tc_us2 vtc2
#elif DT_U2==3
#define tc_us2 vtc3
#elif DT_U2==4
#define tc_us2 vtc4
#elif DT_U2==5
#define tc_us2 vtc5
#elif DT_U2==6
#define tc_us2 vtc6
#elif DT_U2==7
#define tc_us2 vtc7
#endif
#if DT_U3==0
#define tc_us3 nnglvTexCoord0
#elif DT_U3==1
#define tc_us3 vtc1
#elif DT_U3==2
#define tc_us3 vtc2
#elif DT_U3==3
#define tc_us3 vtc3
#elif DT_U3==4
#define tc_us3 vtc4
#elif DT_U3==5
#define tc_us3 vtc5
#elif DT_U3==6
#define tc_us3 vtc6
#elif DT_U3==7
#define tc_us3 vtc7
#endif
#if DT_U4==0
#define tc_us4 nnglvTexCoord0
#elif DT_U4==1
#define tc_us4 vtc1
#elif DT_U4==2
#define tc_us4 vtc2
#elif DT_U4==3
#define tc_us4 vtc3
#elif DT_U4==4
#define tc_us4 vtc4
#elif DT_U4==5
#define tc_us4 vtc5
#elif DT_U4==6
#define tc_us4 vtc6
#elif DT_U4==7
#define tc_us4 vtc7
#endif
#if DT_U5==0
#define tc_us5 nnglvTexCoord0
#elif DT_U5==1
#define tc_us5 vtc1
#elif DT_U5==2
#define tc_us5 vtc2
#elif DT_U5==3
#define tc_us5 vtc3
#elif DT_U5==4
#define tc_us5 vtc4
#elif DT_U5==5
#define tc_us5 vtc5
#elif DT_U5==6
#define tc_us5 vtc6
#elif DT_U5==7
#define tc_us5 vtc7
#endif
#if DT_U6==0
#define tc_us6 nnglvTexCoord0
#elif DT_U6==1
#define tc_us6 vtc1
#elif DT_U6==2
#define tc_us6 vtc2
#elif DT_U6==3
#define tc_us6 vtc3
#elif DT_U6==4
#define tc_us6 vtc4
#elif DT_U6==5
#define tc_us6 vtc5
#elif DT_U6==6
#define tc_us6 vtc6
#elif DT_U6==7
#define tc_us6 vtc7
#endif
#if DT_U7==0
#define tc_us7 nnglvTexCoord0
#elif DT_U7==1
#define tc_us7 vtc1
#elif DT_U7==2
#define tc_us7 vtc2
#elif DT_U7==3
#define tc_us7 vtc3
#elif DT_U7==4
#define tc_us7 vtc4
#elif DT_U7==5
#define tc_us7 vtc5
#elif DT_U7==6
#define tc_us7 vtc6
#elif DT_U7==7
#define tc_us7 vtc7
#endif
#if DT_U8==0
#define tc_us8 nnglvTexCoord0
#elif DT_U8==1
#define tc_us8 vtc1
#elif DT_U8==2
#define tc_us8 vtc2
#elif DT_U8==3
#define tc_us8 vtc3
#elif DT_U8==4
#define tc_us8 vtc4
#elif DT_U8==5
#define tc_us8 vtc5
#elif DT_U8==6
#define tc_us8 vtc6
#elif DT_U8==7
#define tc_us8 vtc7
#endif
#if (DN_PL>0)&&NNGLD_OPT_LIGHTING&&DFL
ufm pdir vec3 nngluParallelLightDirection[DN_PL];
ufm pcol vec3 nngluParallelLightDiffuse[DN_PL];
ufm pcol vec3 nngluParallelLightAmbient[DN_PL];
ufm pcol vec3 nngluParallelLightSpecular[DN_PL];
#endif
ufm pcol vec4 nngluFrontMaterialEmissionAlphaRef;
#define sar nngluFrontMaterialEmissionAlphaRef.a
#if NNGLD_OPT_SPECULAR||(DT_SP!=-1)||NNGLD_OPT_LIGHTING
ufm pvf vec4 nngluFrontMaterialSpecularShininess;
#define sfmsp nngluFrontMaterialSpecularShininess.rgb
#define sfmsn nngluFrontMaterialSpecularShininess.a
#endif
#define puv mediump
#if NNGLD_OPT_LIGHTING
ufm pcol vec4 nngluSceneAmbientTangent;
#define sscam nngluSceneAmbientTangent.rgb
#endif
#if (DT_B!=-1)||(DT_D1!=-1)||(DT_D2!=-1)||(DT_D3!=-1)
ufm pcol vec4 nngluTexBaseDecal123Alpha;
#define stba nngluTexBaseDecal123Alpha.x
#define stda nngluTexBaseDecal123Alpha.y
#define stda2 nngluTexBaseDecal123Alpha.z
#define stda3 nngluTexBaseDecal123Alpha.w
#endif
#if (DT_SN!=-1)||(NNGLD_OPT_TEX_DUALPARABOLOID!=-1)||(DT_AD!=-1)
ufm pcol vec3 nngluTexShininessDualParaboloidAddLevel;
#define stsnl nngluTexShininessDualParaboloidAddLevel.x
#define stdpl nngluTexShininessDualParaboloidAddLevel.y
#define stal nngluTexShininessDualParaboloidAddLevel.z
#endif
#if DT_U1!=-1
ufm float nngluTexUser1Param;
#endif
#if (NNGLD_OPT_TEX_DUALPARABOLOID!=-1||((NNGLD_OPT_TEXCOORD_ADD==-3)||(NNGLD_OPT_TEXCOORD_BASE==-3)||(NNGLD_OPT_TEXCOORD_DECAL==-3)||(NNGLD_OPT_TEXCOORD_DECAL2==-3)||(NNGLD_OPT_TEXCOORD_DECAL3==-3)||(NNGLD_OPT_TEXCOORD_SPECULAR==-3)||(NNGLD_OPT_TEXCOORD_SHININESS==-3)||(NNGLD_OPT_TEXCOORD_MODULATE==-3)||(NNGLD_OPT_TEXCOORD_ADD==-3)||(NNGLD_OPT_TEXCOORD_OPACITY==-3)||(NNGLD_OPT_TEXCOORD_USER1==-3)||(NNGLD_OPT_TEXCOORD_USER2==-3)||(NNGLD_OPT_TEXCOORD_USER3==-3)||(NNGLD_OPT_TEXCOORD_USER4==-3)||(NNGLD_OPT_TEXCOORD_USER5==-3)||(NNGLD_OPT_TEXCOORD_USER6==-3)||(NNGLD_OPT_TEXCOORD_USER7==-3)||(NNGLD_OPT_TEXCOORD_USER8==-3)))
ufm mat3 nngluDualParaboloidMatrix;
#endif
#if NNGLD_PROF_MAX_USER_UNIFORM>0
ufm pvf vec4 nngluUserUniform[NNGLD_PROF_MAX_USER_UNIFORM];
#define uusr nngluUserUniform
#endif
pcol vec4 svdc;
pcol vec4 svsc=vec4(.0);
pcol vec3 sfc;
mediump float sfa;
#if (DFL&&((NNGLD_OPT_TEXCOORD_ADD==-1)||(NNGLD_OPT_TEXCOORD_BASE==-1)||(NNGLD_OPT_TEXCOORD_DECAL==-1)||(NNGLD_OPT_TEXCOORD_DECAL2==-1)||(NNGLD_OPT_TEXCOORD_DECAL3==-1)||(NNGLD_OPT_TEXCOORD_SPECULAR==-1)||(NNGLD_OPT_TEXCOORD_SHININESS==-1)||(NNGLD_OPT_TEXCOORD_MODULATE==-1)||(NNGLD_OPT_TEXCOORD_ADD==-1)||(NNGLD_OPT_TEXCOORD_OPACITY==-1)||(NNGLD_OPT_TEXCOORD_USER1==-1)||(NNGLD_OPT_TEXCOORD_USER2==-1)||(NNGLD_OPT_TEXCOORD_USER3==-1)||(NNGLD_OPT_TEXCOORD_USER4==-1)||(NNGLD_OPT_TEXCOORD_USER5==-1)||(NNGLD_OPT_TEXCOORD_USER6==-1)||(NNGLD_OPT_TEXCOORD_USER7==-1)||(NNGLD_OPT_TEXCOORD_USER8==-1)))
#define DF_SPM (1)
puv vec2 ssmtc;
#else
#define DF_SPM (0)
#endif
#if (NNGLD_OPT_TEX_DUALPARABOLOID!=-1||((NNGLD_OPT_TEXCOORD_ADD==-3)||(NNGLD_OPT_TEXCOORD_BASE==-3)||(NNGLD_OPT_TEXCOORD_DECAL==-3)||(NNGLD_OPT_TEXCOORD_DECAL2==-3)||(NNGLD_OPT_TEXCOORD_DECAL3==-3)||(NNGLD_OPT_TEXCOORD_SPECULAR==-3)||(NNGLD_OPT_TEXCOORD_SHININESS==-3)||(NNGLD_OPT_TEXCOORD_MODULATE==-3)||(NNGLD_OPT_TEXCOORD_ADD==-3)||(NNGLD_OPT_TEXCOORD_OPACITY==-3)||(NNGLD_OPT_TEXCOORD_USER1==-3)||(NNGLD_OPT_TEXCOORD_USER2==-3)||(NNGLD_OPT_TEXCOORD_USER3==-3)||(NNGLD_OPT_TEXCOORD_USER4==-3)||(NNGLD_OPT_TEXCOORD_USER5==-3)||(NNGLD_OPT_TEXCOORD_USER6==-3)||(NNGLD_OPT_TEXCOORD_USER7==-3)||(NNGLD_OPT_TEXCOORD_USER8==-3)))
#define DF_DPM (1)
puv vec2 sdpmtc;
#else
#define DF_DPM (0)
#endif
#if DFL||(DT_NR!=-1)||DF_DPM
pdir vec3 sfnr;
pcol vec3 sfdf =vec3(.0);
pcol vec3 sfsp=vec3(.0);
pdir vec3 sn;
pdir vec3 sed;
#if NNGLD_OPT_TANGENT_SPACE
pdir vec3 stn;
pdir vec3 sbn;
#endif
#endif
#if DFL&&NNGLD_PROF_LIGHT_AMBIENT
pcol vec3 sfam=vec3(.0);
#endif
#if DT_NR!=-1
vec4 ssnr;
#endif
vec4 ssbs;
#if DT_D1!=-1
vec4 ssdc;
#endif
#if DT_D2!=-1
vec4 ssdc2;
#endif
#if DT_D3!=-1
vec4 ssdc3;
#endif
#if DT_SP!=-1
vec4 sssp;
#endif
#if DT_SN!=-1
vec4 sssn;
#endif
#if NNGLD_OPT_TEX_DUALPARABOLOID!=-1
vec4 ssdp;
#endif
#if DT_EM!=-1
vec4 ssem;
#endif
#if DT_MD!=-1
vec4 ssmd;
#endif
#if DT_AD!=-1
vec4 ssad;
#endif
#if DT_OP!=-1
vec4 ssop;
#endif
#if DT_U1!=-1
vec4 ssus1;
#endif
#if DP_DI(DP1)&&(NNGLD_OPT_TEX_SAMPLER2D1!=-1)
vec4 sscf;
#endif
#if DT_NR!=-1
ufm pcol smp2D nngltexNormal;
#endif
#if DT_B!=-1
ufm pcol smp2D nngltexBase;
#endif
#if DT_D1!=-1
ufm pcol smp2D nngltexDecal;
#endif
#if DT_D2!=-1
ufm pcol smp2D nngltexDecal2;
#endif
#if DT_D3!=-1
ufm pcol smp2D nngltexDecal3;
#endif
#if DT_SP!=-1
ufm pcol smp2D nngltexSpecular;
#endif
#if DT_SN!=-1
ufm pcol smp2D nngltexShininess;
#endif
#if NNGLD_OPT_TEX_DUALPARABOLOID!=-1
ufm pcol smp2D nngltexDualParaboloid;
#endif
#if DT_EM!=-1
ufm pcol smp2D nngltexEnvMask;
#endif
#if DT_MD!=-1
ufm pcol smp2D nngltexModulate;
#endif
#if DT_AD!=-1
ufm pcol smp2D nngltexAdd;
#endif
#if DT_OP!=-1
ufm pcol smp2D nngltexOpacity;
#endif
#if DT_U1!=-1
ufm pcol smp2D nngltexUser1;
#endif
#if DT_U2!=-1
ufm pcol smp2D nngltexUser2;
#endif
#if DT_U3!=-1
ufm pcol smp2D nngltexUser3;
#endif
#if DT_U4!=-1
ufm pcol smp2D nngltexUser4;
#endif
#if DT_U5!=-1
ufm pcol smp2D nngltexUser5;
#endif
#if DT_U6!=-1
ufm pcol smp2D nngltexUser6;
#endif
#if DT_U7!=-1
ufm pcol smp2D nngltexUser7;
#endif
#if DT_U8!=-1
ufm pcol smp2D nngltexUser8;
#endif
#if NNGLD_OPT_TEX_SAMPLER2D1!=-1
ufm pcol smp2D nngltexUserSampler2D1;
#endif
#if DT_S22!=-1
ufm pcol smp2D nngltexUserSampler2D2;
#endif
#if NNGLD_OPT_TEX_SAMPLER3D1!=-1
ufm pcol sampler3D nngltexUserSampler3D1;
#endif
#if NNGLD_OPT_TEX_SAMPLER3D2!=-1
ufm pcol sampler3D nngltexUserSampler3D2;
#endif
#if DF_SPM
vec2 fcsmtc(){
vec3 r=reflect(sed,sfnr);
r.z+=1.0;
vec2 r2=(nmlz(r).xy)*vec2(.5,-.5)+vec2(.5);
return r2;
}
#endif
#if DF_DPM
vec2 fcdpmtc(){
float s1,izi;
vec3 r=reflect(sed,sfnr);
r=nngluDualParaboloidMatrix*r;
izi=1.0+abs(r.z);
vec2 st=r.xy*vec2(1.0,-1.0)/izi;
st=(st+vec2(1.0))*.5;
s1=step(.0,r.z);
st.x=(.5-s1)*st.x;
return st;
}
#endif
void fnrin(){
#if NNGLD_OPT_LIGHTING
#if DFL||DF_DPM
sed=nmlz(vvp);
#endif
#if DFL||DF_DPM
sn=nmlz(vn);
#if NNGLD_OPT_TANGENT_SPACE
stn=nmlz(vt);
sbn=nmlz(vb);
#endif
#endif
#endif
}
void fstm(){
#if NNGLD_OPT_LIGHTING
#if DFL||DF_DPM
#if DT_NR!=-1
ssnr=t2D(nngltexNormal,tc_nr);
#if NNGLD_OPT_NORMALMAP_AXLY
ssnr=(ssnr-.5)*2.0;
vec3 tn=vec3(ssnr.a,ssnr.r,sqrt(1.0-(ssnr.a*ssnr.a+ssnr.r*ssnr.r)));
tn=nmlz(tn);
#else
vec3 tn=nmlz(ssnr.rgb-.5);
#endif
#if NNGLD_OPT_TANGENT_SPACE
sfnr=tn.x*stn+tn.y*sbn+tn.z*sn;
sfnr=nmlz(sfnr);
#else
sfnr=tn;
#endif
#else
sfnr=sn;
#endif
#if DPU_RT||DPU_RB
vec2 ProjPos2=vpp.xy/vpp.w*vec2(.5)+.5;
vec3 Normal=t2D(nngltexUserSampler2D1,ProjPos2).xyz;
#if DPU_RT
Normal*=2.0;
Normal-=1.0;
#else
Normal*=-2.0;
Normal+=1.0;
#endif
sfnr=nmlz((sfnr+Normal.xyz)*.5);
#endif
#endif
#endif
#if DF_SPM
ssmtc=fcsmtc();
#endif
#if DF_DPM
sdpmtc=fcdpmtc();
#endif
#if DT_EM!=-1
ssem=t2D(nngltexEnvMask,tc_em);
#endif
#if DT_B!=-1
#if DF_SPM&&NNGLD_OPT_TEXCOORD_BASE==-1
ssbs=t2D(nngltexBase,ssmtc);
#elif NNGLD_OPT_TEXCOORD_BASE==-3
ssbs=t2D(nngltexBase,sdpmtc);
#else
ssbs=t2D(nngltexBase,tc_bn);
#endif
#if (DT_EM!=-1)&&((NNGLD_OPT_TEXCOORD_BASE==-1)||(NNGLD_OPT_TEXCOORD_BASE==-3))
ssbs=mix(vec4(1.0),ssbs,ssem.r);
#endif
ssbs.a*=stba;
#else
ssbs=vec4(1.0);
#endif
#if DT_D1!=-1
#if DF_SPM&&NNGLD_OPT_TEXCOORD_DECAL==-1
ssdc=t2D(nngltexDecal,ssmtc);
#elif NNGLD_OPT_TEXCOORD_DECAL==-3
ssdc=t2D(nngltexDecal,sdpmtc);
#else
ssdc=t2D(nngltexDecal,tc_dc1);
#endif
ssdc.a*=stda;
#if (NNGLD_OPT_TEXCOORD_DECAL==-1||NNGLD_OPT_TEXCOORD_DECAL==-3)&&DT_EM!=-1
ssdc.a*=ssem.r;
#endif
#endif
#if DT_D2!=-1
#if DF_SPM&&NNGLD_OPT_TEXCOORD_DECAL2==-1
ssdc2=t2D(nngltexDecal2,ssmtc);
#elif NNGLD_OPT_TEXCOORD_DECAL2==-3
ssdc2=t2D(nngltexDecal2,sdpmtc);
#else
ssdc2=t2D(nngltexDecal2,tc_dc2);
#endif
ssdc2.a*=stda2;
#if (NNGLD_OPT_TEXCOORD_DECAL2==-1||NNGLD_OPT_TEXCOORD_DECAL2==-3)&&DT_EM!=-1
ssdc2.a*=ssem.r;
#endif
#endif
#if DT_D3!=-1
#if DF_SPM&&NNGLD_OPT_TEXCOORD_DECAL3==-1
ssdc3=t2D(nngltexDecal3,ssmtc);
#elif NNGLD_OPT_TEXCOORD_DECAL3==-3
ssdc3=t2D(nngltexDecal3,sdpmtc);
#else
ssdc3=t2D(nngltexDecal3,tc_dc3);
#endif
ssdc3.a*=stda3;
#if (NNGLD_OPT_TEXCOORD_DECAL3==-1||NNGLD_OPT_TEXCOORD_DECAL3==-1)&&DT_EM!=-1
ssdc3.a*=ssem.r;
#endif
#endif
#if DT_SP!=-1
sssp=t2D(nngltexSpecular,tc_sp);
#endif
#if DT_SN!=-1
sssn=t2D(nngltexShininess,tc_sn);
#endif
#if DT_MD!=-1
#if DF_SPM&&NNGLD_OPT_TEXCOORD_MODULATE==-1
ssmd=t2D(nngltexModulate,ssmtc);
#elif NNGLD_OPT_TEXCOORD_MODULATE==-3
ssmd=t2D(nngltexModulate,sdpmtc);
#else
ssmd=t2D(nngltexModulate,tc_md);
#endif
#if DT_EM!=-1&&(NNGLD_OPT_TEXCOORD_MODULATE==-1||NNGLD_OPT_TEXCOORD_MODULATE==-3)
ssmd=vec4(1.0)-(vec4(1.0)-ssmd)*ssem.r;
#endif
#endif
#if DT_AD!=-1
#if DF_SPM&&NNGLD_OPT_TEXCOORD_ADD==-1
ssad=t2D(nngltexAdd,ssmtc);
#elif NNGLD_OPT_TEXCOORD_ADD==-3
ssad=t2D(nngltexAdd,sdpmtc);
#else
ssad=t2D(nngltexAdd,tc_ad);
#endif
ssad*=stal;
#if DT_EM!=-1&&(NNGLD_OPT_TEXCOORD_ADD==-1||NNGLD_OPT_TEXCOORD_ADD==-3)
ssad*=ssem.r;
#endif
#endif
#if NNGLD_OPT_TEX_DUALPARABOLOID!=-1
ssdp=t2D(nngltexDualParaboloid,sdpmtc);
#if DT_EM!=-1
ssdp*=ssem.r;
#endif
ssdp*=stdpl;
#endif
#if NNGLD_OPT_TEX_SAMPLER2D1!=-1
#if DP_DI(DP1)&&DFL
vec2 uv7=vn.xy*vec2(1.0,-1.0)*vec2(64.0/1920.0,64.0/1080.0);
uv7*=min(uusr[DUI_T].w*2.0,1.0);
uv7+=vuu.xy;
sscf=t2D(nngltexUserSampler2D1,uv7);
#endif
#endif
#if DT_S22!=-1
#if DPU_WR
vec2 refra_uv=vphp.xy/vphp.w+.5;
#if DT_WN!=-1
vec3 norm=t2D(nngltexNormal,tc_wn).xyz;
refra_uv+=(norm.xy-vec2(.5))*vec2(.03);
ssbs.rgb=t2D(nngltexUserSampler2D2,refra_uv.xy).rgb;
float half_power=norm.z-.5;
ssbs.rgb*=1.0+min(half_power,.0)+max(half_power,.0)*3.0;
#else
ssbs.rgb=t2D(nngltexUserSampler2D2,refra_uv.xy).rgb;
#endif
#elif DPU_WS
vec2 refra_uv=vphp.xy/vphp.w+.5;
#if DT_WN!=-1
vec3 norm=t2D(nngltexNormal,tc_wn).xyz;
refra_uv+=(norm.xy-vec2(.5))*vec2(.03);
ssbs.rgb=t2D(nngltexUserSampler2D2,refra_uv.xy).rgb;
#if NNGLD_OPT_VTX_COLOR0
svdc.rgb+=norm.z;
#endif
#else
ssbs.rgb=t2D(nngltexUserSampler2D2,refra_uv.xy).rgb;
#endif
#elif DPU_NR
vec2 noref_uv=vphp.xy/vphp.w*vec2(.5,-.5)+.5;
noref_uv.x+=dFdx(noref_uv.x)/2.0;
noref_uv.y+=dFdy(noref_uv.y)/2.0;
ssbs.rgb=t2D(nngltexUserSampler2D2,noref_uv.xy).rgb;
#endif
#endif
#if DT_OP!=-1
#if DF_SPM&&NNGLD_OPT_TEXCOORD_OPACITY==-1
ssop=t2D(nngltexOpacity,ssmtc);
#elif NNGLD_OPT_TEXCOORD_OPACITY==-3
ssop=t2D(nngltexOpacity,sdpmtc);
#else
ssop=t2D(nngltexOpacity,tc_op);
#endif
#if DT_EM!=-1&&(NNGLD_OPT_TEXCOORD_OPACITY==-1||NNGLD_OPT_TEXCOORD_OPACITY==-3)
ssop*=(1.0-ssem.r);
#endif
#endif
#if (DT_D3!=-1)&&(DT_D1!=-1)
sfc=mix(mix(mix(ssbs.rgb,ssdc.rgb,ssdc.a),ssdc2.rgb,ssdc2.a),ssdc3.rgb,ssdc3.a);
#elif (DT_D2!=-1)&&(DT_D1!=-1)
sfc=mix(mix(ssbs.rgb,ssdc.rgb,ssdc.a),ssdc2.rgb,ssdc2.a);
#elif !DPU_T&&(DT_D1!=-1)
// sfc=mix(ssbs.rgb,ssdc.rgb,ssdc.a);
sfc=mix(ssbs.rgb,ssdc.rgb,clamp(ssdc.a,.0,1.0));
#else
sfc=ssbs.rgb;
#endif
#if DPU_GR&&(DT_GRD!=-1)
vec2 uv=vphp.xy/vphp.w+.5;
float depth=t2D(nngltexUserSampler2D2,clamp(vec2(uv.x,1.0-uv.y),.0,1.0)).x;
sfc*=step(1.0,depth);
#endif
}
void fcl1(){
#if !NNGLD_OPT_TWOSIDED_LIGHTING
#if NNGLD_OPT_VTX_COLOR0||DV_LT
svdc=vfc;
#endif
#if NNGLD_OPT_SPECULAR
svsc.rgb=vfsc;
#endif
#else
#if NNGLD_OPT_VTX_COLOR0
svdc=(gl_FrontFacing?vfc:vbc);
#endif
#if NNGLD_OPT_SPECULAR
svsc=(gl_FrontFacing?vfsc:vbsc);
#endif
#endif
}
void fcl2(){
#if NNGLD_OPT_LIGHTING
#if DFL
#if DN_PL>0
#if DPU_T
float rimnrm=pow(1.0-sfnr.z*sfnr.z,uusr[DUI_T].y);
#endif
for(int litno=0;litno<DN_PL; litno++){
vec3 litdir=-nngluParallelLightDirection[litno].xyz;
#if DPU_T
sfdf+=dot(sfnr,litdir);
float rimpow=pow(abs(litdir.z),uusr[DUI_T].z)*rimnrm*sign(litdir.z)*uusr[DUI_T].x;
sfdf-=rimpow;
#else
float fdiff=dot(sfnr,litdir)*.5+.5;
fdiff=fdiff*fdiff;
sfdf+=fdiff*nngluParallelLightDiffuse[litno].rgb;
#endif
#if NNGLD_OPT_SPECULAR
vec3 halfvec=nmlz(litdir-sed);
sfsp+=nngluParallelLightSpecular[litno].rgb*pow(abs(clamp(dot(halfvec,sfnr),.0,1.0)),
#if DT_SN!=-1
stsnl*sssn.r*sfmsn
#else
sfmsn
#endif
);
#endif
#if NNGLD_PROF_LIGHT_AMBIENT
sfam+=nngluParallelLightAmbient[litno].rgb;
#endif
}
#if DPU_T
#if DT_D1!=-1
sfc.xyz-=t2D(nngltexDecal,
vec2(sfdf.x*.5+.5,.5)).xyz;
sfc=clamp(sfc,.0,1.0);
#else
sfc*=(sfdf.x>.7)? 2.0:((sfdf.x<-.7)? .2:1.2);
#endif
#endif
#endif
#if NNGLD_PROF_LIGHT_AMBIENT
sfc*=
#if NNGLD_OPT_VTX_COLOR0
(sfdf*svdc.rgb
#else
(sfdf
#endif
+sscam.rgb+sfam.rgb
#if DPU_HE
+vhlc.rgb
#endif
);
#else
sfc*=
#if NNGLD_OPT_VTX_COLOR0
(sfdf*svdc.rgb
#else
(sfdf
#endif
+sscam.rgb
#if DPU_HE
+vhlc.rgb
#endif
);
#endif
#if DT_SP!=-1
sfsp*=sssp.rgb;
#endif
#if NNGLD_OPT_SPECULAR
sfc+=sfsp*svsc.rgb*sfmsp.rgb;
#else
#if DT_SP!=-1
sfc+=sfsp*sfmsp.rgb;
#endif
#endif
#if DPU_FR
{
vec3 ed=nmlz(-sed);
float inten=pow(1.0-dot(sfnr,ed),uusr[DUI_FR].z);
float frw=smoothstep(1.0-uusr[DUI_FR].x,1.0,inten)*uusr[DUI_FR].y;
sfc+=frw;
}
#endif
#if DP_DI(DP1)&&(NNGLD_OPT_TEX_SAMPLER2D1!=-1)
sfc.xyz=mix(sscf.xyz,sfc.xyz,clamp(uusr[DUI_T].w*2.0-1.0,.0,1.0));
#endif
#else
#if NNGLD_OPT_VTX_COLOR0||DV_LT
sfc*=svdc.rgb;
#endif
#if DT_SP!=-1
#if NNGLD_OPT_SPECULAR
sfc+=sssp.rgb*svsc.rgb*sfmsp.rgb;
#else
sfc+=sssp.rgb*sfmsp.rgb;
#endif
#else
#if NNGLD_OPT_SPECULAR
sfc+=svsc.rgb*sfmsp.rgb;
#else
sfc+=sfmsp.rgb;
#endif
#endif
#endif
#else
#if NNGLD_OPT_VTX_COLOR0
sfc*=svdc.rgb;
#endif
#endif
#if DPU_IC&&(DT_U1!=-1)
ssus1=t2D(nngltexUser1,sfc.rg).rgba;
sfc.rgb=ssus1.rgb;
sfa=ssus1.a;
#if (NNGLD_OPT_ALPHA_TEST)
if (sfa<=sar) discard;
#endif
#endif
}
void fbtf(){
#if DT_MD!=-1
sfc*=ssmd.rgb;
#endif
#if DT_AD!=-1
sfc+=ssad.rgb;
#endif
#if NNGLD_OPT_TEX_DUALPARABOLOID!=-1
sfc+=ssdp.rgb;
#endif
}
void fca(){
#if !DPU_IC
#if DT_D3!=-1
sfa=1.0-(1.0-ssbs.a)*(1.0-ssdc.a)*(1.0-ssdc2.a)*(1.0-ssdc3.a);
#elif DT_D2!=-1
sfa=1.0-(1.0-ssbs.a)*(1.0-ssdc.a)*(1.0-ssdc2.a);
#elif DP_DI(DP1)&&(NNGLD_OPT_TEX_SAMPLER2D1!=-1)
sfa=mix(1.0,ssbs.a,min(uusr[DUI_T].w*2.0,1.0));
#elif (DT_D1!=-1)&&!DPU_T
sfa=ssbs.a+ssdc.a-ssbs.a*ssdc.a;
#else
sfa=ssbs.a;
#endif
#if DT_OP!=-1
sfa*=ssop.r;
#endif
#if DT_MD!=-1
sfa*=ssmd.a;
#endif
#if NNGLD_OPT_VTX_COLOR0
sfa*=svdc.a;
#endif
#if NNGLD_OPT_ALPHA_TEST
if (sfa<=sar) discard;
#endif
#endif
}
void fcf(){
#if DP_DI(DP8)
sfa=sfa*vf;
#endif
#if DPU_OC
sfc=mix(sfc,uusr[7].rgb,uusr[7].a);
#endif
}
void fsfc(){
gl_FragColor.rgb=sfc;
gl_FragColor.a=sfa;
}
void main(){
fnrin();
fcl1();
fstm();
fca();
fcl2();
fbtf();
fcf();
fsfc();
}
