Add mapping and noise
This commit is contained in:
parent
b33e332709
commit
1b49358d0d
3 changed files with 109 additions and 16 deletions
|
@ -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 <refl_correction> -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 <rainbowiness> and <fresneliness>.
|
||||
The overall values of the noisiness, coloured fringing or fresnel effect may be adjusted
|
||||
by the use of <noisiness>, <rainbowiness> and <fresneliness>.
|
||||
|
||||
If your result is too dark/too light the overall ambient light value can be adjusted
|
||||
by the use of <ambient_correction>. 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 <reflect_map> to 1,and the path to the map texture in
|
||||
<texture n="8">
|
||||
|
||||
USE: To use the default reflection effect (controlled by material shininess values) use
|
||||
|
||||
<effect>
|
||||
|
@ -49,7 +52,7 @@ EXAMPLES: You can find examples of both usages in the Hunter and Lightning model
|
|||
<texture n="5">
|
||||
<type>cubemap</type>
|
||||
<!-- use this form for a cube cross -->
|
||||
<!--<image>Aircraft/Generic/Effects/CubeCrosses/blue_sky.jpg</image>-->
|
||||
<!--<image>Aircraft/Generic/Effects/CubeCrosses/blue_sky_big.jpg</image>-->
|
||||
|
||||
<!-- use this form for a 6 image cube map -->
|
||||
<images>
|
||||
|
@ -76,12 +79,21 @@ EXAMPLES: You can find examples of both usages in the Hunter and Lightning model
|
|||
<wrap-t>repeat</wrap-t>
|
||||
<internal-format>normalized</internal-format>
|
||||
</texture>
|
||||
<texture n="8">
|
||||
<image>Aircraft/737-300/Models/Effects/733LH.ReflectionMap3.png</image>
|
||||
<filter>linear-mipmap-linear</filter>
|
||||
<wrap-s>repeat</wrap-s>
|
||||
<wrap-t>repeat</wrap-t>
|
||||
<internal-format>normalized</internal-format>
|
||||
</texture>
|
||||
<rendering-hint>transparent</rendering-hint>
|
||||
<shade-model>smooth</shade-model>
|
||||
<rainbowiness>0.075</rainbowiness>
|
||||
<fresneliness>0.075</fresneliness>
|
||||
<rainbowiness type="float">0.01</rainbowiness>
|
||||
<fresneliness>0.1</fresneliness>
|
||||
<noisiness>0.25</noisiness>
|
||||
<refl_correction>0.0</refl_correction>
|
||||
<ambient_correction>0.1</ambient_correction>
|
||||
<ambient_correction>0.05</ambient_correction>
|
||||
<reflect_map>0</reflect_map>
|
||||
</parameters>
|
||||
|
||||
<technique n="9">
|
||||
|
@ -224,6 +236,31 @@ EXAMPLES: You can find examples of both usages in the Hunter and Lightning model
|
|||
</wrap-t>
|
||||
</texture-unit>
|
||||
|
||||
<texture-unit>
|
||||
<unit>8</unit>
|
||||
<image>
|
||||
<use>texture[8]/image</use>
|
||||
</image>
|
||||
<filter>
|
||||
<use>texture[8]/filter</use>
|
||||
</filter>
|
||||
<wrap-s>
|
||||
<use>texture[8]/wrap-s</use>
|
||||
</wrap-s>
|
||||
<wrap-t>
|
||||
<use>texture[8]/wrap-t</use>
|
||||
</wrap-t>
|
||||
<internal-format>
|
||||
<use>texture[0]/internal-format</use>
|
||||
</internal-format>
|
||||
</texture-unit>
|
||||
|
||||
<texture-unit>
|
||||
<unit>9</unit>
|
||||
<type>noise</type>
|
||||
</texture-unit>
|
||||
|
||||
|
||||
<program>
|
||||
<vertex-shader>Shaders/reflect.vert</vertex-shader>
|
||||
<fragment-shader>Shaders/reflect.frag</fragment-shader>
|
||||
|
@ -265,19 +302,43 @@ EXAMPLES: You can find examples of both usages in the Hunter and Lightning model
|
|||
<value type="int">7</value>
|
||||
</uniform>
|
||||
|
||||
<uniform>
|
||||
<name>Map</name>
|
||||
<type>sampler-2d</type>
|
||||
<value type="int">8</value>
|
||||
</uniform>
|
||||
|
||||
<uniform>
|
||||
<name>Noise</name>
|
||||
<type>sampler-3d</type>
|
||||
<value type="int">9</value>
|
||||
</uniform>
|
||||
|
||||
<!-- set the amount of fringing colour 0.0 - 1.0 -->
|
||||
<uniform>
|
||||
<name>rainbowiness</name>
|
||||
<type>float</type>
|
||||
<value><use>rainbowiness</use></value>
|
||||
<value>
|
||||
<use>rainbowiness</use>
|
||||
</value>
|
||||
</uniform>
|
||||
|
||||
<!-- set the amount of fresnel effect colour 0.0 - 1.0 -->
|
||||
<uniform>
|
||||
<name>fresneliness</name>
|
||||
<type>float</type>
|
||||
<value><use>fresneliness</use></value>
|
||||
<value>
|
||||
<use>fresneliness</use>
|
||||
</value>
|
||||
</uniform>
|
||||
|
||||
<!-- set the amount of noisiness 0.0 - 1.0 -->
|
||||
<uniform>
|
||||
<name>noisiness</name>
|
||||
<type>float</type>
|
||||
<value>
|
||||
<use>noisiness</use>
|
||||
</value>
|
||||
</uniform>
|
||||
|
||||
<!-- The reflection is set proportional to the shininess of the material.
|
||||
|
@ -299,6 +360,16 @@ EXAMPLES: You can find examples of both usages in the Hunter and Lightning model
|
|||
<use>ambient_correction</use>
|
||||
</value>
|
||||
</uniform>
|
||||
|
||||
<!-- use a reflection map-->
|
||||
<uniform>
|
||||
<name>reflect_map</name>
|
||||
<type>float</type>
|
||||
<value>
|
||||
<use>reflect_map</use>
|
||||
</value>
|
||||
</uniform>noisiness
|
||||
|
||||
</pass>
|
||||
</technique>
|
||||
</PropertyList>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue