varying vec4 ecPosition; //homogeneous eye coordinate vector. varying vec3 normal; //calculated vertex normal. varying vec3 eye; //eye vector. vec3 ecPosition3; uniform float spec_bias; uniform vec3 glowRGB; void PerformLighting(in int i, inout vec4 ambient, inout vec4 diffuse, inout vec4 specular) { float nDotVP; float nDotHV; float pf; float attenuation; float d; vec3 VP; vec3 halfVector; //compute distance between surface to light position VP = vec3 (gl_LightSource[i].position) - ecPosition3; //compute distance between surface and light position //normalize the vector from surface to light position VP = normalize(VP); halfVector = normalize(VP + eye); nDotVP = max(0.0, dot(normal,VP)); nDotHV = max(0.0, dot(normal,halfVector)); if(nDotVP == 0.0) pf = 0.0; else pf = pow(nDotHV, gl_FrontMaterial.shininess); gl_FragColor = gl_Color; if((spec_bias > -1.0) && nDotHV < (.5 + spec_bias)) gl_FragColor.a = 0.0; } void main() { vec4 amb; vec4 diff; vec4 spec; normal = normalize(normal); ecPosition3 = (vec3(ecPosition)); ecPosition3 /= ecPosition.w; PerformLighting(0,amb,diff,spec); } struct TexInfo { uniform sampler2D tex; //texture unit int application; //application(modulate,decal,interpolate,etc...) float transp; //overall texture tranparency level int method; //method(reflective,projected,etc...) int enabled; //is this texture unit enabled? }; //max texture units exposed to application is currently 4. There are some issues with iterating over an array inside a loop which is controlled //by a uniform variable. driver issues? not currently implemented? I have no idea at the moment. uniform TexInfo textureInfo[4]; uniform float glowR; uniform float glowG; uniform float glowB; const int MAX_LIGHTS = 8; //restricted to 8 lights for now vec3 ecPosition3; //nonhomogeneous eye coordinate vector. varying vec4 ecPosition; //homogeneous eye coordinate vector. varying vec3 normal; //calculated vertex normal. varying vec3 eye; //eye vector. void PointLight(in int i,in vec3 normal,inout vec4 ambient,inout vec4 diffuse,inout vec4 specular) { float nDotVP; float nDotHV; float pf; float attenuation; float d; vec3 VP; vec3 halfVector; //compute distance between surface to light position VP = vec3 (gl_LightSource[i].position) - ecPosition3; //compute distance between surface and light position //normalize the vector from surface to light position VP = normalize(VP); halfVector = normalize(VP + eye); nDotVP = max(0.0, dot(normal,VP)); nDotHV = max(0.0, dot(normal,halfVector)); if(nDotVP == 0.0) pf = 0.0; else pf = pow(nDotHV, gl_FrontMaterial.shininess); ambient += gl_LightSource[i].ambient; diffuse += gl_LightSource[i].diffuse * nDotVP; specular += gl_LightSource[i].specular * pf; } void PerformBasicLighting() { //Perform lighting calculations vec4 amb; vec4 diff; vec4 spec; //clear the light intensity accumulators amb = vec4(0.0); diff = vec4(0.0); spec= vec4(0.0); PointLight(0,normal, amb, diff, spec); /* vec4 color; color = gl_FrontMaterial.emission + gl_FrontMaterial.ambient * gl_LightModel.ambient+ amb * gl_FrontMaterial.ambient + diff * vec4(glowRGB,gl_FrontMaterial.diffuse.a) + spec * gl_FrontMaterial.specular; color.a = gl_FrontMaterial.diffuse.a; gl_FrontColor = vec4(glowRGB,gl_FrontMaterial.diffuse.a); */ } void main() { gl_Position = ftransform(); gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex; ecPosition = gl_ModelViewMatrix*gl_Vertex; ecPosition3 = (vec3 (ecPosition)) / ecPosition.w; eye = -normalize(ecPosition3); normal = normalize(gl_NormalMatrix * gl_Normal); gl_FrontColor = vec4(glowR,glowG,glowB,1.0); }uniform sampler2D sourceTex; uniform float offsetX; uniform float offsetY; uniform float glowR; uniform float glowG; uniform float glowB; void main() { float x2 = .0058; vec2 texCoord = vec2(gl_TexCoord[0].x,gl_TexCoord[0].y); vec4 sample1 = texture2D(sourceTex,vec2(texCoord.x,texCoord.y+x2)) / 2.0; vec4 sample2 = texture2D(sourceTex,vec2(texCoord.x+x2,texCoord.y)) / 2.0; vec4 sample3 = texture2D(sourceTex,vec2(texCoord.x-x2,texCoord.y)) / 2.0; vec4 sample4 = texture2D(sourceTex,vec2(texCoord.x,texCoord.y-x2)) / 2.0; vec4 avg1 = (sample1 + sample2) / 2.0; vec4 avg2 = (sample3 + sample4) / 2.0; gl_FragColor = avg1+avg2; } /*********************************************************************NVMH3**** POPE: This is a substantially modified version of the Metal Paint program in the nVidia 8.5 SDK. A lot of corners have been cut in order to make this run as fast as possible and still achieve a convincing effect (the metal paint part instruction count has been cut by about 50%). Also, standard OpenGL states are used where possible to allow user configuration from the application. ******************************************************************************/ uniform sampler3D noiseMap; uniform sampler2D texMap; uniform sampler2D texMap2; uniform vec3 specularColor; uniform float speckleScale; uniform float clearcoat_smoothness; uniform float clearcoat_shininess; uniform float fleck_locality; varying vec3 oPosition; varying vec3 ePosition; varying vec3 normal; varying vec2 uv; float saturate(float a) { return clamp(a, 0.0, 1.0); } void main() { //vec4 texLookup1 = texture2D(texMap,gl_TexCoord[0].xy); //vec4 texLookup2 = texture2D(texMap2,gl_TexCoord[1].xy); //gl_FragColor = texLookup2;//*texLookup2; //return; vec3 lightVector = vec3(gl_LightSource[0].position) - ePosition; vec3 ambientColor = vec3(gl_LightModel.ambient * gl_FrontMaterial.ambient); vec3 diffuse_material_color = vec3(gl_FrontMaterial.diffuse); vec3 L = normalize(lightVector); vec3 N = normalize(normal); float n_dot_l = clamp(dot(N, L),0.0,1.0); vec3 diffuse_color = n_dot_l * (diffuse_material_color) + (ambientColor); vec3 specular_material_color = specularColor; vec3 V = normalize(ePosition); vec3 R = reflect(V, N); float r_dot_l = saturate(dot(R, L)); vec3 specular_color = r_dot_l * specular_material_color; vec3 fleck_material_color = specularColor * clearcoat_smoothness; float fleck_shininess = 5.0; vec3 noise_coords = oPosition * speckleScale; vec3 fleck_normal0 = texture3D(noiseMap, noise_coords).rgb; vec3 fleck_normal1 = texture3D(noiseMap, noise_coords).rgb; vec3 fleck_normal2 = texture3D(noiseMap, noise_coords * 2.0).rgb; vec3 fleck_normal3 = texture3D(noiseMap, noise_coords * 3.0).rgb; float fleck_intensity = pow(saturate(abs(fleck_normal0.z)), fleck_shininess) + pow(saturate(abs(fleck_normal1.z)), fleck_shininess) + pow(saturate(abs(fleck_normal2.z)), fleck_shininess) + pow(saturate(abs(fleck_normal3.z)), fleck_shininess); fleck_intensity *= pow(r_dot_l,fleck_locality); vec3 fleck_color = fleck_intensity * fleck_material_color; R = reflect(V, N); r_dot_l = saturate(dot(R, L)); specular_color = vec3(pow(r_dot_l, clearcoat_shininess)) * vec3(gl_FrontMaterial.specular); vec3 sum_color = diffuse_color + fleck_color + specular_color; gl_FragColor = vec4(sum_color, gl_FrontMaterial.diffuse.a); } /*********************************************************************NVMH3**** Copyright NVIDIA Corporation 2002 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Comments: ******************************************************************************/ varying vec3 oPosition; varying vec3 ePosition; varying vec3 normal; varying vec2 uv; varying vec2 uv2; void main() { // output clip space position gl_Position = ftransform(); // output object space position oPosition = gl_Vertex.xyz; // output eye space position ePosition = vec3(gl_ModelViewMatrix * gl_Vertex); // output view space position normal = gl_NormalMatrix * gl_Normal; //uv = gl_MultiTexCoord0.xy; gl_TexCoord[0] = gl_MultiTexCoord0 * gl_TextureMatrix[0]; gl_TexCoord[1] = gl_MultiTexCoord0 * gl_TextureMatrix[1]; gl_TexCoord[2] = gl_MultiTexCoord0 * gl_TextureMatrix[2]; gl_TexCoord[3] = gl_MultiTexCoord0 * gl_TextureMatrix[3]; } varying vec3 oPosition; varying vec3 ePosition; varying vec3 normal; float saturate(float a) { return clamp(a, 0.0, 1.0); } void main() { vec3 lightVector = vec3(gl_LightSource[0].position) - ePosition; vec3 ambientColor = vec3(gl_LightModel.ambient * gl_FrontMaterial.ambient); vec3 diffuse_color = vec3(gl_FrontMaterial.diffuse); vec3 L = normalize(lightVector); vec3 N = normalize(normal); float n_dot_l = clamp(dot(N, L),0.0,1.0); if(n_dot_l > .95) gl_FragColor.rgb = diffuse_color; else if(n_dot_l > .75) gl_FragColor.rgb = diffuse_color*.75; else if(n_dot_l > .5) gl_FragColor.rgb = diffuse_color*.5; else gl_FragColor.rgb = diffuse_color*.33; gl_FragColor.rgb += ambientColor; gl_FragColor.a = gl_FrontMaterial.diffuse.a; } varying vec4 ePosition; //homogeneous eye coordinate vector. varying vec3 normal; //calculated vertex normal. void main() { gl_Position = ftransform(); gl_ClipVertex = gl_ModelViewMatrix*gl_Vertex; ePosition = gl_ModelViewMatrix*gl_Vertex; normal = gl_NormalMatrix * gl_Normal; }