bgfx/3rdparty/glsl-optimizer/tests/fragment/zun-Hidden_Camera-DepthNormalTexture1-in.txt

73 lines
1.6 KiB
Text
Raw Normal View History

2012-04-03 23:30:07 -04:00
void xll_clip(float x) {
if ( x<0.0 ) discard;
}
struct v2f_vertex_lit {
vec2 uv;
vec4 diff;
vec4 spec;
};
struct v2f_img {
vec4 pos;
vec2 uv;
};
struct appdata_img {
vec4 vertex;
vec2 texcoord;
};
struct v2f {
vec4 pos;
vec2 uv;
vec4 nz;
};
struct appdata_grass {
vec4 vertex;
vec4 tangent;
vec4 color;
vec4 texcoord;
vec4 texcoord1;
};
uniform float _Cutoff;
uniform sampler2D _MainTex;
vec2 EncodeViewNormalStereo( in vec3 n );
vec2 EncodeFloatRG( in float v );
vec4 EncodeDepthNormal( in float depth, in vec3 normal );
vec4 frag( in v2f i );
vec2 EncodeViewNormalStereo( in vec3 n ) {
float kScale = 1.77770;
vec2 enc;
enc = (n.xy / (n.z + 1.00000));
enc /= kScale;
enc = ((enc * 0.500000) + 0.500000);
return enc;
}
vec2 EncodeFloatRG( in float v ) {
vec2 kEncodeMul = vec2( 1.00000, 255.000);
float kEncodeBit = 0.00392157;
vec2 enc;
enc = (kEncodeMul * v);
enc = fract( enc );
enc.x -= (enc.y * kEncodeBit);
return enc;
}
vec4 EncodeDepthNormal( in float depth, in vec3 normal ) {
vec4 enc;
enc.xy = EncodeViewNormalStereo( normal);
enc.zw = EncodeFloatRG( depth);
return enc;
}
vec4 frag( in v2f i ) {
vec4 texcol;
texcol = texture2D( _MainTex, i.uv);
xll_clip( (texcol.w - _Cutoff) );
return EncodeDepthNormal( i.nz.w , i.nz.xyz );
}
void main() {
vec4 xl_retval;
v2f xlt_i;
xlt_i.pos = vec4(0.0);
xlt_i.uv = vec2( gl_TexCoord[0]);
xlt_i.nz = vec4( gl_TexCoord[1]);
xl_retval = frag( xlt_i);
gl_FragData[0] = vec4( xl_retval);
}