diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2015-01-05 14:14:36 -0800 |
---|---|---|
committer | Kenneth Graunke <kenneth@whitecape.org> | 2015-01-05 16:04:18 -0800 |
commit | f4e5cbd191d1a644a29eef3da51d4d8a4630d12a (patch) | |
tree | 85a71101e1434e9cab19b21ad8289238f1d27a52 /shaders/unity/56-PBS_Deferred_MRT.shader_test | |
parent | c6a13041fa143cbc6749bb3f10d23c3afe66edec (diff) |
Import Unity 5.0 built-in shaders.
The Unity 3D engine ships with a number of built-in shaders, which will
likely be used by many games. These were originally written in HLSL,
but translated via a bunch of software.
Thanks to Aras Pranckevičius <aras@unity3d.com> for giving us a copy of
these shaders under the MIT license.
Diffstat (limited to 'shaders/unity/56-PBS_Deferred_MRT.shader_test')
-rw-r--r-- | shaders/unity/56-PBS_Deferred_MRT.shader_test | 341 |
1 files changed, 341 insertions, 0 deletions
diff --git a/shaders/unity/56-PBS_Deferred_MRT.shader_test b/shaders/unity/56-PBS_Deferred_MRT.shader_test new file mode 100644 index 0000000..48af19f --- /dev/null +++ b/shaders/unity/56-PBS_Deferred_MRT.shader_test @@ -0,0 +1,341 @@ +# Built-in shader from Unity 5.0.0b19: +# Standard; deferred shading g-buffer (MRT) output pass +# internal variant: DIRLIGHTMAP_OFF DYNAMICLIGHTMAP_OFF LIGHTMAP_OFF _METALLICGLOSSMAP _NORMALMAP +# This shader GLSL dump is put under MIT license +[require] +GLSL >= 1.10 + +[vertex shader] +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 unity_SHBr; +uniform vec4 unity_SHBg; +uniform vec4 unity_SHBb; +uniform vec4 unity_SHC; + +uniform mat4 _Object2World; +uniform mat4 _World2Object; +uniform vec4 _MainTex_ST; +uniform vec4 _DetailAlbedoMap_ST; +uniform float _UVSec; +attribute vec4 TANGENT; +varying vec4 xlv_TEXCOORD0; +varying vec3 xlv_TEXCOORD1; +varying vec4 xlv_TEXCOORD2; +varying vec4 xlv_TEXCOORD2_1; +varying vec4 xlv_TEXCOORD2_2; +varying vec4 xlv_TEXCOORD5; +varying vec3 xlv_TEXCOORD6; +void main () +{ + vec2 tmpvar_1; + tmpvar_1 = gl_MultiTexCoord0.xy; + vec2 tmpvar_2; + tmpvar_2 = gl_MultiTexCoord1.xy; + vec4 tmpvar_3; + vec4 tmpvar_4; + vec4 tmpvar_5; + vec4 tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = (_Object2World * gl_Vertex); + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7.xyz; + vec4 tmpvar_9; + tmpvar_9 = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 texcoord_10; + texcoord_10.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + vec2 tmpvar_11; + if ((_UVSec == 0.0)) { + tmpvar_11 = tmpvar_1; + } else { + tmpvar_11 = tmpvar_2; + }; + texcoord_10.zw = ((tmpvar_11 * _DetailAlbedoMap_ST.xy) + _DetailAlbedoMap_ST.zw); + vec4 v_12; + v_12.x = _World2Object[0].x; + v_12.y = _World2Object[1].x; + v_12.z = _World2Object[2].x; + v_12.w = _World2Object[3].x; + vec4 v_13; + v_13.x = _World2Object[0].y; + v_13.y = _World2Object[1].y; + v_13.z = _World2Object[2].y; + v_13.w = _World2Object[3].y; + vec4 v_14; + v_14.x = _World2Object[0].z; + v_14.y = _World2Object[1].z; + v_14.z = _World2Object[2].z; + v_14.w = _World2Object[3].z; + vec3 tmpvar_15; + tmpvar_15 = normalize((( + (v_12.xyz * gl_Normal.x) + + + (v_13.xyz * gl_Normal.y) + ) + (v_14.xyz * gl_Normal.z))); + mat3 tmpvar_16; + tmpvar_16[0] = _Object2World[0].xyz; + tmpvar_16[1] = _Object2World[1].xyz; + tmpvar_16[2] = _Object2World[2].xyz; + vec4 tmpvar_17; + tmpvar_17.xyz = normalize((tmpvar_16 * TANGENT.xyz)); + tmpvar_17.w = TANGENT.w; + vec3 tmpvar_18; + vec3 tmpvar_19; + tmpvar_18 = tmpvar_17.xyz; + tmpvar_19 = (((tmpvar_15.yzx * tmpvar_17.zxy) - (tmpvar_15.zxy * tmpvar_17.yzx)) * TANGENT.www); + vec3 tmpvar_20; + vec3 tmpvar_21; + vec3 tmpvar_22; + tmpvar_20.x = tmpvar_18.x; + tmpvar_20.y = tmpvar_19.x; + tmpvar_20.z = tmpvar_15.x; + tmpvar_21.x = tmpvar_18.y; + tmpvar_21.y = tmpvar_19.y; + tmpvar_21.z = tmpvar_15.y; + tmpvar_22.x = tmpvar_18.z; + tmpvar_22.y = tmpvar_19.z; + tmpvar_22.z = tmpvar_15.z; + vec3 v_23; + v_23.x = tmpvar_20.x; + v_23.y = tmpvar_21.x; + v_23.z = tmpvar_22.x; + tmpvar_3.xyz = v_23; + vec3 v_24; + v_24.x = tmpvar_20.y; + v_24.y = tmpvar_21.y; + v_24.z = tmpvar_22.y; + tmpvar_4.xyz = v_24; + vec3 v_25; + v_25.x = tmpvar_20.z; + v_25.y = tmpvar_21.z; + v_25.z = tmpvar_22.z; + tmpvar_5.xyz = v_25; + vec3 x2_26; + vec4 tmpvar_27; + tmpvar_27 = (tmpvar_15.xyzz * tmpvar_15.yzzx); + x2_26.x = dot (unity_SHBr, tmpvar_27); + x2_26.y = dot (unity_SHBg, tmpvar_27); + x2_26.z = dot (unity_SHBb, tmpvar_27); + tmpvar_6.xyz = (x2_26 + (unity_SHC.xyz * ( + (tmpvar_15.x * tmpvar_15.x) + - + (tmpvar_15.y * tmpvar_15.y) + ))); + gl_Position = tmpvar_9; + xlv_TEXCOORD0 = texcoord_10; + xlv_TEXCOORD1 = (tmpvar_7.xyz - _WorldSpaceCameraPos); + xlv_TEXCOORD2 = tmpvar_3; + xlv_TEXCOORD2_1 = tmpvar_4; + xlv_TEXCOORD2_2 = tmpvar_5; + xlv_TEXCOORD5 = tmpvar_6; + xlv_TEXCOORD6 = tmpvar_8; +} + +[fragment shader] +#extension GL_ARB_shader_texture_lod : enable +uniform vec4 unity_SHAr; +uniform vec4 unity_SHAg; +uniform vec4 unity_SHAb; +uniform vec4 unity_ColorSpaceDielectricSpec; +uniform samplerCube unity_SpecCube; +uniform samplerCube unity_SpecCube1; +uniform vec4 _Color; +uniform sampler2D _MainTex; +uniform sampler2D _BumpMap; +uniform float _BumpScale; +uniform sampler2D _MetallicGlossMap; +uniform sampler2D _OcclusionMap; +uniform float _OcclusionStrength; +uniform vec4 unity_SpecCube_BoxMax; +uniform vec4 unity_SpecCube_BoxMin; +uniform vec4 unity_SpecCube_ProbePosition; +uniform vec4 unity_SpecCube_HDR; +uniform vec4 unity_SpecCube_BoxMax1; +uniform vec4 unity_SpecCube_BoxMin1; +uniform vec4 unity_SpecCube_ProbePosition1; +uniform vec4 unity_SpecCube_HDR1; +varying vec4 xlv_TEXCOORD0; +varying vec3 xlv_TEXCOORD1; +varying vec4 xlv_TEXCOORD2; +varying vec4 xlv_TEXCOORD2_1; +varying vec4 xlv_TEXCOORD2_2; +varying vec4 xlv_TEXCOORD5; +varying vec3 xlv_TEXCOORD6; +void main () +{ + vec3 tmpvar_1; + vec3 tmpvar_2; + vec3 tmpvar_3; + tmpvar_1 = xlv_TEXCOORD2.xyz; + tmpvar_2 = xlv_TEXCOORD2_1.xyz; + tmpvar_3 = normalize(xlv_TEXCOORD2_2.xyz); + mat3 tmpvar_4; + tmpvar_4[0].x = tmpvar_1.x; + tmpvar_4[0].y = tmpvar_2.x; + tmpvar_4[0].z = tmpvar_3.x; + tmpvar_4[1].x = tmpvar_1.y; + tmpvar_4[1].y = tmpvar_2.y; + tmpvar_4[1].z = tmpvar_3.y; + tmpvar_4[2].x = tmpvar_1.z; + tmpvar_4[2].y = tmpvar_2.z; + tmpvar_4[2].z = tmpvar_3.z; + vec3 normal_5; + normal_5.xy = ((texture2D (_BumpMap, xlv_TEXCOORD0.xy).wy * 2.0) - 1.0); + normal_5.xy = (normal_5.xy * _BumpScale); + normal_5.z = sqrt((1.0 - clamp ( + dot (normal_5.xy, normal_5.xy) + , 0.0, 1.0))); + vec3 tmpvar_6; + tmpvar_6 = normalize((normal_5 * tmpvar_4)); + vec3 tmpvar_7; + tmpvar_7 = normalize(xlv_TEXCOORD1); + vec2 tmpvar_8; + tmpvar_8 = texture2D (_MetallicGlossMap, xlv_TEXCOORD0.xy).xw; + float tmpvar_9; + tmpvar_9 = tmpvar_8.y; + vec3 tmpvar_10; + tmpvar_10 = (_Color.xyz * texture2D (_MainTex, xlv_TEXCOORD0.xy).xyz); + vec3 tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = mix (unity_ColorSpaceDielectricSpec.xyz, tmpvar_10, tmpvar_8.xxx); + float tmpvar_13; + tmpvar_13 = (unity_ColorSpaceDielectricSpec.w - (tmpvar_8.x * unity_ColorSpaceDielectricSpec.w)); + tmpvar_11 = (tmpvar_10 * tmpvar_13); + float tmpvar_14; + tmpvar_14 = ((1.0 - _OcclusionStrength) + (texture2D (_OcclusionMap, xlv_TEXCOORD0.xy).y * _OcclusionStrength)); + vec3 tmpvar_15; + vec3 tmpvar_16; + tmpvar_16 = vec3(0.0, 0.0, 0.0); + vec4 tmpvar_17; + tmpvar_17.w = 1.0; + tmpvar_17.xyz = tmpvar_6; + vec3 x1_18; + x1_18.x = dot (unity_SHAr, tmpvar_17); + x1_18.y = dot (unity_SHAg, tmpvar_17); + x1_18.z = dot (unity_SHAb, tmpvar_17); + tmpvar_15 = (xlv_TEXCOORD5.xyz + x1_18); + tmpvar_15 = (tmpvar_15 * tmpvar_14); + vec3 tmpvar_19; + tmpvar_19 = (tmpvar_7 - (2.0 * ( + dot (tmpvar_6, tmpvar_7) + * tmpvar_6))); + vec3 worldNormal_20; + worldNormal_20 = tmpvar_19; + if ((unity_SpecCube_ProbePosition.w > 0.0)) { + vec3 tmpvar_21; + tmpvar_21 = normalize(tmpvar_19); + vec3 tmpvar_22; + tmpvar_22 = ((unity_SpecCube_BoxMax.xyz - xlv_TEXCOORD6) / tmpvar_21); + vec3 tmpvar_23; + tmpvar_23 = ((unity_SpecCube_BoxMin.xyz - xlv_TEXCOORD6) / tmpvar_21); + bvec3 tmpvar_24; + tmpvar_24 = greaterThan (tmpvar_21, vec3(0.0, 0.0, 0.0)); + float tmpvar_25; + if (tmpvar_24.x) { + tmpvar_25 = tmpvar_22.x; + } else { + tmpvar_25 = tmpvar_23.x; + }; + float tmpvar_26; + if (tmpvar_24.y) { + tmpvar_26 = tmpvar_22.y; + } else { + tmpvar_26 = tmpvar_23.y; + }; + float tmpvar_27; + if (tmpvar_24.z) { + tmpvar_27 = tmpvar_22.z; + } else { + tmpvar_27 = tmpvar_23.z; + }; + vec3 tmpvar_28; + tmpvar_28 = ((unity_SpecCube_BoxMax.xyz + unity_SpecCube_BoxMin.xyz) * 0.5); + worldNormal_20 = ((( + (tmpvar_28 - unity_SpecCube_ProbePosition.xyz) + + xlv_TEXCOORD6) + (tmpvar_21 * + min (min (tmpvar_25, tmpvar_26), tmpvar_27) + )) - tmpvar_28); + }; + vec4 tmpvar_29; + tmpvar_29.xyz = worldNormal_20; + tmpvar_29.w = (pow ((1.0 - tmpvar_8.y), 0.75) * 7.0); + vec4 tmpvar_30; + tmpvar_30 = textureCubeLod (unity_SpecCube, worldNormal_20, tmpvar_29.w); + vec3 tmpvar_31; + tmpvar_31 = ((unity_SpecCube_HDR.x * pow (tmpvar_30.w, unity_SpecCube_HDR.y)) * tmpvar_30.xyz); + if ((unity_SpecCube_BoxMin.w < 0.99999)) { + vec3 worldNormal_32; + worldNormal_32 = tmpvar_19; + if ((unity_SpecCube_ProbePosition1.w > 0.0)) { + vec3 tmpvar_33; + tmpvar_33 = normalize(tmpvar_19); + vec3 tmpvar_34; + tmpvar_34 = ((unity_SpecCube_BoxMax1.xyz - xlv_TEXCOORD6) / tmpvar_33); + vec3 tmpvar_35; + tmpvar_35 = ((unity_SpecCube_BoxMin1.xyz - xlv_TEXCOORD6) / tmpvar_33); + bvec3 tmpvar_36; + tmpvar_36 = greaterThan (tmpvar_33, vec3(0.0, 0.0, 0.0)); + float tmpvar_37; + if (tmpvar_36.x) { + tmpvar_37 = tmpvar_34.x; + } else { + tmpvar_37 = tmpvar_35.x; + }; + float tmpvar_38; + if (tmpvar_36.y) { + tmpvar_38 = tmpvar_34.y; + } else { + tmpvar_38 = tmpvar_35.y; + }; + float tmpvar_39; + if (tmpvar_36.z) { + tmpvar_39 = tmpvar_34.z; + } else { + tmpvar_39 = tmpvar_35.z; + }; + vec3 tmpvar_40; + tmpvar_40 = ((unity_SpecCube_BoxMax1.xyz + unity_SpecCube_BoxMin1.xyz) * 0.5); + worldNormal_32 = ((( + (tmpvar_40 - unity_SpecCube_ProbePosition1.xyz) + + xlv_TEXCOORD6) + (tmpvar_33 * + min (min (tmpvar_37, tmpvar_38), tmpvar_39) + )) - tmpvar_40); + }; + vec4 tmpvar_41; + tmpvar_41.xyz = worldNormal_32; + tmpvar_41.w = (pow ((1.0 - tmpvar_8.y), 0.75) * 7.0); + vec4 tmpvar_42; + tmpvar_42 = textureCubeLod (unity_SpecCube1, worldNormal_32, tmpvar_41.w); + tmpvar_16 = mix (((unity_SpecCube_HDR1.x * + pow (tmpvar_42.w, unity_SpecCube_HDR1.y) + ) * tmpvar_42.xyz), tmpvar_31, unity_SpecCube_BoxMin.www); + } else { + tmpvar_16 = tmpvar_31; + }; + tmpvar_16 = (tmpvar_16 * tmpvar_14); + vec4 tmpvar_43; + tmpvar_43.w = 1.0; + tmpvar_43.xyz = ((tmpvar_11 * tmpvar_15) + (tmpvar_16 * mix (tmpvar_12, vec3( + clamp ((tmpvar_8.y + (1.0 - tmpvar_13)), 0.0, 1.0) + ), vec3( + pow (abs((1.0 - max (0.0, + dot (tmpvar_6, -(tmpvar_7)) + ))), 5.0) + )))); + vec4 tmpvar_44; + tmpvar_44.xyz = tmpvar_11; + tmpvar_44.w = tmpvar_14; + vec4 tmpvar_45; + tmpvar_45.xyz = tmpvar_12; + tmpvar_45.w = tmpvar_9; + vec4 tmpvar_46; + tmpvar_46.w = 1.0; + tmpvar_46.xyz = ((tmpvar_6 * 0.5) + 0.5); + vec4 tmpvar_47; + tmpvar_47.w = 1.0; + tmpvar_47.xyz = exp2(-(tmpvar_43.xyz)); + gl_FragData[0] = tmpvar_44; + gl_FragData[1] = tmpvar_45; + gl_FragData[2] = tmpvar_46; + gl_FragData[3] = tmpvar_47; +} + |