Merge branch 'master' of gitorious.org:fg/fgdata
This commit is contained in:
commit
bc54f3c40a
13 changed files with 603 additions and 105 deletions
|
@ -362,7 +362,7 @@ var TO_DEG = 180/math.pi;
|
||||||
var walkers = {};
|
var walkers = {};
|
||||||
|
|
||||||
var closerXY = func (pos, p1, p2) {
|
var closerXY = func (pos, p1, p2) {
|
||||||
l1 = [p1[0] - pos[0], p1[1] - pos[1]];
|
var l1 = [p1[0] - pos[0], p1[1] - pos[1]];
|
||||||
l2 = [p2[0] - pos[0], p2[1] - pos[1]];
|
var l2 = [p2[0] - pos[0], p2[1] - pos[1]];
|
||||||
return (l1[0]*l1[0] + l1[1]*l1[1]) - (l2[0]*l2[0] + l2[1]*l2[1]);
|
return (l1[0]*l1[0] + l1[1]*l1[1]) - (l2[0]*l2[0] + l2[1]*l2[1]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,150 @@
|
||||||
<PropertyList>
|
<PropertyList>
|
||||||
<name>Effects/water</name>
|
<name>Effects/water</name>
|
||||||
<inherits-from>Effects/terrain-default</inherits-from>
|
<inherits-from>Effects/terrain-default</inherits-from>
|
||||||
|
<parameters>
|
||||||
|
<texture n="0">
|
||||||
|
<image>Textures/Water/water-reflection.png</image>
|
||||||
|
<filter>linear-mipmap-linear</filter>
|
||||||
|
<wrap-s>repeat</wrap-s>
|
||||||
|
<wrap-t>repeat</wrap-t>
|
||||||
|
<internal-format>normalized</internal-format>
|
||||||
|
</texture>
|
||||||
|
<texture n="1">
|
||||||
|
<image>Textures/Water/water-refraction.png</image>
|
||||||
|
<filter>linear-mipmap-linear</filter>
|
||||||
|
<wrap-s>repeat</wrap-s>
|
||||||
|
<wrap-t>repeat</wrap-t>
|
||||||
|
<internal-format>normalized</internal-format>
|
||||||
|
</texture>
|
||||||
|
<texture n="2">
|
||||||
|
<image>Textures/Water/water-normalmap.png</image>
|
||||||
|
<filter>linear-mipmap-linear</filter>
|
||||||
|
<wrap-s>repeat</wrap-s>
|
||||||
|
<wrap-t>repeat</wrap-t>
|
||||||
|
<internal-format>normalized</internal-format>
|
||||||
|
</texture>
|
||||||
|
<texture n="3">
|
||||||
|
<image>Textures/Water/water-dudv.png</image>
|
||||||
|
<filter>linear-mipmap-linear</filter>
|
||||||
|
<wrap-s>repeat</wrap-s>
|
||||||
|
<wrap-t>repeat</wrap-t>
|
||||||
|
<internal-format>normalized</internal-format>
|
||||||
|
</texture>
|
||||||
|
<saturation>
|
||||||
|
<use>/rendering/scene/saturation</use>
|
||||||
|
</saturation>
|
||||||
|
</parameters>
|
||||||
|
<technique n="8">
|
||||||
|
<predicate>
|
||||||
|
<and>
|
||||||
|
<property>/sim/rendering/water-shader</property>
|
||||||
|
<property>/sim/rendering/shader-effects</property>
|
||||||
|
<less-equal>
|
||||||
|
<value type="float">2.0</value>
|
||||||
|
<float-property>/sim/rendering/quality-level</float-property>
|
||||||
|
</less-equal>
|
||||||
|
<or>
|
||||||
|
<less-equal>
|
||||||
|
<value type="float">2.0</value>
|
||||||
|
<glversion/>
|
||||||
|
</less-equal>
|
||||||
|
<and>
|
||||||
|
<extension-supported>GL_ARB_shader_objects</extension-supported>
|
||||||
|
<extension-supported>GL_ARB_shading_language_100</extension-supported>
|
||||||
|
<extension-supported>GL_ARB_vertex_shader</extension-supported>
|
||||||
|
<extension-supported>GL_ARB_fragment_shader</extension-supported>
|
||||||
|
</and>
|
||||||
|
</or>
|
||||||
|
</and>
|
||||||
|
</predicate>
|
||||||
|
<pass>
|
||||||
|
<lighting>true</lighting>
|
||||||
|
<material>
|
||||||
|
<ambient><use>material/ambient</use></ambient>
|
||||||
|
<diffuse><use>material/diffuse</use></diffuse>
|
||||||
|
<specular><use>material/specular</use></specular>
|
||||||
|
<color-mode>ambient-and-diffuse</color-mode>
|
||||||
|
</material>
|
||||||
|
<blend><use>transparent</use></blend>
|
||||||
|
<alpha-test><use>transparent</use></alpha-test>
|
||||||
|
<shade-model>smooth</shade-model>
|
||||||
|
<cull-face>back</cull-face>
|
||||||
|
<render-bin>
|
||||||
|
<bin-number><use>render-bin/bin-number</use></bin-number>
|
||||||
|
<bin-name><use>render-bin/bin-name</use></bin-name>
|
||||||
|
</render-bin>
|
||||||
|
<texture-unit>
|
||||||
|
<unit>0</unit>
|
||||||
|
<image><use>texture[0]/image</use></image>
|
||||||
|
<filter><use>texture[0]/filter</use></filter>
|
||||||
|
<wrap-s><use>texture[0]/wrap-s</use></wrap-s>
|
||||||
|
<wrap-t><use>texture[0]/wrap-t</use></wrap-t>
|
||||||
|
<internal-format>
|
||||||
|
<use>texture[0]/internal-format</use>
|
||||||
|
</internal-format>
|
||||||
|
</texture-unit>
|
||||||
|
<texture-unit>
|
||||||
|
<unit>1</unit>
|
||||||
|
<image><use>texture[1]/image</use></image>
|
||||||
|
<filter><use>texture[1]/filter</use></filter>
|
||||||
|
<wrap-s><use>texture[1]/wrap-s</use></wrap-s>
|
||||||
|
<wrap-t><use>texture[1]/wrap-t</use></wrap-t>
|
||||||
|
<internal-format>
|
||||||
|
<use>texture[1]/internal-format</use>
|
||||||
|
</internal-format>
|
||||||
|
</texture-unit>
|
||||||
|
<texture-unit>
|
||||||
|
<unit>2</unit>
|
||||||
|
<image><use>texture[2]/image</use></image>
|
||||||
|
<filter><use>texture[2]/filter</use></filter>
|
||||||
|
<wrap-s><use>texture[2]/wrap-s</use></wrap-s>
|
||||||
|
<wrap-t><use>texture[2]/wrap-t</use></wrap-t>
|
||||||
|
<internal-format>
|
||||||
|
<use>texture[2]/internal-format</use>
|
||||||
|
</internal-format>
|
||||||
|
</texture-unit>
|
||||||
|
<texture-unit>
|
||||||
|
<unit>3</unit>
|
||||||
|
<image><use>texture[3]/image</use></image>
|
||||||
|
<filter><use>texture[3]/filter</use></filter>
|
||||||
|
<wrap-s><use>texture[3]/wrap-s</use></wrap-s>
|
||||||
|
<wrap-t><use>texture[3]/wrap-t</use></wrap-t>
|
||||||
|
<internal-format>
|
||||||
|
<use>texture[3]/internal-format</use>
|
||||||
|
</internal-format>
|
||||||
|
</texture-unit>
|
||||||
|
<program>
|
||||||
|
<vertex-shader>Shaders/water.vert</vertex-shader>
|
||||||
|
<fragment-shader>Shaders/water.frag</fragment-shader>
|
||||||
|
</program>
|
||||||
|
<uniform>
|
||||||
|
<name>water_reflection</name>
|
||||||
|
<type>sampler-2d</type>
|
||||||
|
<value type="int">0</value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>water_refraction</name>
|
||||||
|
<type>sampler-2d</type>
|
||||||
|
<value type="int">1</value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>water_normalmap</name>
|
||||||
|
<type>sampler-2d</type>
|
||||||
|
<value type="int">2</value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>water_dudvmap</name>
|
||||||
|
<type>sampler-2d</type>
|
||||||
|
<value type="int">3</value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>saturation</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value>0.4</value>
|
||||||
|
<!--<value><use>saturation</use></value>-->
|
||||||
|
</uniform>
|
||||||
|
</pass>
|
||||||
|
</technique>
|
||||||
<technique n="9">
|
<technique n="9">
|
||||||
<predicate>
|
<predicate>
|
||||||
<and>
|
<and>
|
||||||
|
@ -42,8 +186,8 @@
|
||||||
<type>noise</type>
|
<type>noise</type>
|
||||||
</texture-unit>
|
</texture-unit>
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/water.vert</vertex-shader>
|
<vertex-shader>Shaders/water-orig.vert</vertex-shader>
|
||||||
<fragment-shader>Shaders/water.frag</fragment-shader>
|
<fragment-shader>Shaders/water-orig.frag</fragment-shader>
|
||||||
</program>
|
</program>
|
||||||
<uniform>
|
<uniform>
|
||||||
<name>texture</name>
|
<name>texture</name>
|
||||||
|
|
|
@ -45,24 +45,25 @@ BroadcastChannel.new = func (mpp_path, process,
|
||||||
accept_predicate = nil,
|
accept_predicate = nil,
|
||||||
on_disconnect = nil,
|
on_disconnect = nil,
|
||||||
enable_send=1) {
|
enable_send=1) {
|
||||||
obj = { parents : [BroadcastChannel],
|
var obj = { parents : [BroadcastChannel],
|
||||||
mpp_path : mpp_path,
|
mpp_path : mpp_path,
|
||||||
send_node : enable_send ? props.globals.getNode(mpp_path, 1)
|
send_node : enable_send ? props.globals.getNode(mpp_path, 1)
|
||||||
: nil,
|
: nil,
|
||||||
process_msg : process,
|
process_msg : process,
|
||||||
send_to_self : send_to_self,
|
send_to_self : send_to_self,
|
||||||
accept_predicate : (accept_predicate != nil) ? accept_predicate :
|
accept_predicate :
|
||||||
func (p) { return 1; },
|
(accept_predicate != nil) ? accept_predicate
|
||||||
on_disconnect : (on_disconnect != nil) ? on_disconnect :
|
: func (p) { return 1; },
|
||||||
func (p) { return; },
|
on_disconnect : (on_disconnect != nil) ? on_disconnect
|
||||||
# Internal state.
|
: func (p) { return; },
|
||||||
send_buf : [],
|
# Internal state.
|
||||||
peers : {},
|
send_buf : [],
|
||||||
loopid : 0,
|
peers : {},
|
||||||
PERIOD : 1.3,
|
loopid : 0,
|
||||||
last_time : 0.0, # For join handling.
|
PERIOD : 1.3,
|
||||||
last_send : 0.0, # For the send queue
|
last_time : 0.0, # For join handling.
|
||||||
SEND_TIME : 0.5 };
|
last_send : 0.0, # For the send queue
|
||||||
|
SEND_TIME : 0.5 };
|
||||||
if (enable_send and (obj.send_node == nil)) {
|
if (enable_send and (obj.send_node == nil)) {
|
||||||
printlog("warn",
|
printlog("warn",
|
||||||
"BroadcastChannel invalid send node.");
|
"BroadcastChannel invalid send node.");
|
||||||
|
|
|
@ -97,7 +97,7 @@ void main (void)
|
||||||
reflFactor = (gl_FrontMaterial.shininess / 128) + transparency_offset;
|
reflFactor = (gl_FrontMaterial.shininess / 128) + transparency_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
reflFactor = clamp(reflFactor * ns.a, 0.0, 1.0);
|
reflFactor = clamp(reflFactor, 0.0, 1.0);
|
||||||
|
|
||||||
// set ambient adjustment to remove bluiness with user input
|
// set ambient adjustment to remove bluiness with user input
|
||||||
float ambient_offset = clamp(ambient_correction, -1.0, 1.0);
|
float ambient_offset = clamp(ambient_correction, -1.0, 1.0);
|
||||||
|
|
86
Shaders/water-orig.frag
Normal file
86
Shaders/water-orig.frag
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
#version 120
|
||||||
|
|
||||||
|
varying vec4 rawpos;
|
||||||
|
varying vec4 ecPosition;
|
||||||
|
varying vec3 VNormal;
|
||||||
|
varying vec3 Normal;
|
||||||
|
varying vec3 lightVec;
|
||||||
|
|
||||||
|
uniform sampler3D NoiseTex;
|
||||||
|
uniform float osg_SimulationTime;
|
||||||
|
|
||||||
|
//const float scale = 1.0;
|
||||||
|
|
||||||
|
void main (void)
|
||||||
|
{
|
||||||
|
vec4 noisevecS = texture3D(NoiseTex, (rawpos.xyz)*0.0126);
|
||||||
|
vec4 nvLS = texture3D(NoiseTex, (rawpos.xyz)*-0.0003323417);
|
||||||
|
|
||||||
|
vec4 noisevec = texture3D(NoiseTex, (rawpos.xyz)*0.00423+vec3(0.0,0.0,osg_SimulationTime*0.035217));
|
||||||
|
vec4 nvL = texture3D(NoiseTex, (rawpos.xyz)*0.001223417+(0.0,0.0,osg_SimulationTime*-0.0212));
|
||||||
|
|
||||||
|
float fogFactor;
|
||||||
|
if (gl_Fog.density == 1.0)
|
||||||
|
{
|
||||||
|
fogFactor=1.0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float fogCoord = ecPosition.z;
|
||||||
|
const float LOG2 = 1.442695;
|
||||||
|
fogFactor = exp2(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord * LOG2);
|
||||||
|
fogFactor = clamp(fogFactor, 0.0, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
float a=1.0;
|
||||||
|
float n=0.00;
|
||||||
|
n += nvLS[0]*a;
|
||||||
|
a/=2.0;
|
||||||
|
n += nvLS[1]*a;
|
||||||
|
a/=2.0;
|
||||||
|
n += nvLS[2]*a;
|
||||||
|
a/=2.0;
|
||||||
|
n += nvLS[3]*a;
|
||||||
|
|
||||||
|
a=4.0;
|
||||||
|
float na=n;
|
||||||
|
na += nvL[0]*1.1;
|
||||||
|
a*=1.2;
|
||||||
|
na += nvL[1]*a;
|
||||||
|
a*=1.2;
|
||||||
|
na += nvL[2]*a;
|
||||||
|
a*=1.2;
|
||||||
|
na += nvL[3]*a;
|
||||||
|
a=2.0;
|
||||||
|
na += noisevec[0]*a*0.2;
|
||||||
|
a*=1.2;
|
||||||
|
na += noisevec[1]*a;
|
||||||
|
a*=1.2;
|
||||||
|
na += noisevec[2]*a;
|
||||||
|
a*=1.2;
|
||||||
|
na += noisevec[3]*a;
|
||||||
|
|
||||||
|
vec4 c1;
|
||||||
|
c1 = asin(vec4(smoothstep(0.0, 2.2, n), smoothstep(-0.1, 2.10, n), smoothstep(-0.2, 2.0, n), 1.0));
|
||||||
|
|
||||||
|
vec3 Eye = normalize(-ecPosition.xyz);
|
||||||
|
vec3 Reflected = normalize(reflect(-normalize(lightVec), normalize(VNormal+vec3(0.0,0.0,na*0.10-0.24))));
|
||||||
|
|
||||||
|
vec3 bump = normalize(VNormal+vec3(0.0, 0.0, na)-0.9);
|
||||||
|
vec3 bumped = max(normalize(refract(lightVec, normalize(bump), 0.16)), 0.0);
|
||||||
|
|
||||||
|
vec4 ambientColor = gl_LightSource[0].ambient;
|
||||||
|
vec4 light = ambientColor;
|
||||||
|
c1 *= light;
|
||||||
|
|
||||||
|
float bumpFact = (bumped.r+bumped.g+bumped.b);
|
||||||
|
float ReflectedEye = max(dot(Reflected, Eye), 0.0);
|
||||||
|
float eyeFact = pow(ReflectedEye, 20.0);
|
||||||
|
c1 += 0.3 * gl_LightSource[0].diffuse * (1.0-eyeFact) * bumpFact*bumpFact;
|
||||||
|
c1 += 0.4 * gl_LightSource[0].diffuse * eyeFact * 3*bumpFact;
|
||||||
|
eyeFact = pow(eyeFact, 20.0);
|
||||||
|
c1 += gl_LightSource[0].specular * eyeFact * 4*bumpFact;
|
||||||
|
|
||||||
|
vec4 finalColor = c1;
|
||||||
|
gl_FragColor = mix(gl_Fog.color, finalColor, fogFactor);
|
||||||
|
}
|
15
Shaders/water-orig.vert
Normal file
15
Shaders/water-orig.vert
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
varying vec4 rawpos;
|
||||||
|
varying vec4 ecPosition;
|
||||||
|
varying vec3 VNormal;
|
||||||
|
varying vec3 Normal;
|
||||||
|
varying vec3 lightVec;
|
||||||
|
|
||||||
|
void main(void)
|
||||||
|
{
|
||||||
|
rawpos = gl_Vertex;
|
||||||
|
ecPosition = gl_ModelViewMatrix * gl_Vertex;
|
||||||
|
VNormal = normalize(gl_NormalMatrix * gl_Normal);
|
||||||
|
Normal = normalize(gl_Normal);
|
||||||
|
lightVec = normalize(gl_LightSource[0].position.xyz/* - ecPosition*/);
|
||||||
|
gl_Position = ftransform();
|
||||||
|
}
|
|
@ -1,86 +1,80 @@
|
||||||
#version 120
|
uniform sampler2D water_normalmap;
|
||||||
|
uniform sampler2D water_reflection;
|
||||||
|
uniform sampler2D water_dudvmap;
|
||||||
|
uniform float saturation;
|
||||||
|
|
||||||
varying vec4 rawpos;
|
varying vec4 waterTex1; //moving texcoords
|
||||||
|
varying vec4 waterTex2; //moving texcoords
|
||||||
|
varying vec4 waterTex4; //viewts
|
||||||
varying vec4 ecPosition;
|
varying vec4 ecPosition;
|
||||||
varying vec3 VNormal;
|
varying vec3 viewerdir;
|
||||||
varying vec3 Normal;
|
varying vec3 lightdir;
|
||||||
varying vec3 lightVec;
|
varying vec3 normal;
|
||||||
|
|
||||||
uniform sampler3D NoiseTex;
|
void main(void)
|
||||||
uniform float osg_SimulationTime;
|
|
||||||
|
|
||||||
//const float scale = 1.0;
|
|
||||||
|
|
||||||
void main (void)
|
|
||||||
{
|
{
|
||||||
vec4 noisevecS = texture3D(NoiseTex, (rawpos.xyz)*0.0126);
|
const vec4 sca = vec4(0.005, 0.005, 0.005, 0.005);
|
||||||
vec4 nvLS = texture3D(NoiseTex, (rawpos.xyz)*-0.0003323417);
|
const vec4 sca2 = vec4(0.02, 0.02, 0.02, 0.02);
|
||||||
|
const vec4 tscale = vec4(0.25, 0.25, 0.25, 0.25);
|
||||||
|
|
||||||
vec4 noisevec = texture3D(NoiseTex, (rawpos.xyz)*0.00423+vec3(0.0,0.0,osg_SimulationTime*0.035217));
|
// compute direction to viewer
|
||||||
vec4 nvL = texture3D(NoiseTex, (rawpos.xyz)*0.001223417+(0.0,0.0,osg_SimulationTime*-0.0212));
|
vec3 E = normalize(viewerdir);
|
||||||
|
|
||||||
float fogFactor;
|
// compute direction to light source
|
||||||
if (gl_Fog.density == 1.0)
|
vec3 L = normalize(lightdir);
|
||||||
{
|
|
||||||
fogFactor=1.0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
float fogCoord = ecPosition.z;
|
|
||||||
const float LOG2 = 1.442695;
|
|
||||||
fogFactor = exp2(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord * LOG2);
|
|
||||||
fogFactor = clamp(fogFactor, 0.0, 1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
float a=1.0;
|
// half vector
|
||||||
float n=0.00;
|
vec3 H = normalize(L + E);
|
||||||
n += nvLS[0]*a;
|
|
||||||
a/=2.0;
|
const float water_shininess = 240.0;
|
||||||
n += nvLS[1]*a;
|
|
||||||
a/=2.0;
|
|
||||||
n += nvLS[2]*a;
|
|
||||||
a/=2.0;
|
|
||||||
n += nvLS[3]*a;
|
|
||||||
|
|
||||||
a=4.0;
|
vec4 viewt = normalize(waterTex4);
|
||||||
float na=n;
|
|
||||||
na += nvL[0]*1.1;
|
|
||||||
a*=1.2;
|
|
||||||
na += nvL[1]*a;
|
|
||||||
a*=1.2;
|
|
||||||
na += nvL[2]*a;
|
|
||||||
a*=1.2;
|
|
||||||
na += nvL[3]*a;
|
|
||||||
a=2.0;
|
|
||||||
na += noisevec[0]*a*0.2;
|
|
||||||
a*=1.2;
|
|
||||||
na += noisevec[1]*a;
|
|
||||||
a*=1.2;
|
|
||||||
na += noisevec[2]*a;
|
|
||||||
a*=1.2;
|
|
||||||
na += noisevec[3]*a;
|
|
||||||
|
|
||||||
vec4 c1;
|
vec4 disdis = texture2D(water_dudvmap, vec2(waterTex2 * tscale)) * 2.0 - 1.0;
|
||||||
c1 = asin(vec4(smoothstep(0.0, 2.2, n), smoothstep(-0.1, 2.10, n), smoothstep(-0.2, 2.0, n), 1.0));
|
vec4 dist = texture2D(water_dudvmap, vec2(waterTex1 + disdis*sca2)) * 2.0 - 1.0;
|
||||||
|
vec4 fdist = normalize(dist);
|
||||||
|
fdist *= sca;
|
||||||
|
|
||||||
vec3 Eye = normalize(-ecPosition.xyz);
|
//normalmap
|
||||||
vec3 Reflected = normalize(reflect(-normalize(lightVec), normalize(VNormal+vec3(0.0,0.0,na*0.10-0.24))));
|
vec4 nmap0 = texture2D(water_normalmap, vec2(waterTex1+ disdis*sca2)) * 2.0 - 1.0;
|
||||||
|
vec4 nmap2 = texture2D(water_normalmap, vec2(waterTex2 * tscale)) * 2.0 - 1.0;
|
||||||
|
vec4 vNorm = normalize(nmap0 + nmap2);
|
||||||
|
|
||||||
vec3 bump = normalize(VNormal+vec3(0.0, 0.0, na)-0.9);
|
//load reflection
|
||||||
vec3 bumped = max(normalize(refract(lightVec, normalize(bump), 0.16)), 0.0);
|
vec4 tmp = vec4(lightdir, 0.0);
|
||||||
|
vec4 refTex = texture2D(water_reflection, vec2(tmp));
|
||||||
|
vec4 refl = normalize(refTex);
|
||||||
|
|
||||||
vec4 ambientColor = gl_LightSource[0].ambient;
|
vec3 N0 = vec3(texture2D(water_normalmap, vec2(waterTex1+ disdis*sca2)) * 2.0 - 1.0);
|
||||||
vec4 light = ambientColor;
|
vec3 N1 = vec3(texture2D(water_normalmap, vec2(waterTex2 * tscale)) * 2.0 - 1.0);
|
||||||
c1 *= light;
|
vec3 N = normalize(normal+N0+N1);
|
||||||
|
|
||||||
float bumpFact = (bumped.r+bumped.g+bumped.b);
|
vec3 specular_color = vec3(gl_LightSource[0].diffuse)
|
||||||
float ReflectedEye = max(dot(Reflected, Eye), 0.0);
|
* pow(max(0.0, dot(N, H)), water_shininess) * 6.0;
|
||||||
float eyeFact = pow(ReflectedEye, 20.0);
|
|
||||||
c1 += 0.3 * gl_LightSource[0].diffuse * (1.0-eyeFact) * bumpFact*bumpFact;
|
|
||||||
c1 += 0.4 * gl_LightSource[0].diffuse * eyeFact * 3*bumpFact;
|
|
||||||
eyeFact = pow(eyeFact, 20.0);
|
|
||||||
c1 += gl_LightSource[0].specular * eyeFact * 4*bumpFact;
|
|
||||||
|
|
||||||
vec4 finalColor = c1;
|
vec4 specular = vec4(specular_color,0.5);
|
||||||
gl_FragColor = mix(gl_Fog.color, finalColor, fogFactor);
|
|
||||||
|
//calculate fresnel
|
||||||
|
vec4 invfres = vec4( dot(vNorm, viewt) );
|
||||||
|
vec4 fres = vec4(1.0) + invfres;
|
||||||
|
refl *= fres;
|
||||||
|
|
||||||
|
|
||||||
|
specular = specular * saturation;
|
||||||
|
|
||||||
|
vec4 finalColor = refl + specular;
|
||||||
|
|
||||||
|
float fogFactor;
|
||||||
|
float fogCoord = ecPosition.z;
|
||||||
|
const float LOG2 = 1.442695;
|
||||||
|
fogFactor = exp2(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord * LOG2);
|
||||||
|
|
||||||
|
vec4 ambient_light = gl_LightSource[0].diffuse;
|
||||||
|
|
||||||
|
finalColor *= ambient_light;
|
||||||
|
|
||||||
|
if(gl_Fog.density == 1.0)
|
||||||
|
fogFactor=1.0;
|
||||||
|
|
||||||
|
gl_FragColor = mix(gl_Fog.color,finalColor, fogFactor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,29 @@
|
||||||
varying vec4 rawpos;
|
varying vec4 waterTex1;
|
||||||
|
varying vec4 waterTex2;
|
||||||
|
varying vec4 waterTex4;
|
||||||
varying vec4 ecPosition;
|
varying vec4 ecPosition;
|
||||||
varying vec3 VNormal;
|
uniform float osg_SimulationTime;
|
||||||
varying vec3 Normal;
|
varying vec3 viewerdir;
|
||||||
varying vec3 lightVec;
|
varying vec3 lightdir;
|
||||||
|
varying vec3 normal;
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
rawpos = gl_Vertex;
|
vec3 N = normalize(gl_Normal);
|
||||||
ecPosition = gl_ModelViewMatrix * gl_Vertex;
|
normal = N;
|
||||||
VNormal = normalize(gl_NormalMatrix * gl_Normal);
|
|
||||||
Normal = normalize(gl_Normal);
|
ecPosition = gl_ModelViewMatrix * gl_Vertex;
|
||||||
lightVec = normalize(gl_LightSource[0].position.xyz/* - ecPosition*/);
|
|
||||||
gl_Position = ftransform();
|
viewerdir = vec3(gl_ModelViewMatrixInverse[3]) - vec3(gl_Vertex);
|
||||||
}
|
lightdir = normalize(vec3(gl_ModelViewMatrixInverse * gl_LightSource[0].position));
|
||||||
|
|
||||||
|
waterTex4 = vec4( ecPosition.xzy, 0.0 );
|
||||||
|
|
||||||
|
vec4 t1 = vec4(0.0, osg_SimulationTime*0.005217, 0.0,0.0);
|
||||||
|
vec4 t2 = vec4(0.0, osg_SimulationTime*-0.0012, 0.0,0.0);
|
||||||
|
|
||||||
|
waterTex1 = gl_MultiTexCoord0 + t1;
|
||||||
|
waterTex2 = gl_MultiTexCoord0 + t2;
|
||||||
|
|
||||||
|
gl_Position = ftransform();
|
||||||
|
}
|
BIN
Textures/Water/water-dudv.png
Normal file
BIN
Textures/Water/water-dudv.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 368 KiB |
BIN
Textures/Water/water-normalmap.png
Normal file
BIN
Textures/Water/water-normalmap.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 525 KiB |
BIN
Textures/Water/water-reflection.png
Normal file
BIN
Textures/Water/water-reflection.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1 KiB |
237
gui/dialogs/formation.xml
Normal file
237
gui/dialogs/formation.xml
Normal file
|
@ -0,0 +1,237 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
|
||||||
|
<PropertyList>
|
||||||
|
<name>formation</name>
|
||||||
|
<modal>false</modal>
|
||||||
|
<layout>vbox</layout>
|
||||||
|
|
||||||
|
<!-- AI Wingman options -->
|
||||||
|
|
||||||
|
<text>
|
||||||
|
<halign>left</halign>
|
||||||
|
<label>Wingman Controls</label>
|
||||||
|
<color>
|
||||||
|
<red>0.5</red>
|
||||||
|
<green>0.5</green>
|
||||||
|
<blue>0.5</blue>
|
||||||
|
<alpha>1</alpha>
|
||||||
|
</color>
|
||||||
|
</text>
|
||||||
|
|
||||||
|
<group>
|
||||||
|
<layout>hbox</layout>
|
||||||
|
<empty>
|
||||||
|
<pref-width>10</pref-width>
|
||||||
|
</empty>
|
||||||
|
|
||||||
|
<group>
|
||||||
|
<layout>vbox</layout>
|
||||||
|
|
||||||
|
<radio>
|
||||||
|
<halign>left</halign>
|
||||||
|
<label>Formate</label>
|
||||||
|
<property>/sim/ai/models/wingman/controls/formate-to-ac</property>
|
||||||
|
<live>true</live>
|
||||||
|
<binding>
|
||||||
|
<command>dialog-apply</command>
|
||||||
|
</binding>
|
||||||
|
<binding>
|
||||||
|
<command>nasal</command>
|
||||||
|
<script>
|
||||||
|
var v = getprop("/sim/ai/models/wingman/controls/formate-to-ac");
|
||||||
|
setprop("/sim/ai/models/wingman/controls/break",0);
|
||||||
|
setprop("/sim/ai/models/wingman/controls/join",0);
|
||||||
|
foreach (var c; props.globals.getNode("/ai/models").getChildren("wingman")){
|
||||||
|
c.getNode("controls/formate-to-ac").setBoolValue(v);
|
||||||
|
c.getNode("controls/break").setBoolValue(0);
|
||||||
|
c.getNode("controls/join").setBoolValue(0);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</binding>
|
||||||
|
</radio>
|
||||||
|
|
||||||
|
<radio>
|
||||||
|
<halign>left</halign>
|
||||||
|
<label>Break Formation</label>
|
||||||
|
<property>/sim/ai/models/wingman/controls/break</property>
|
||||||
|
<live>true</live>
|
||||||
|
<binding>
|
||||||
|
<command>dialog-apply</command>
|
||||||
|
</binding>
|
||||||
|
<binding>
|
||||||
|
<command>nasal</command>
|
||||||
|
<script>
|
||||||
|
var v = getprop("/sim/ai/models/wingman/controls/break");
|
||||||
|
setprop("/sim/ai/models/wingman/controls/formate-to-ac",0);
|
||||||
|
setprop("/sim/ai/models/wingman/controls/join",0);
|
||||||
|
|
||||||
|
foreach (var c; props.globals.getNode("/ai/models").getChildren("wingman")){
|
||||||
|
c.getNode("controls/break").setBoolValue(v);
|
||||||
|
c.getNode("controls/formate-to-ac").setBoolValue(0);
|
||||||
|
c.getNode("controls/join").setBoolValue(0);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</binding>
|
||||||
|
</radio>
|
||||||
|
|
||||||
|
<radio>
|
||||||
|
<halign>left</halign>
|
||||||
|
<label>Join</label>
|
||||||
|
<property>/sim/ai/models/wingman/controls/join</property>
|
||||||
|
<live>true</live>
|
||||||
|
<binding>
|
||||||
|
<command>dialog-apply</command>
|
||||||
|
</binding>
|
||||||
|
<binding>
|
||||||
|
<command>nasal</command>
|
||||||
|
<script>
|
||||||
|
var v = getprop("/sim/ai/models/wingman/controls/join");
|
||||||
|
setprop("/sim/ai/models/wingman/controls/formate-to-ac",0);
|
||||||
|
setprop("/sim/ai/models/wingman/controls/break",0);
|
||||||
|
|
||||||
|
foreach (var c; props.globals.getNode("/ai/models").getChildren("wingman")){
|
||||||
|
c.getNode("controls/join").setBoolValue(v);
|
||||||
|
c.getNode("controls/break").setBoolValue(0);
|
||||||
|
c.getNode("controls/formate-to-ac").setBoolValue(0);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</binding>
|
||||||
|
</radio>
|
||||||
|
|
||||||
|
</group>
|
||||||
|
|
||||||
|
<group>
|
||||||
|
<layout>vbox</layout>
|
||||||
|
|
||||||
|
<text>
|
||||||
|
<halign>left</halign>
|
||||||
|
<label>Break Heading Degrees Relative</label>
|
||||||
|
</text>
|
||||||
|
|
||||||
|
<text>
|
||||||
|
<label>Left/Right</label>
|
||||||
|
</text>
|
||||||
|
|
||||||
|
<group>
|
||||||
|
<layout>hbox</layout>
|
||||||
|
<text>
|
||||||
|
<halign>left</halign>
|
||||||
|
<label>-180</label>
|
||||||
|
</text>
|
||||||
|
<slider>
|
||||||
|
<width>75</width>
|
||||||
|
<height>25</height>
|
||||||
|
<min>-180</min>
|
||||||
|
<max>180</max>
|
||||||
|
<property>/ai/models/wingman/controls/break-deg-rel</property>
|
||||||
|
<binding>
|
||||||
|
<command>dialog-apply</command>
|
||||||
|
</binding>
|
||||||
|
<binding>
|
||||||
|
<command>nasal</command>
|
||||||
|
<script>
|
||||||
|
var v = getprop("/ai/models/wingman/controls/break-deg-rel");
|
||||||
|
foreach (var c; props.globals.getNode("/ai/models").getChildren("wingman")){
|
||||||
|
print("FFF ", v, " ", c.getNode("name").getValue());
|
||||||
|
c.getNode("controls/break-deg-rel",1).setDoubleValue(v);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</binding>
|
||||||
|
</slider>
|
||||||
|
<text>
|
||||||
|
<halign>left</halign>
|
||||||
|
|
||||||
|
<label>180</label>
|
||||||
|
|
||||||
|
</text>
|
||||||
|
</group>
|
||||||
|
|
||||||
|
<text>
|
||||||
|
<label>-100.00</label>
|
||||||
|
<format>%-0.1f deg</format>
|
||||||
|
<live>true</live>
|
||||||
|
<property>/ai/models/wingman/controls/break-deg-rel</property>
|
||||||
|
</text>
|
||||||
|
|
||||||
|
</group>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</group>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<group>
|
||||||
|
<layout>hbox</layout>
|
||||||
|
|
||||||
|
<text>
|
||||||
|
<halign>left</halign>
|
||||||
|
<label>Target Heading Degrees True</label>
|
||||||
|
</text>
|
||||||
|
|
||||||
|
<text>
|
||||||
|
<halign>left</halign>
|
||||||
|
<label>-100.00</label>
|
||||||
|
<format>%-0.1f deg</format>
|
||||||
|
<live>true</live>
|
||||||
|
<property>/ai/models/wingman/controls/tgt-heading-deg</property>
|
||||||
|
</text>
|
||||||
|
</group>
|
||||||
|
|
||||||
|
<empty>
|
||||||
|
<stretch>true</stretch>
|
||||||
|
</empty>
|
||||||
|
|
||||||
|
<group>
|
||||||
|
<layout>hbox</layout>
|
||||||
|
<default-padding>6</default-padding>
|
||||||
|
<empty>
|
||||||
|
<stretch>true</stretch>
|
||||||
|
</empty>
|
||||||
|
|
||||||
|
<button>
|
||||||
|
<legend>OK</legend>
|
||||||
|
<default>true</default>
|
||||||
|
<equal>true</equal>
|
||||||
|
<binding>
|
||||||
|
<command>dialog-apply</command>
|
||||||
|
</binding>
|
||||||
|
<binding>
|
||||||
|
<command>dialog-close</command>
|
||||||
|
</binding>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button>
|
||||||
|
<legend>Apply</legend>
|
||||||
|
<equal>true</equal>
|
||||||
|
<binding>
|
||||||
|
<command>dialog-apply</command>
|
||||||
|
</binding>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button>
|
||||||
|
<legend>Reset</legend>
|
||||||
|
<equal>true</equal>
|
||||||
|
<binding>
|
||||||
|
<command>dialog-update</command>
|
||||||
|
</binding>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button>
|
||||||
|
<legend>Cancel</legend>
|
||||||
|
<equal>true</equal>
|
||||||
|
<key>Esc</key>
|
||||||
|
<binding>
|
||||||
|
<command>dialog-close</command>
|
||||||
|
</binding>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<empty>
|
||||||
|
<stretch>true</stretch>
|
||||||
|
</empty>
|
||||||
|
</group>
|
||||||
|
</PropertyList>
|
|
@ -474,6 +474,13 @@
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
<item>
|
||||||
|
<label>AI Formation</label>
|
||||||
|
<binding>
|
||||||
|
<command>dialog-show</command>
|
||||||
|
<dialog-name>formation</dialog-name>
|
||||||
|
</binding>
|
||||||
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<label>AI Tanker</label>
|
<label>AI Tanker</label>
|
||||||
|
|
Loading…
Reference in a new issue