diff --git a/Effects/reflect.eff b/Effects/reflect.eff index 25349d905..cf24f9f45 100644 --- a/Effects/reflect.eff +++ b/Effects/reflect.eff @@ -9,13 +9,16 @@ varying the material shininess value over or between objects the amount of refection can be controlled. The overall amount of reflection may be adjusted by the use of -1.0 (fully transparent)- 1.0 (fully opaque). -The overall values of the coloured fringing or fresnel effect may be adjusted -by the use of and . +The overall values of the noisiness, coloured fringing or fresnel effect may be adjusted +by the use of , and . If your result is too dark/too light the overall ambient light value can be adjusted by the use of . This correction also takes out some of the blueness added as default to compensate for the lack of reflection. +To use a reflection map set to 1,and the path to the map texture in + + USE: To use the default reflection effect (controlled by material shininess values) use @@ -49,7 +52,7 @@ EXAMPLES: You can find examples of both usages in the Hunter and Lightning model cubemap - + @@ -76,12 +79,21 @@ EXAMPLES: You can find examples of both usages in the Hunter and Lightning model repeat normalized + + Aircraft/737-300/Models/Effects/733LH.ReflectionMap3.png + linear-mipmap-linear + repeat + repeat + normalized + transparent smooth - 0.075 - 0.075 + 0.01 + 0.1 + 0.25 0.0 - 0.1 + 0.05 + 0 @@ -224,6 +236,31 @@ EXAMPLES: You can find examples of both usages in the Hunter and Lightning model + + 8 + + texture[8]/image + + + texture[8]/filter + + + texture[8]/wrap-s + + + texture[8]/wrap-t + + + texture[0]/internal-format + + + + + 9 + noise + + + Shaders/reflect.vert Shaders/reflect.frag @@ -265,19 +302,43 @@ EXAMPLES: You can find examples of both usages in the Hunter and Lightning model 7 + + Map + sampler-2d + 8 + + + + Noise + sampler-3d + 9 + rainbowiness float - rainbowiness + + rainbowiness + fresneliness float - fresneliness + + fresneliness + + + + + + noisiness + float + + noisiness + + + reflect_map + float + + reflect_map + + noisiness + diff --git a/Shaders/reflect.frag b/Shaders/reflect.frag index 37900d415..40837e467 100644 --- a/Shaders/reflect.frag +++ b/Shaders/reflect.frag @@ -4,6 +4,7 @@ #version 120 +varying vec4 rawpos; varying vec4 ecPosition; varying vec3 VNormal; varying vec3 Normal; @@ -19,12 +20,15 @@ uniform samplerCube Environment; uniform sampler2D Rainbow; uniform sampler2D BaseTex; uniform sampler2D Fresnel; +uniform sampler2D Map; +uniform sampler3D Noise; uniform float refl_correction; uniform float rainbowiness; uniform float fresneliness; +uniform float noisiness; uniform float ambient_correction; - +uniform float reflect_map; void main (void) { @@ -75,21 +79,37 @@ void main (void) // map the refection of the environment vec4 reflection = textureCube(Environment, reflVec); - // set the reflectivity proportional to shininess with user - // input ambient + // set the user shininess offse float transparency_offset = clamp(refl_correction, -1.0, 1.0); - float reflFactor = (gl_FrontMaterial.shininess / 128) + transparency_offset; + float reflFactor = 0.0; + + if(reflect_map > 0){ + // map the shininess of the object with user input + vec4 map = texture2D(Map, gl_TexCoord[0].st); + //float pam = (map.a * -2) + 1; //reverse map + reflFactor = map.a + transparency_offset; + } else { + // set the reflectivity proportional to shininess with user + // input + reflFactor = (gl_FrontMaterial.shininess / 128) + transparency_offset; + } + reflFactor = clamp(reflFactor, 0.0, 1.0); - // set adjust ambient ambient + // set adjust ambient float ambient_offset = clamp(ambient_correction, -1.0, 1.0); - vec4 ambient_Correction = mix(gl_LightSource[0].ambient, vec4(1.0, 1.0, 0.9, 1.0), 0.5) + vec4 ambient_Correction = mix(gl_LightSource[0].ambient, vec4(1.0, 1.0, 0.6, 1.0), 0.5) * ambient_offset; + // map noise vectore + vec4 noisevec = texture3D(Noise, rawpos.xyz); + // add fringing fresnel and rainbow effects and modulate by reflection vec4 reflcolor = mix(reflection, rainbow, rainbowiness * v); vec4 reflfrescolor = mix(reflcolor, fresnel, fresneliness * v); - vec4 raincolor = vec4(reflfrescolor.rgb, 1.0) * reflFactor; + vec4 noisecolor = mix(reflfrescolor, noisevec, noisiness); + vec4 raincolor = vec4(noisecolor.rgb, 1.0) * reflFactor; + vec4 mixedcolor = mix(texel, raincolor, reflFactor); // the final reflection diff --git a/Shaders/reflect.vert b/Shaders/reflect.vert index 6c3e8fb37..ed76cee0f 100644 --- a/Shaders/reflect.vert +++ b/Shaders/reflect.vert @@ -1,7 +1,8 @@ // -*- mode: C; -*- // Licence: GPL v2 -// Author: Vivian Meazza. +// Author: Vivian Meazza. +varying vec4 rawpos; varying vec4 ecPosition; varying vec3 VNormal; varying vec3 Normal; @@ -19,6 +20,7 @@ uniform mat4 osg_ViewMatrixInverse; void main(void) { + rawpos = gl_Vertex; ecPosition = gl_ModelViewMatrix * gl_Vertex; vec3 ecPosition3 = vec3(gl_ModelViewMatrix * gl_Vertex) / ecPosition.w;