Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //== PROGRAM LINK STATUS = TRUE
- //== PROGRAM VALIDATE STATUS = TRUE
- //======================================================
- // Vertex Shader 1
- //======================================================
- //== SHADER COMPILE STATUS = TRUE
- #version 150
- float saturate( float v ) { return clamp( v, 0.0, 1.0 ); }
- vec2 saturate( vec2 v ) { return clamp( v, 0.0, 1.0 ); }
- vec3 saturate( vec3 v ) { return clamp( v, 0.0, 1.0 ); }
- vec4 saturate( vec4 v ) { return clamp( v, 0.0, 1.0 ); }
- float dot3 ( vec3 a, vec3 b ) { return dot( a, b ); }
- float dot3 ( vec3 a, vec4 b ) { return dot( a, b.xyz ); }
- float dot3 ( vec4 a, vec3 b ) { return dot( a.xyz, b ); }
- float dot3 ( vec4 a, vec4 b ) { return dot( a.xyz, b.xyz ); }
- float dot4 ( vec4 a, vec4 b ) { return dot( a, b ); }
- float dot4 ( vec2 a, vec4 b ) { return dot( vec4( a, 0, 1 ), b ); }
- uniform vec4 _va_ [13];
- uniform vec4 skinOffsets ;
- uniform vec4 hardwareSkinning ;
- uniform matrices_ubo { vec4 matrices[768]; };
- in vec4 in_Position;
- in vec2 in_TexCoord;
- in vec4 in_Normal;
- in vec4 in_Tangent;
- in vec4 in_Color;
- in vec4 in_Morph;
- out vec4 gl_Position;
- out vec4 vofi_TexCoord0;
- out vec4 vofi_TexCoord1;
- out vec4 vofi_TexCoord2;
- out vec4 vofi_TexCoord3;
- out vec4 vofi_TexCoord4;
- void main() {
- vec4 position = in_Position * _va_[0 ] + _va_[1 ];
- vec4 normal = in_Normal * 2.0 - 1.0;
- vec4 tangent = in_Tangent * 2.0 - 1.0;
- float morphScale = 0.0;
- if ( hardwareSkinning.x != 0.0 ) {
- vec4 vertexPosition = position;
- if ( hardwareSkinning.y != 0.0 ) {
- vec3 morphVector = ( in_Morph.xyz * 2 ) - 1;
- morphScale = in_Morph.w;
- vertexPosition.xyz += ( morphVector * morphScale * 32.0 );
- }
- float weights = in_Normal.w * 255;
- float w1 = floor( weights / 16 );
- float w2 = floor( weights / 4 ) - ( w1 * 4 );
- float w3 = weights - ( w2 * 4 ) - ( w1 * 16 );
- w1 *= 1.0 / 30.0;
- w2 *= 1.0 / 9.0;
- w3 *= 1.0 / 12.0;
- float w0 = 1 - ( w1 + w2 + w3 );
- vec4 matX, matY, matZ;
- float joint = in_Color.r * 255;
- matX = matrices[int(joint*3+0)] * w0;
- matY = matrices[int(joint*3+1)] * w0;
- matZ = matrices[int(joint*3+2)] * w0;
- joint = in_Color.g * 255;
- matX += matrices[int(joint*3+0)] * w1;
- matY += matrices[int(joint*3+1)] * w1;
- matZ += matrices[int(joint*3+2)] * w1;
- joint = in_Color.b * 255;
- matX += matrices[int(joint*3+0)] * w2;
- matY += matrices[int(joint*3+1)] * w2;
- matZ += matrices[int(joint*3+2)] * w2;
- joint = in_Color.a * 255;
- matX += matrices[int(joint*3+0)] * w3;
- matY += matrices[int(joint*3+1)] * w3;
- matZ += matrices[int(joint*3+2)] * w3;
- position.x = dot4( vertexPosition, matX );
- position.y = dot4( vertexPosition, matY );
- position.z = dot4( vertexPosition, matZ );
- position.w = 1.0;
- vec4 tempNormal = normal;
- normal.x = dot3( tempNormal, matX );
- normal.y = dot3( tempNormal, matY );
- normal.z = dot3( tempNormal, matZ );
- vec4 tempTangent = tangent;
- tangent.x = dot3( tempTangent, matX );
- tangent.y = dot3( tempTangent, matY );
- tangent.z = dot3( tempTangent, matZ );
- }
- vec3 bitangent = cross( normal.xyz, tangent.xyz ) * tangent.w;
- gl_Position.x = dot4( position, _va_[2 ] );
- gl_Position.y = dot4( position, _va_[3 ] );
- gl_Position.z = dot4( position, _va_[4 ] );
- gl_Position.w = dot4( position, _va_[5 ] );
- vofi_TexCoord0.xy = in_TexCoord.xy + skinOffsets.xy;
- vofi_TexCoord0.zw = in_TexCoord.xy + skinOffsets.zw;
- vofi_TexCoord1.x = dot3( tangent, _va_[6 ] );
- vofi_TexCoord1.y = dot3( bitangent, _va_[6 ] );
- vofi_TexCoord1.z = dot3( normal, _va_[6 ] );
- vofi_TexCoord1.w = morphScale;
- vofi_TexCoord2.x = dot3( tangent, _va_[7 ] );
- vofi_TexCoord2.y = dot3( bitangent, _va_[7 ] );
- vofi_TexCoord2.z = dot3( normal, _va_[7 ] );
- vofi_TexCoord2.w = 0.0;
- vofi_TexCoord3.x = dot3( tangent, _va_[8 ] );
- vofi_TexCoord3.y = dot3( bitangent, _va_[8 ] );
- vofi_TexCoord3.z = dot3( normal, _va_[8 ] );
- vofi_TexCoord3.w = 0.0;
- vofi_TexCoord4.x = dot4( position, _va_[6 ] );
- vofi_TexCoord4.y = dot4( position, _va_[7 ] );
- vofi_TexCoord4.z = dot4( position, _va_[8 ] );
- vofi_TexCoord4.xyz -= _va_[9 ].xyz;
- vofi_TexCoord4.w = -( clamp( gl_Position.w - _va_[10 ].x, 0.0, _va_[11 ].x ) * _va_[12 ].x );
- }
- //======================================================
- // Fragment Shader 2
- //======================================================
- //== SHADER COMPILE STATUS = TRUE
- #version 150
- void clip( float v ) { if ( v < 0.0 ) { discard; } }
- void clip( vec2 v ) { if ( any( lessThan( v, vec2( 0.0 ) ) ) ) { discard; } }
- void clip( vec3 v ) { if ( any( lessThan( v, vec3( 0.0 ) ) ) ) { discard; } }
- void clip( vec4 v ) { if ( any( lessThan( v, vec4( 0.0 ) ) ) ) { discard; } }
- float saturate( float v ) { return clamp( v, 0.0, 1.0 ); }
- vec2 saturate( vec2 v ) { return clamp( v, 0.0, 1.0 ); }
- vec3 saturate( vec3 v ) { return clamp( v, 0.0, 1.0 ); }
- vec4 saturate( vec4 v ) { return clamp( v, 0.0, 1.0 ); }
- vec4 tex2D( sampler2D sampler, vec2 texcoord ) { return texture( sampler, texcoord.xy ); }
- vec4 tex2D( sampler2DShadow sampler, vec3 texcoord ) { return vec4( texture( sampler, texcoord.xyz ) ); }
- vec4 tex2D( sampler2D sampler, vec2 texcoord, vec2 dx, vec2 dy ) { return textureGrad( sampler, texcoord.xy, dx, dy ); }
- vec4 tex2D( sampler2DShadow sampler, vec3 texcoord, vec2 dx, vec2 dy ) { return vec4( textureGrad( sampler, texcoord.xyz, dx, dy ) ); }
- vec4 texCUBE( samplerCube sampler, vec3 texcoord ) { return texture( sampler, texcoord.xyz ); }
- vec4 texCUBE( samplerCubeShadow sampler, vec4 texcoord ) { return vec4( texture( sampler, texcoord.xyzw ) ); }
- vec4 tex1Dproj( sampler1D sampler, vec2 texcoord ) { return textureProj( sampler, texcoord ); }
- vec4 tex2Dproj( sampler2D sampler, vec3 texcoord ) { return textureProj( sampler, texcoord ); }
- vec4 tex3Dproj( sampler3D sampler, vec4 texcoord ) { return textureProj( sampler, texcoord ); }
- vec4 tex1Dbias( sampler1D sampler, vec4 texcoord ) { return texture( sampler, texcoord.x, texcoord.w ); }
- vec4 tex2Dbias( sampler2D sampler, vec4 texcoord ) { return texture( sampler, texcoord.xy, texcoord.w ); }
- vec4 tex3Dbias( sampler3D sampler, vec4 texcoord ) { return texture( sampler, texcoord.xyz, texcoord.w ); }
- vec4 texCUBEbias( samplerCube sampler, vec4 texcoord ) { return texture( sampler, texcoord.xyz, texcoord.w ); }
- vec4 tex1Dlod( sampler1D sampler, vec4 texcoord ) { return textureLod( sampler, texcoord.x, texcoord.w ); }
- vec4 tex2Dlod( sampler2D sampler, vec4 texcoord ) { return textureLod( sampler, texcoord.xy, texcoord.w ); }
- vec4 tex3Dlod( sampler3D sampler, vec4 texcoord ) { return textureLod( sampler, texcoord.xyz, texcoord.w ); }
- vec4 texCUBElod( samplerCube sampler, vec4 texcoord ) { return textureLod( sampler, texcoord.xyz, texcoord.w ); }
- float dot3 ( vec3 a, vec3 b ) { return dot( a, b ); }
- float dot3 ( vec3 a, vec4 b ) { return dot( a, b.xyz ); }
- float dot3 ( vec4 a, vec3 b ) { return dot( a.xyz, b ); }
- float dot3 ( vec4 a, vec4 b ) { return dot( a.xyz, b.xyz ); }
- float dot4 ( vec4 a, vec4 b ) { return dot( a, b ); }
- float dot4 ( vec2 a, vec4 b ) { return dot( vec4( a, 0, 1 ), b ); }
- vec4 texPhys ( sampler2D image, vec2 texcoord ) { return tex2D( image, texcoord ); }
- vec4 texPhys ( sampler2D image, vec2 texcoord, vec2 dx, vec2 dy ) { return tex2D( image, texcoord, dx, dy ); }
- vec2 screenPosToTexcoord ( vec2 pos, vec4 bias_scale ) { return ( pos * bias_scale.zw + bias_scale.xy ); }
- const vec4 matrixCoCg1YtoRGB1X = vec4( 1.0, -1.0, 0.0, 1.0 );
- const vec4 matrixCoCg1YtoRGB1Y = vec4( 0.0, 1.0, -0.50196078, 1.0 );
- const vec4 matrixCoCg1YtoRGB1Z = vec4( -1.0, -1.0, 1.00392156, 1.0 );
- vec3 VirtualToPhysical2 ( sampler2D virtToPhysPage, sampler2D physPageToXform0, vec2 virtCoords ) {
- vec2 physPage = tex2D( virtToPhysPage, virtCoords).xy;
- vec4 xform = tex2D( physPageToXform0, physPage );
- vec3 physCoord;
- physCoord.xy = virtCoords * xform.x + xform.zw;
- physCoord.z = xform.y;
- return physCoord;
- }
- vec3 ScaleSpecular ( vec3 unscaled, float factor ) {
- return ( unscaled * 8.0 ) / ( factor * 255.0 + 8.0 );
- }
- uniform vec4 _fa_ [20];
- uniform sampler2D samp_pagetablemap;
- uniform sampler2D samp_physicalvmtrmappingsmap0;
- uniform sampler2D samp_physicalvmtrpagesmap0;
- uniform sampler2D samp_physicalvmtrpagesmap1;
- uniform sampler2D samp_physicalvmtrpagesmap2;
- uniform samplerCube samp_dynamicenvmap;
- uniform sampler2D samp_viewcolormap;
- in vec4 gl_FragCoord;
- in vec4 vofi_TexCoord0;
- in vec4 vofi_TexCoord1;
- in vec4 vofi_TexCoord2;
- in vec4 vofi_TexCoord3;
- in vec4 vofi_TexCoord4;
- out vec4 out_FragColor;
- void main() {
- vec2 texcoord = vofi_TexCoord0.xy;
- vec2 texcoord2 = vofi_TexCoord0.zw; if ( _fa_[0 ].x > 0 ) {
- texcoord = fract( texcoord ) * _fa_[1 ].xy + _fa_[1 ].zw;
- texcoord2 = fract( texcoord2 ) * _fa_[1 ].xy + _fa_[1 ].zw;
- }
- vec3 physCoord = VirtualToPhysical2( samp_pagetablemap, samp_physicalvmtrmappingsmap0, texcoord);
- vec4 specularPage = texPhys( samp_physicalvmtrpagesmap0, physCoord.xy );
- vec4 YCoCg = texPhys( samp_physicalvmtrpagesmap1, physCoord.xy );
- vec4 bumpPage = texPhys( samp_physicalvmtrpagesmap2, physCoord.xy ); if ( _fa_[2 ].x > 0.0 ) {
- vec3 physCoord = VirtualToPhysical2( samp_pagetablemap, samp_physicalvmtrmappingsmap0, texcoord2);
- vec4 specularPage2 = texPhys( samp_physicalvmtrpagesmap0, physCoord.xy );
- vec4 YCoCg2 = texPhys( samp_physicalvmtrpagesmap1, physCoord.xy );
- vec4 bumpPage2 = texPhys( samp_physicalvmtrpagesmap2, physCoord.xy );
- float morphScale = vofi_TexCoord1.w;
- specularPage = mix( specularPage, specularPage2, morphScale );
- YCoCg = mix( YCoCg, YCoCg2, morphScale );
- bumpPage = mix( bumpPage, bumpPage2, morphScale );
- }
- vec3 diffuse;
- YCoCg.z = ( YCoCg.z * 31.875 ) + 1.0;
- YCoCg.z = 1.0 / YCoCg.z;
- YCoCg.xy *= YCoCg.z;
- diffuse.x = dot4( YCoCg, matrixCoCg1YtoRGB1X );
- diffuse.y = dot4( YCoCg, matrixCoCg1YtoRGB1Y );
- diffuse.z = dot4( YCoCg, matrixCoCg1YtoRGB1Z );
- specularPage.xyz = ScaleSpecular( specularPage.xyz, bumpPage.z );
- float powerFactor = bumpPage.x;
- vec3 localNormal = bumpPage.wyz - 0.5;
- localNormal.z = sqrt( abs( dot( localNormal.xy, localNormal.xy ) - 0.25 ) );
- vec3 globalNormal;
- globalNormal.x = dot3( localNormal, vofi_TexCoord1.xyz );
- globalNormal.y = dot3( localNormal, vofi_TexCoord2.xyz );
- globalNormal.z = dot3( localNormal, vofi_TexCoord3.xyz );
- globalNormal = normalize( globalNormal );
- vec3 fromViewer = normalize( vofi_TexCoord4.xyz );
- vec4 reflection;
- reflection.xyz = fromViewer - ( globalNormal * dot3( fromViewer, globalNormal ) * 2.0 );
- reflection.w = floor( ( 1.0 - powerFactor ) * 4.0 + _fa_[3 ].x );
- vec3 envColor = texCUBElod( samp_dynamicenvmap, reflection ).xyz;
- vec4 window;
- window.xy = screenPosToTexcoord( gl_FragCoord.xy, _fa_[4 ] );
- window.z = 0.0;
- window.w = 0.0;
- float shadow = tex2Dlod( samp_viewcolormap, window ).w;
- shadow = saturate( shadow + _fa_[5 ].x );
- vec3 primeLight = shadow * _fa_[6 ].xyz *
- saturate( dot3( _fa_[7 ], globalNormal ) - 0.2 );
- vec3 light = primeLight
- + max( globalNormal.x * _fa_[8 ].xyz, 0 )
- + max( -globalNormal.x * _fa_[9 ].xyz, 0 )
- + max( globalNormal.y * _fa_[10 ].xyz, 0 )
- + max( -globalNormal.y * _fa_[11 ].xyz, 0 )
- + max( globalNormal.z * _fa_[12 ].xyz, 0 )
- + max( -globalNormal.z * _fa_[13 ].xyz, 0 );
- float graze = saturate( dot3( -fromViewer, globalNormal ) );
- graze = saturate( ( _fa_[14 ].x - max( graze, -graze ) ) / max( _fa_[14 ].x, 0.0001 ) );
- diffuse.xyz = mix( diffuse.xyz, _fa_[15 ].xyz, graze );
- specularPage.xyz = mix( specularPage.xyz, _fa_[16 ].xyz, graze );
- vec3 color = light * ( envColor * specularPage.xyz * _fa_[17 ].xyz )
- + light * ( diffuse.xyz * _fa_[18 ].xyz * 2.0 );
- float fog = saturate( exp2( vofi_TexCoord4.w ) );
- out_FragColor.xyz = mix( _fa_[19 ].xyz, color.xyz, fog );
- out_FragColor.w = specularPage.w;
- }
Advertisement
Add Comment
Please, Sign In to add comment