diff options
author | Valerio Virgillito | 2012-07-09 14:35:44 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-07-09 14:35:44 -0700 |
commit | 84b3327bd92faafab7954b5eb64c7abe24a3fe13 (patch) | |
tree | 3f56cbed2f08c5a81ea79eaf0bcb9bd031d8a627 /assets/shaders/test_fshader_full.glsl | |
parent | c0a42c56f768a873ba637f5b86d5f6a84d4a3312 (diff) | |
parent | 40c6eb2c06b34f65a74d59ef9687251952858bab (diff) | |
download | ninja-84b3327bd92faafab7954b5eb64c7abe24a3fe13.tar.gz |
Merge branch 'normalize' of https://github.com/kriskowal/ninja-internal
Conflicts:
js/components/gradientpicker.reel/gradientpicker.js
js/components/tools-properties/text-properties.reel/text-properties.js
js/document/views/base.js
js/document/views/design.js
js/helper-classes/3D/StageLine.js
js/helper-classes/3D/draw-utils.js
js/lib/drawing/world.js
js/lib/geom/circle.js
js/lib/geom/line.js
js/lib/geom/rectangle.js
js/lib/geom/shape-primitive.js
js/lib/rdge/materials/bump-metal-material.js
js/lib/rdge/materials/flag-material.js
js/lib/rdge/materials/fly-material.js
js/lib/rdge/materials/julia-material.js
js/lib/rdge/materials/keleidoscope-material.js
js/lib/rdge/materials/mandel-material.js
js/lib/rdge/materials/material.js
js/lib/rdge/materials/plasma-material.js
js/lib/rdge/materials/pulse-material.js
js/lib/rdge/materials/radial-gradient-material.js
js/lib/rdge/materials/taper-material.js
js/lib/rdge/materials/twist-vert-material.js
js/lib/rdge/materials/water-material.js
js/panels/Materials/materials-library-panel.reel/materials-library-panel.html
js/panels/Materials/materials-library-panel.reel/materials-library-panel.js
js/panels/Materials/materials-popup.reel/materials-popup.html
js/panels/Materials/materials-popup.reel/materials-popup.js
js/tools/LineTool.js
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'assets/shaders/test_fshader_full.glsl')
-rwxr-xr-x | assets/shaders/test_fshader_full.glsl | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/assets/shaders/test_fshader_full.glsl b/assets/shaders/test_fshader_full.glsl index 345a93f2..b2fc60e9 100755 --- a/assets/shaders/test_fshader_full.glsl +++ b/assets/shaders/test_fshader_full.glsl | |||
@@ -41,7 +41,7 @@ uniform vec4 u_lightAmb; | |||
41 | // diffuse map | 41 | // diffuse map |
42 | uniform sampler2D colMap; | 42 | uniform sampler2D colMap; |
43 | 43 | ||
44 | // environment map | 44 | // environment map |
45 | uniform sampler2D envMap; | 45 | uniform sampler2D envMap; |
46 | 46 | ||
47 | // normal map | 47 | // normal map |
@@ -68,39 +68,39 @@ void main() | |||
68 | vec3 normal = normalize(vNormal.xyz); | 68 | vec3 normal = normalize(vNormal.xyz); |
69 | vec3 mapNormal = texture2D(normalMap, vec2(vNormal.w, vECPos.w)).xyz * 2.0 - 1.0; | 69 | vec3 mapNormal = texture2D(normalMap, vec2(vNormal.w, vECPos.w)).xyz * 2.0 - 1.0; |
70 | mapNormal = normalize(mapNormal.x*vec3(normal.z, 0.0, -normal.x) + vec3(0.0, mapNormal.y, 0.0) + mapNormal.z*normal); | 70 | mapNormal = normalize(mapNormal.x*vec3(normal.z, 0.0, -normal.x) + vec3(0.0, mapNormal.y, 0.0) + mapNormal.z*normal); |
71 | 71 | ||
72 | // create envmap coordinates | 72 | // create envmap coordinates |
73 | vec3 r = reflect( normalize(vec3(vECPos.xyz - vEyePos.xyz)), mapNormal); | 73 | vec3 r = reflect( normalize(vec3(vECPos.xyz - vEyePos.xyz)), mapNormal); |
74 | float m = 2.0 * sqrt( r.x*r.x + r.y*r.y + r.z*r.z ); | 74 | float m = 2.0 * sqrt( r.x*r.x + r.y*r.y + r.z*r.z ); |
75 | 75 | ||
76 | // calculate environment map texel | 76 | // calculate environment map texel |
77 | vec4 envMapTexel = vec4(texture2D(envMap, vec2(r.x/m + 0.5, r.y/m + 0.5)).rgb, 0.0); | 77 | vec4 envMapTexel = vec4(texture2D(envMap, vec2(r.x/m + 0.5, r.y/m + 0.5)).rgb, 0.0); |
78 | 78 | ||
79 | // lighting | 79 | // lighting |
80 | vec3 lightDirection = u_lightPos - vECPos.xyz; | 80 | vec3 lightDirection = u_lightPos - vECPos.xyz; |
81 | float lightDist = length(lightDirection); | 81 | float lightDist = length(lightDirection); |
82 | lightDirection /= lightDist; | 82 | lightDirection /= lightDist; |
83 | 83 | ||
84 | float attenuation = clamp(1.0 - lightDist * 0.01, 0.0, 1.0); | 84 | float attenuation = clamp(1.0 - lightDist * 0.01, 0.0, 1.0); |
85 | 85 | ||
86 | vec3 halfVec = normalize(lightDirection + vEyePos); | 86 | vec3 halfVec = normalize(lightDirection + vEyePos); |
87 | 87 | ||
88 | float diffuseIntensity = max(0.0, dot(mapNormal, lightDirection)); | 88 | float diffuseIntensity = max(0.0, dot(mapNormal, lightDirection)); |
89 | float specularModifier = max(0.0, dot(mapNormal, halfVec)); | 89 | float specularModifier = max(0.0, dot(mapNormal, halfVec)); |
90 | 90 | ||
91 | float pf; | 91 | float pf; |
92 | if(diffuseIntensity == 0.0) | 92 | if(diffuseIntensity == 0.0) |
93 | pf = 0.0; | 93 | pf = 0.0; |
94 | else | 94 | else |
95 | pf = pow(specularModifier, 76.0); | 95 | pf = pow(specularModifier, 76.0); |
96 | 96 | ||
97 | vec4 ambient = u_matAmbient * u_lightAmb; | 97 | vec4 ambient = u_matAmbient * u_lightAmb; |
98 | vec4 diffuse = u_matDiffuse * (colMapTexel + envMapTexel); | 98 | vec4 diffuse = u_matDiffuse * (colMapTexel + envMapTexel); |
99 | 99 | ||
100 | if (u_renderGlow <= 0.5) | 100 | if (u_renderGlow <= 0.5) |
101 | diffuse *= u_lightDiff * diffuseIntensity * attenuation; | 101 | diffuse *= u_lightDiff * diffuseIntensity * attenuation; |
102 | 102 | ||
103 | vec4 specular = 2.0 * pf * envMapTexel; | 103 | vec4 specular = 2.0 * pf * envMapTexel; |
104 | 104 | ||
105 | gl_FragColor = (colMapTexel*(ambient + diffuse)) + specular + vec4(0.0,0.0,0.0,1.0); | 105 | gl_FragColor = (colMapTexel*(ambient + diffuse)) + specular + vec4(0.0,0.0,0.0,1.0); |
106 | } | 106 | } |