|
#version 430
|
|
|
|
#define FORCE_EARLY_Z layout(early_fragment_tests) in
|
|
|
|
#extension GL_ARB_shading_language_420pack : enable
|
|
|
|
#define ATTRIBUTE_LOCATION(x)
|
|
#define FRAGMENT_OUTPUT_LOCATION(x)
|
|
#define FRAGMENT_OUTPUT_LOCATION_INDEXED(x, y)
|
|
#define UBO_BINDING(packing, x) layout(packing, binding = x)
|
|
#define SAMPLER_BINDING(x) layout(binding = x)
|
|
#define TEXEL_BUFFER_BINDING(x) layout(binding = x)
|
|
#define SSBO_BINDING(x) layout(binding = x)
|
|
#define IMAGE_BINDING(format, x) layout(format, binding = x)
|
|
|
|
#define VARYING_LOCATION(x)
|
|
|
|
#extension GL_ARB_shader_storage_buffer_object : enable
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#extension GL_NV_shader_thread_group : enable
|
|
#extension GL_NV_shader_thread_shuffle : enable
|
|
#define SUPPORTS_SUBGROUP_REDUCTION 1
|
|
|
|
// The xor shuffle below produces incorrect results if all threads in a warp are not active.
|
|
#define CAN_USE_SUBGROUP_REDUCTION (ballotThreadNV(true) == 0xFFFFFFFFu)
|
|
|
|
#define IS_HELPER_INVOCATION gl_HelperThreadNV
|
|
#define IS_FIRST_ACTIVE_INVOCATION (gl_ThreadInWarpNV == findLSB(ballotThreadNV(!gl_HelperThreadNV)))
|
|
#define SUBGROUP_REDUCTION(func, value) value = func(value, shuffleXorNV(value, 16, 32)); \
|
|
value = func(value, shuffleXorNV(value, 8, 32)); \
|
|
value = func(value, shuffleXorNV(value, 4, 32)); \
|
|
value = func(value, shuffleXorNV(value, 2, 32)); \
|
|
value = func(value, shuffleXorNV(value, 1, 32));
|
|
#define SUBGROUP_MIN(value) SUBGROUP_REDUCTION(min, value)
|
|
#define SUBGROUP_MAX(value) SUBGROUP_REDUCTION(max, value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define API_OPENGL 1
|
|
#define float2 vec2
|
|
#define float3 vec3
|
|
#define float4 vec4
|
|
#define uint2 uvec2
|
|
#define uint3 uvec3
|
|
#define uint4 uvec4
|
|
#define int2 ivec2
|
|
#define int3 ivec3
|
|
#define int4 ivec4
|
|
#define frac fract
|
|
#define lerp mix
|
|
//Pixel Shader for TEV stages
|
|
//1 TEV stages, 13 texgens, 0 IND stages
|
|
int idot(int3 x, int3 y)
|
|
{
|
|
int3 tmp = x * y;
|
|
return tmp.x + tmp.y + tmp.z;
|
|
}
|
|
int idot(int4 x, int4 y)
|
|
{
|
|
int4 tmp = x * y;
|
|
return tmp.x + tmp.y + tmp.z + tmp.w;
|
|
}
|
|
|
|
int iround(float x) { return int (round(x)); }
|
|
int2 iround(float2 x) { return int2(round(x)); }
|
|
int3 iround(float3 x) { return int3(round(x)); }
|
|
int4 iround(float4 x) { return int4(round(x)); }
|
|
|
|
SAMPLER_BINDING(0) uniform sampler2DArray samp[8];
|
|
|
|
UBO_BINDING(std140, 1) uniform PSBlock {
|
|
int4 color[4];
|
|
int4 k[4];
|
|
int4 alphaRef;
|
|
float4 texdim[8];
|
|
int4 czbias[2];
|
|
int4 cindscale[2];
|
|
int4 cindmtx[6];
|
|
int4 cfogcolor;
|
|
int4 cfogi;
|
|
float4 cfogf;
|
|
float4 cfogrange[3];
|
|
float4 czslope;
|
|
float2 cefbscale;
|
|
uint bpmem_genmode;
|
|
uint bpmem_alphaTest;
|
|
uint bpmem_fogParam3;
|
|
uint bpmem_fogRangeBase;
|
|
uint bpmem_dstalpha;
|
|
uint bpmem_ztex_op;
|
|
bool bpmem_late_ztest;
|
|
bool bpmem_rgba6_format;
|
|
bool bpmem_dither;
|
|
bool bpmem_bounding_box;
|
|
uint4 bpmem_pack1[16];
|
|
uint4 bpmem_pack2[8];
|
|
int4 konstLookup[32];
|
|
bool blend_enable;
|
|
uint blend_src_factor;
|
|
uint blend_src_factor_alpha;
|
|
uint blend_dst_factor;
|
|
uint blend_dst_factor_alpha;
|
|
bool blend_subtract;
|
|
bool blend_subtract_alpha;
|
|
};
|
|
|
|
#define bpmem_combiners(i) (bpmem_pack1[(i)].xy)
|
|
#define bpmem_tevind(i) (bpmem_pack1[(i)].z)
|
|
#define bpmem_iref(i) (bpmem_pack1[(i)].w)
|
|
#define bpmem_tevorder(i) (bpmem_pack2[(i)].x)
|
|
#define bpmem_tevksel(i) (bpmem_pack2[(i)].y)
|
|
|
|
struct Light {
|
|
int4 color;
|
|
float4 cosatt;
|
|
float4 distatt;
|
|
float4 pos;
|
|
float4 dir;
|
|
};
|
|
UBO_BINDING(std140, 2) uniform VSBlock {
|
|
uint components;
|
|
uint xfmem_dualTexInfo;
|
|
uint xfmem_numColorChans;
|
|
float4 cpnmtx[6];
|
|
float4 cproj[4];
|
|
int4 cmtrl[4];
|
|
Light clights[8];
|
|
float4 ctexmtx[24];
|
|
float4 ctrmtx[64];
|
|
float4 cnmtx[32];
|
|
float4 cpostmtx[64];
|
|
float4 cpixelcenter;
|
|
float2 cviewport;
|
|
uint4 xfmem_pack1[8];
|
|
#define xfmem_texMtxInfo(i) (xfmem_pack1[(i)].x)
|
|
#define xfmem_postMtxInfo(i) (xfmem_pack1[(i)].y)
|
|
#define xfmem_color(i) (xfmem_pack1[(i)].z)
|
|
#define xfmem_alpha(i) (xfmem_pack1[(i)].w)
|
|
};
|
|
FORCE_EARLY_Z;
|
|
FRAGMENT_OUTPUT_LOCATION_INDEXED(0, 0) out vec4 ocol0;
|
|
FRAGMENT_OUTPUT_LOCATION_INDEXED(0, 1) out vec4 ocol1;
|
|
VARYING_LOCATION(0) in VertexData {
|
|
float4 pos;
|
|
float4 colors_0;
|
|
float4 colors_1;
|
|
float3 tex0;
|
|
float3 tex1;
|
|
float3 tex2;
|
|
float3 tex3;
|
|
float3 tex4;
|
|
float3 tex5;
|
|
float3 tex6;
|
|
float3 tex7;
|
|
float3 tex8;
|
|
float3 tex9;
|
|
float3 tex10;
|
|
float3 tex11;
|
|
float3 tex12;
|
|
float3 Normal;
|
|
float3 WorldPos;
|
|
float clipDist0;
|
|
float clipDist1;
|
|
};
|
|
void main()
|
|
{
|
|
float4 rawpos = gl_FragCoord;
|
|
int4 c0 = color[1], c1 = color[2], c2 = color[3], prev = color[0];
|
|
int4 rastemp = int4(0, 0, 0, 0), textemp = int4(0, 0, 0, 0), konsttemp = int4(0, 0, 0, 0);
|
|
int3 comp16 = int3(1, 256, 0), comp24 = int3(1, 256, 256*256);
|
|
int alphabump=0;
|
|
int3 tevcoord=int3(0, 0, 0);
|
|
int2 wrappedcoord=int2(0,0), tempcoord=int2(0,0);
|
|
int4 tevin_a=int4(0,0,0,0),tevin_b=int4(0,0,0,0),tevin_c=int4(0,0,0,0),tevin_d=int4(0,0,0,0);
|
|
|
|
float4 col0 = colors_0;
|
|
float4 col1 = colors_1;
|
|
float3 _norm0 = normalize(Normal.xyz);
|
|
|
|
float3 pos = WorldPos;
|
|
int4 lacc;
|
|
float3 ldir, h, cosAttn, distAttn;
|
|
float dist, dist2, attn;
|
|
{
|
|
int4 mat = cmtrl[2];
|
|
lacc = int4(255, 255, 255, 255);
|
|
lacc.w = 255;
|
|
lacc = clamp(lacc, 0, 255);
|
|
col0 = float4((mat * (lacc + (lacc >> 7))) >> 8) / 255.0;
|
|
}
|
|
{
|
|
int4 mat = cmtrl[3];
|
|
lacc = int4(255, 255, 255, 255);
|
|
lacc.w = 255;
|
|
lacc = clamp(lacc, 0, 255);
|
|
col1 = float4((mat * (lacc + (lacc >> 7))) >> 8) / 255.0;
|
|
}
|
|
int2 fixpoint_uv0 = int2((tex0.z == 0.0 ? tex0.xy : tex0.xy / tex0.z) * texdim[0].zw);
|
|
int2 fixpoint_uv1 = int2((tex1.z == 0.0 ? tex1.xy : tex1.xy / tex1.z) * texdim[1].zw);
|
|
int2 fixpoint_uv2 = int2((tex2.z == 0.0 ? tex2.xy : tex2.xy / tex2.z) * texdim[2].zw);
|
|
int2 fixpoint_uv3 = int2((tex3.z == 0.0 ? tex3.xy : tex3.xy / tex3.z) * texdim[3].zw);
|
|
int2 fixpoint_uv4 = int2((tex4.z == 0.0 ? tex4.xy : tex4.xy / tex4.z) * texdim[4].zw);
|
|
int2 fixpoint_uv5 = int2((tex5.z == 0.0 ? tex5.xy : tex5.xy / tex5.z) * texdim[5].zw);
|
|
int2 fixpoint_uv6 = int2((tex6.z == 0.0 ? tex6.xy : tex6.xy / tex6.z) * texdim[6].zw);
|
|
int2 fixpoint_uv7 = int2((tex7.z == 0.0 ? tex7.xy : tex7.xy / tex7.z) * texdim[7].zw);
|
|
int2 fixpoint_uv8 = int2((tex8.z == 0.0 ? tex8.xy : tex8.xy / tex8.z) * texdim[8].zw);
|
|
int2 fixpoint_uv9 = int2((tex9.z == 0.0 ? tex9.xy : tex9.xy / tex9.z) * texdim[9].zw);
|
|
int2 fixpoint_uv10 = int2((tex10.z == 0.0 ? tex10.xy : tex10.xy / tex10.z) * texdim[10].zw);
|
|
int2 fixpoint_uv11 = int2((tex11.z == 0.0 ? tex11.xy : tex11.xy / tex11.z) * texdim[11].zw);
|
|
int2 fixpoint_uv12 = int2((tex12.z == 0.0 ? tex12.xy : tex12.xy / tex12.z) * texdim[12].zw);
|
|
|
|
// TEV stage 0
|
|
rastemp = iround(col0 * 255.0).rrba;
|
|
tevcoord.xy = fixpoint_uv0;
|
|
textemp = iround(255.0 * texture(samp[0], float3(float2(tevcoord.xy).xy * texdim[0].xy, 0.0))).rrba;
|
|
tevin_a = int4(int3(0,0,0), 0)&int4(255, 255, 255, 255);
|
|
tevin_b = int4(textemp.rgb, textemp.a)&int4(255, 255, 255, 255);
|
|
tevin_c = int4(rastemp.rgb, rastemp.a)&int4(255, 255, 255, 255);
|
|
tevin_d = int4(int3(0,0,0), 0);
|
|
// color combine
|
|
prev.rgb = clamp((((tevin_d.rgb)) + (((((tevin_a.rgb<<8) + (tevin_b.rgb-tevin_a.rgb)*(tevin_c.rgb+(tevin_c.rgb>>7)))) + 128)>>8)), int3(0,0,0), int3(255,255,255));
|
|
// alpha combine
|
|
prev.a = clamp((((tevin_d.a)) + (((((tevin_a.a<<8) + (tevin_b.a-tevin_a.a)*(tevin_c.a+(tevin_c.a>>7)))))>>8)), 0, 255);
|
|
prev = prev & 255;
|
|
int zCoord = int(rawpos.z * 16777216.0);
|
|
zCoord = clamp(zCoord, 0, 0xFFFFFF);
|
|
float ze = (cfogf.x * 16777216.0) / float(cfogi.y - (zCoord >> cfogi.w));
|
|
float fog = clamp(ze - cfogf.y, 0.0, 1.0);
|
|
int ifog = iround(fog * 256.0);
|
|
prev.rgb = (prev.rgb * (256 - ifog) + cfogcolor.rgb * ifog) >> 8;
|
|
ocol0.rgb = float3(prev.rgb) / 255.0;
|
|
ocol0.a = float(prev.a >> 2) / 63.0;
|
|
ocol1 = float4(0.0, 0.0, 0.0, float(prev.a) / 255.0);
|
|
}
|
|
0(219) : error C1068: array index out of bounds
|
|
0(220) : error C1068: array index out of bounds
|
|
0(221) : error C1068: array index out of bounds
|
|
0(222) : error C1068: array index out of bounds
|
|
0(223) : error C1068: array index out of bounds
|
|
|