summaryrefslogtreecommitdiff
path: root/shaders/dolphin/smg.2.shader_test
blob: 8b8a1f95466b727d84ab0f30066fdd9280a287a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
[require]
GLSL >= 1.30

[fragment shader]
#version 130
#extension GL_ARB_uniform_buffer_object : enable

#extension GL_ARB_shading_language_420pack : enable


#define ATTRIN in
#define ATTROUT out
#define VARYIN centroid in
#define VARYOUT centroid out
#define float2 vec2
#define float3 vec3
#define float4 vec4
#define int2 ivec2
#define int3 ivec3
#define int4 ivec4
#define frac fract
#define lerp mix

//Pixel Shader for TEV stages
//1 TEV stages, 1 texgens, 0 IND stages
float fmod( float x, float y )
{
	float z = fract( abs( x / y) ) * abs( y );
	return (x < 0.0) ? -z : z;
}
uniform sampler2D samp0;
uniform sampler2D samp1;
uniform sampler2D samp2;
uniform sampler2D samp3;
uniform sampler2D samp4;
uniform sampler2D samp5;
uniform sampler2D samp6;
uniform sampler2D samp7;

layout(std140, binding = 1) uniform PSBlock {
float4 color[4] ;
float4 k[4] ;
float4 alphaRef[1] ;
float4 texdim[8] ;
float4 czbias[2] ;
float4 cindscale[2] ;
float4 cindmtx[6] ;
float4 cfog[3] ;
float4 cPLights[40] ;
float4 cPmtrl[4] ;
};
out vec4 ocol0;
#define depth gl_FragDepth
VARYIN float4 colors_02;
VARYIN float4 colors_12;
VARYIN float3 uv0_2;
VARYIN float4 clipPos_2;
void main()
{
  float4 c0 = color[1], c1 = color[2], c2 = color[3], prev = float4(0.0, 0.0, 0.0, 0.0), textemp = float4(0.0, 0.0, 0.0, 0.0), rastemp = float4(0.0, 0.0, 0.0, 0.0), konsttemp = float4(0.0, 0.0, 0.0, 0.0);
  float3 comp16 = float3(1.0, 255.0, 0.0), comp24 = float3(1.0, 255.0, 255.0*255.0);
  float alphabump=0.0;
  float3 tevcoord=float3(0.0, 0.0, 0.0);
  float2 wrappedcoord=float2(0.0,0.0), tempcoord=float2(0.0,0.0);
  float4 cc0=float4(0.0,0.0,0.0,0.0), cc1=float4(0.0,0.0,0.0,0.0);
  float4 cc2=float4(0.0,0.0,0.0,0.0), cprev=float4(0.0,0.0,0.0,0.0);
  float4 crastemp=float4(0.0,0.0,0.0,0.0),ckonsttemp=float4(0.0,0.0,0.0,0.0);

float4 rawpos = gl_FragCoord;
float4 colors_0 = colors_02;
float4 colors_1 = colors_12;
float3 uv0 = uv0_2;
float4 clipPos = clipPos_2;
	clipPos = float4(rawpos.x, rawpos.y, clipPos.z, clipPos.w);
uv0.xy = uv0.xy * texdim[0].zw;
// TEV stage 0
tevcoord.xy = uv0.xy;
textemp = texture(samp0,tevcoord.xy * texdim[0].xy).rgba;
// color combine
prev.rgb = clamp((c0.rgb)+float3(0.0, 0.0, 0.0), 0.0, 1.0);
// alpha combine
prev.a = clamp(c0.a+float4(0.0, 0.0, 0.0, 0.0).a, 0.0, 1.0);

// TEV done
float zCoord = rawpos.z;
zCoord = dot(czbias[0].xyzw, textemp.xyzw) + czbias[1].w ;
zCoord = zCoord * (16777215.0/16777216.0);
zCoord = frac(zCoord);
zCoord = zCoord * (16777216.0/16777215.0);
depth = zCoord;
	ocol0 = prev;
}

[vertex shader]
#version 130
#extension GL_ARB_uniform_buffer_object : enable

#extension GL_ARB_shading_language_420pack : enable


#define ATTRIN in
#define ATTROUT out
#define VARYIN centroid in
#define VARYOUT centroid out
#define float2 vec2
#define float3 vec3
#define float4 vec4
#define int2 ivec2
#define int3 ivec3
#define int4 ivec4
#define frac fract
#define lerp mix

layout(std140, binding = 2) uniform VSBlock {
float4 cpnmtx[6] ;
float4 cproj[4] ;
float4 cmtrl[4] ;
float4 clights[40] ;
float4 ctexmtx[24] ;
float4 ctrmtx[64] ;
float4 cnmtx[32] ;
float4 cpostmtx[64] ;
float4 cDepth ;
};
struct VS_OUTPUT {
  float4 pos;
  float4 colors_0;
  float4 colors_1;
  float3 tex0;
  float4 clipPos;
};
ATTRIN float4 rawpos; // ATTR0,
ATTRIN float2 tex0; // ATTR8,
VARYOUT  float3 uv0_2;
VARYOUT   float4 clipPos_2;
VARYOUT   float4 colors_02;
VARYOUT   float4 colors_12;
void main()
{
VS_OUTPUT o;
float4 pos = float4(dot(cpnmtx[0], rawpos), dot(cpnmtx[1], rawpos), dot(cpnmtx[2], rawpos), 1.0);
float3 _norm0 = float3(0.0, 0.0, 0.0);
o.pos = float4(dot(cproj[0], pos), dot(cproj[1], pos), dot(cproj[2], pos), dot(cproj[3], pos));
float4 mat, lacc;
float3 ldir, h;
float dist, dist2, attn;
o.colors_0 = float4(1.0, 1.0, 1.0, 1.0);
o.colors_1 = o.colors_0;
float4 coord = float4(0.0, 0.0, 1.0, 1.0);
{
coord = float4(0.0, 0.0, 1.0, 1.0);
coord = float4(tex0.x, tex0.y, 1.0, 1.0);
o.tex0.xyz = float3(dot(coord, ctexmtx[0]), dot(coord, ctexmtx[1]), 1);
float4 P0 = cpostmtx[61];
float4 P1 = cpostmtx[62];
float4 P2 = cpostmtx[63];
o.tex0.xyz = float3(dot(P0.xyz, o.tex0.xyz) + P0.w, dot(P1.xyz, o.tex0.xyz) + P1.w, dot(P2.xyz, o.tex0.xyz) + P2.w);
}
o.clipPos = float4(pos.x,pos.y,o.pos.z,o.pos.w);
o.pos.z = o.pos.w + o.pos.z * 2.0;
 uv0_2.xyz =  o.tex0;
  clipPos_2 = o.clipPos;
colors_02 = o.colors_0;
colors_12 = o.colors_1;
gl_Position = o.pos;
}