1
0
Fork 0

Merge branch 'master' of gitorious.org:fg/fgdata

This commit is contained in:
BARANGER Emmanuel 2014-04-24 13:54:17 +02:00
commit 44c8135ceb
15 changed files with 813 additions and 126 deletions

View file

@ -0,0 +1,210 @@
<?xml version="1.0" encoding="utf-8"?>
<PropertyList>
<name>Effects/planet</name>
<!-- <inherits-from>Effects/shadow</inherits-from> -->
<parameters>
<texture n ="0">
<type>white</type>
</texture>
<vertex-program-two-side type="bool">false</vertex-program-two-side>
<material>
<color-mode-uniform>1</color-mode-uniform>
<!-- DIFFUSE -->
</material>
<visibility><use>/environment/visibility-m</use></visibility>
</parameters>
<technique n="10">
<predicate>
<and>
<property>/sim/rendering/shaders/generic</property>
<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>
<active>
<use>material/active</use>
</active>
<ambient>
<use>material/ambient</use>
</ambient>
<diffuse>
<use>material/diffuse</use>
</diffuse>
<specular>
<use>material/specular</use>
</specular>
<emissive>
<use>material/emissive</use>
</emissive>
<shininess>
<use>material/shininess</use>
</shininess>
<color-mode>
<use>material/color-mode</use>
</color-mode>
</material>
<blend>
<source>src-alpha</source>
<destination>one-minus-src-alpha</destination>
</blend>
<shade-model>
<use>shade-model</use>
</shade-model>
<cull-face>
<use>cull-face</use>
</cull-face>
<rendering-hint>
<use>rendering-hint</use>
</rendering-hint>
<texture-unit>
<!-- The texture unit is always active because the shaders expect
that. -->
<unit>0</unit>
<!-- If there is a texture, the type in the derived effect
will be "2d". -->
<type>
<use>texture[0]/type</use>
</type>
<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>
<!--<vertex-program-two-side>
<use>vertex-program-two-side</use>
</vertex-program-two-side>-->
<program>
<vertex-shader>Shaders/planet.vert</vertex-shader>
<fragment-shader>Shaders/planet-cloudlayer.frag</fragment-shader>
</program>
<uniform>
<name>texture</name>
<type>sampler-2d</type>
<value type="int">0</value>
</uniform>
<uniform>
<name>colorMode</name>
<type>int</type>
<value>
<use>material/color-mode-uniform</use>
</value>
</uniform>
<uniform>
<name>visibility</name>
<type>float</type>
<value>
<use>visibility</use>
</value>
</uniform>
</pass>
</technique>
<technique n="11">
<pass>
<lighting>true</lighting>
<material>
<active>
<use>material/active</use>
</active>
<ambient>
<use>material/ambient</use>
</ambient>
<diffuse>
<use>material/diffuse</use>
</diffuse>
<specular>
<use>material/specular</use>
</specular>
<emissive>
<use>material/emissive</use>
</emissive>
<shininess>
<use>material/shininess</use>
</shininess>
<color-mode>
<use>material/color-mode</use>
</color-mode>
</material>
<blend>
<active>
<use>blend/active</use>
</active>
<source>
<use>blend/source</use>
</source>
<destination>
<use>blend/destination</use>
</destination>
</blend>
<shade-model>
<use>shade-model</use>
</shade-model>
<cull-face>
<use>cull-face</use>
</cull-face>
<rendering-hint>
<use>rendering-hint</use>
</rendering-hint>
<texture-unit>
<active>
<use>texture[0]/active</use>
</active>
<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>
-->
<environment>
<mode>modulate</mode>
</environment>
</texture-unit>
<!-- A two-sided lighting model is set by default near the root
of the scene graph. Perhaps that ought to be set in this
effect?
-->
</pass>
</technique>
</PropertyList>

218
Effects/planet.eff Normal file
View file

@ -0,0 +1,218 @@
<?xml version="1.0" encoding="utf-8"?>
<PropertyList>
<name>Effects/planet</name>
<!-- <inherits-from>Effects/shadow</inherits-from> -->
<parameters>
<texture n ="0">
<type>white</type>
</texture>
<texture n="1">
<image>Textures/Terrain/void.png</image>
<type>2d</type>
<filter>linear-mipmap-linear</filter>
<wrap-s>repeat</wrap-s>
<wrap-t>repeat</wrap-t>
<internal-format>normalized</internal-format>
</texture>
<vertex-program-two-side type="bool">false</vertex-program-two-side>
<material>
<color-mode-uniform>1</color-mode-uniform>
<!-- DIFFUSE -->
</material>
<visibility><use>/environment/visibility-m</use></visibility>
</parameters>
<generate>
<tangent type="int">6</tangent>
</generate>
<technique n="10">
<predicate>
<and>
<property>/sim/rendering/shaders/generic</property>
<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>
<active>
<use>material/active</use>
</active>
<ambient>
<use>material/ambient</use>
</ambient>
<diffuse>
<use>material/diffuse</use>
</diffuse>
<specular>
<use>material/specular</use>
</specular>
<emissive>
<use>material/emissive</use>
</emissive>
<shininess>
<use>material/shininess</use>
</shininess>
<color-mode>
<use>material/color-mode</use>
</color-mode>
</material>
<blend><use>transparent</use></blend>
<alpha-test><use>transparent</use></alpha-test>
<shade-model>
<use>shade-model</use>
</shade-model>
<cull-face>
<use>cull-face</use>
</cull-face>
<rendering-hint>
<use>rendering-hint</use>
</rendering-hint>
<texture-unit>
<unit>0</unit>
<type><use>texture[0]/type</use></type>
<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>
</texture-unit>
<texture-unit>
<unit>1</unit>
<image><use>texture[1]/image</use></image>
<type><use>texture[1]/type</use></type>
<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>
<program>
<vertex-shader>Shaders/planet.vert</vertex-shader>
<fragment-shader>Shaders/planet.frag</fragment-shader>
<attribute>
<name>tangent</name>
<index>6</index>
</attribute>
</program>
<uniform>
<name>texture</name>
<type>sampler-2d</type>
<value type="int">0</value>
</uniform>
<uniform>
<name>shadowtex</name>
<type>sampler-2d</type>
<value type="int">1</value>
</uniform>
<uniform>
<name>colorMode</name>
<type>int</type>
<value>
<use>material/color-mode-uniform</use>
</value>
</uniform>
<uniform>
<name>visibility</name>
<type>float</type>
<value>
<use>visibility</use>
</value>
</uniform>
</pass>
</technique>
<technique n="11">
<pass>
<lighting>true</lighting>
<material>
<active>
<use>material/active</use>
</active>
<ambient>
<use>material/ambient</use>
</ambient>
<diffuse>
<use>material/diffuse</use>
</diffuse>
<specular>
<use>material/specular</use>
</specular>
<emissive>
<use>material/emissive</use>
</emissive>
<shininess>
<use>material/shininess</use>
</shininess>
<color-mode>
<use>material/color-mode</use>
</color-mode>
</material>
<blend>
<active>
<use>blend/active</use>
</active>
<source>
<use>blend/source</use>
</source>
<destination>
<use>blend/destination</use>
</destination>
</blend>
<shade-model>
<use>shade-model</use>
</shade-model>
<cull-face>
<use>cull-face</use>
</cull-face>
<rendering-hint>
<use>rendering-hint</use>
</rendering-hint>
<texture-unit>
<active>
<use>texture[0]/active</use>
</active>
<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>
-->
<environment>
<mode>modulate</mode>
</environment>
</texture-unit>
<!-- A two-sided lighting model is set by default near the root
of the scene graph. Perhaps that ought to be set in this
effect?
-->
</pass>
</technique>
</PropertyList>

View file

@ -75,6 +75,7 @@
<program>
<vertex-shader>Shaders/surface-light-lightfield.vert</vertex-shader>
<fragment-shader>Shaders/surface-light-lightfield.frag</fragment-shader>
<fragment-shader>Shaders/noise.frag</fragment-shader>
</program>
<uniform>
<name>size</name>

View file

@ -668,11 +668,6 @@
<type>sampler-2d</type>
<value type="int">5</value>
</uniform>
<uniform>
<name>snow_texture</name>
<type>sampler-2d</type>
<value type="int">6</value>
</uniform>
<uniform>
<name>detail_texture</name>
<type>sampler-2d</type>
@ -789,10 +784,6 @@
<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>
<type>noise</type>
</texture-unit>
<texture-unit>
<unit>5</unit>
<type><use>texture[12]/type</use></type>
@ -802,15 +793,6 @@
<wrap-t><use>texture[12]/wrap-t</use></wrap-t>
<internal-format><use>texture[12]/internal-format</use></internal-format>
</texture-unit>
<texture-unit>
<unit>6</unit>
<type><use>texture[10]/type</use></type>
<image><use>texture[10]/image</use></image>
<filter><use>texture[10]/filter</use></filter>
<wrap-s><use>texture[10]/wrap-s</use></wrap-s>
<wrap-t><use>texture[10]/wrap-t</use></wrap-t>
<internal-format><use>texture[10]/internal-format</use></internal-format>
</texture-unit>
<texture-unit>
<unit>7</unit>
<type><use>texture[11]/type</use></type>
@ -823,6 +805,7 @@
<program>
<vertex-shader>Shaders/terrain-haze-detailed.vert</vertex-shader>
<fragment-shader>Shaders/terrain-haze-detailed.frag</fragment-shader>
<fragment-shader>Shaders/noise.frag</fragment-shader>
</program>
<uniform>
<name>visibility</name>
@ -939,21 +922,11 @@
<type>sampler-2d</type>
<value type="int">0</value>
</uniform>
<uniform>
<name>NoiseTex</name>
<type>sampler-3d</type>
<value type="int">1</value>
</uniform>
<uniform>
<name>mix_texture</name>
<type>sampler-2d</type>
<value type="int">5</value>
</uniform>
<uniform>
<name>snow_texture</name>
<type>sampler-2d</type>
<value type="int">6</value>
</uniform>
<uniform>
<name>detail_texture</name>
<type>sampler-2d</type>

104
Nasal/earthview.nas Normal file
View file

@ -0,0 +1,104 @@
###########################################################
# Earthview orbital rendering
###########################################################
var start = func() {
var lat = getprop("/position/latitude-deg");
var lon = getprop("/position/longitude-deg");
earth_model.node = earthview.place_earth_model("Models/Astro/earth.xml",lat, lon, 0.0, 0.0, 0.0, 0.0);
cloudsphere_model.node = earthview.place_earth_model("Models/Astro/cloudsphere.xml",lat, lon, 0.0, 0.0, 0.0, 0.0);
}
var stop = func () {
earth_model.node.remove();
cloudsphere_model.node.remove();
setprop("/earthview/control_loop_flag",0);
}
var place_earth_model = func(path, lat, lon, alt, heading, pitch, roll) {
var m = props.globals.getNode("models", 1);
for (var i = 0; 1; i += 1)
if (m.getChild("model", i, 0) == nil)
break;
var model = m.getChild("model", i, 1);
var R1 = 5800000.0;
var R2 = 58000.0;
var altitude1 = getprop("/position/altitude-ft");
var altitude2 = R2/R1 * altitude1;
var model_alt = altitude1 - altitude2 - R2 * m_to_ft;
setprop("/earthview/latitude-deg", lat);
setprop("/earthview/longitude-deg", lon);
setprop("/earthview/elevation-ft", model_alt);
setprop("/earthview/heading-deg", heading);
setprop("/earthview/pitch-deg", pitch);
setprop("/earthview/roll-deg", roll);
setprop("/earthview/yaw-deg", 0.0);
var eview = props.globals.getNode("earthview", 1);
var latN = eview.getNode("latitude-deg",1);
var lonN = eview.getNode("longitude-deg",1);
var altN = eview.getNode("elevation-ft",1);
var headN = eview.getNode("heading-deg",1);
var pitchN = eview.getNode("pitch-deg",1);
var rollN = eview.getNode("roll-deg",1);
model.getNode("path", 1).setValue(path);
model.getNode("latitude-deg-prop", 1).setValue(latN.getPath());
model.getNode("longitude-deg-prop", 1).setValue(lonN.getPath());
model.getNode("elevation-ft-prop", 1).setValue(altN.getPath());
model.getNode("heading-deg-prop", 1).setValue(headN.getPath());
model.getNode("pitch-deg-prop", 1).setValue(pitchN.getPath());
model.getNode("roll-deg-prop", 1).setValue(rollN.getPath());
model.getNode("load", 1).remove();
setprop("/earthview/heading-deg",90);
setprop("/earthview/control_loop_flag",1);
control_loop();
return model;
}
var control_loop = func {
var R1 = 5800000.0;
var R2 = 58000.0;
var altitude1 = getprop("/position/altitude-ft");
var altitude2 = R2/R1 * altitude1;
var model_alt = altitude1 - altitude2 - R2 * m_to_ft;
setprop("/earthview/elevation-ft", model_alt);
var lat = getprop("/position/latitude-deg");
var lon = getprop("/position/longitude-deg");
setprop("/earthview/latitude-deg", lat);
setprop("/earthview/longitude-deg", lon);
setprop("/earthview/roll-deg", -(90-lat));
setprop("/earthview/yaw-deg", -lon);
if (getprop("/earthview/control_loop_flag") ==1) {settimer( func {control_loop(); },0);}
}
var ft_to_m = 0.30480;
var m_to_ft = 1.0/ft_to_m;
var earth_model = {};
var cloudsphere_model = {};

View file

@ -0,0 +1,61 @@
// -*-C++-*-
// Ambient term comes in gl_Color.rgb.
#version 120
varying vec4 diffuse_term;
varying vec3 normal;
varying vec3 ecViewDir;
varying vec3 VTangent;
uniform sampler2D texture;
float luminance(vec3 color)
{
return dot(vec3(0.212671, 0.715160, 0.072169), color);
}
void main()
{
vec3 n;
float NdotL, NdotHV;
vec4 color = gl_Color;
vec3 lightDir = gl_LightSource[0].position.xyz;
vec3 halfVector = normalize(normalize(lightDir) + normalize(ecViewDir));
vec4 texel;
vec4 fragColor;
vec4 specular = vec4(0.0);
// If gl_Color.a == 0, this is a back-facing polygon and the
// normal should be reversed.
n = (2.0 * gl_Color.a - 1.0) * normal;
n = normalize(n);
vec3 light_specular = vec3 (1.0, 1.0, 1.0);
NdotL = dot(n, lightDir);
if (NdotL > 0.0) {
color += diffuse_term * NdotL ;
NdotHV = max(dot(n, halfVector), 0.0);
if (gl_FrontMaterial.shininess > 0.0)
specular.rgb = (gl_FrontMaterial.specular.rgb
* light_specular
* pow(NdotHV, gl_FrontMaterial.shininess));
}
color.a = diffuse_term.a;
// This shouldn't be necessary, but our lighting becomes very
// saturated. Clamping the color before modulating by the texture
// is closer to what the OpenGL fixed function pipeline does.
color = clamp(color, 0.0, 1.0);
texel = texture2D(texture, gl_TexCoord[0].st);
fragColor = color * texel + specular;
gl_FragColor = fragColor;
//gl_FragColor = (0.5,0.5,0.5,1.0);
}

80
Shaders/planet.frag Normal file
View file

@ -0,0 +1,80 @@
// -*-C++-*-
// Ambient term comes in gl_Color.rgb.
#version 120
varying vec4 diffuse_term;
varying vec3 normal;
varying vec3 ecViewDir;
varying vec3 VTangent;
uniform float visibility;
uniform sampler2D texture;
uniform sampler2D shadowtex;
float luminance(vec3 color)
{
return dot(vec3(0.212671, 0.715160, 0.072169), color);
}
void main()
{
vec3 n;
float NdotL, NdotHV;
vec4 color = gl_Color;
vec3 lightDir = gl_LightSource[0].position.xyz;
//vec3 halfVector = gl_LightSource[0].halfVector.xyz;
vec3 halfVector = normalize(normalize(lightDir) + normalize(ecViewDir));
vec4 texel;
vec4 shadowTexel;
vec4 fragColor;
vec4 specular = vec4(0.0);
// If gl_Color.a == 0, this is a back-facing polygon and the
// normal should be reversed.
n = (2.0 * gl_Color.a - 1.0) * normal;
n = normalize(n);
vec3 VBinormal;
VBinormal = cross(normal, VTangent);
float xOffset = -0.005 * dot(normalize(lightDir), normalize(VTangent));
float yOffset = -0.005 * dot(normalize(lightDir), normalize(VBinormal));
shadowTexel = texture2D(shadowtex, vec2(gl_TexCoord[0].s-xOffset, gl_TexCoord[0].t-yOffset));
vec3 light_specular = vec3 (1.0, 1.0, 1.0);
NdotL = dot(n, lightDir);
if (NdotL > 0.0) {
color += diffuse_term * NdotL * (1.0-shadowTexel.a);
NdotHV = max(dot(n, halfVector), 0.0);
if (gl_FrontMaterial.shininess > 0.0)
specular.rgb = (gl_FrontMaterial.specular.rgb
* light_specular * (1.0-shadowTexel.a)
* pow(NdotHV, gl_FrontMaterial.shininess));
}
color.a = diffuse_term.a;
// This shouldn't be necessary, but our lighting becomes very
// saturated. Clamping the color before modulating by the texture
// is closer to what the OpenGL fixed function pipeline does.
color = clamp(color, 0.0, 1.0);
texel = texture2D(texture, gl_TexCoord[0].st);
fragColor = color * texel + specular;
//fragColor = fragColor * (1.0 - 0.5 * shadowTexel.a);
//fragColor = mix(fragColor, shadowTexel, shadowTexel.a);
float angle = dot(normalize(ecViewDir), normalize(normal));
float distance_through_atmosphere = 10.0 / ((angle)+0.001);
vec4 fogColor = vec4 (0.83,0.9,1.0,1.0) * clamp(length(diffuse_term.rgb * max(NdotL,0.0)),0.0,1.0);
//float visibility = 80.0;
float fogFactor = exp(-distance_through_atmosphere/(visibility/1000.0));
fragColor = mix(fogColor, fragColor, fogFactor);
//fragColor.rgb = fog_Func(fragColor.rgb, fogType);
gl_FragColor = fragColor;
//gl_FragColor = (0.5,0.5,0.5,1.0);
}

69
Shaders/planet.vert Normal file
View file

@ -0,0 +1,69 @@
// -*-C++-*-
// Shader that uses OpenGL state values to do per-pixel lighting
//
// The only light used is gl_LightSource[0], which is assumed to be
// directional.
//
// Diffuse colors come from the gl_Color, ambient from the material. This is
// equivalent to osg::Material::DIFFUSE.
#version 120
#define MODE_OFF 0
#define MODE_DIFFUSE 1
#define MODE_AMBIENT_AND_DIFFUSE 2
// The constant term of the lighting equation that doesn't depend on
// the surface normal is passed in gl_{Front,Back}Color. The alpha
// component is set to 1 for front, 0 for back in order to work around
// bugs with gl_FrontFacing in the fragment shader.
varying vec4 diffuse_term;
varying vec3 normal;
varying vec3 ecViewDir;
varying vec3 VTangent;
uniform int colorMode;
attribute vec3 tangent;//, binormal;
void main()
{
vec4 ep = gl_ModelViewMatrixInverse * vec4(0.0,0.0,0.0,1.0);
ecViewDir = (gl_ModelViewMatrix * (ep - gl_Vertex)).xyz;
gl_Position = ftransform();
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
normal = gl_NormalMatrix * gl_Normal;
VTangent = gl_NormalMatrix * tangent;
vec4 ambient_color, diffuse_color;
if (colorMode == MODE_DIFFUSE) {
diffuse_color = gl_Color;
ambient_color = gl_FrontMaterial.ambient;
} else if (colorMode == MODE_AMBIENT_AND_DIFFUSE) {
diffuse_color = gl_Color;
ambient_color = gl_Color;
} else {
diffuse_color = gl_FrontMaterial.diffuse;
ambient_color = gl_FrontMaterial.ambient;
}
vec4 light_diffuse = vec4 (1.0,1.0,1.0,1.0);
vec4 light_ambient = vec4 (0.05, 0.05, 0.05, 1.0);
diffuse_term = diffuse_color * light_diffuse;//gl_LightSource[0].diffuse;
vec4 constant_term = gl_FrontMaterial.emission + ambient_color *
(gl_LightModel.ambient + light_ambient);
// Super hack: if diffuse material alpha is less than 1, assume a
// transparency animation is at work
if (gl_FrontMaterial.diffuse.a < 1.0)
diffuse_term.a = gl_FrontMaterial.diffuse.a;
else
diffuse_term.a = gl_Color.a;
// Another hack for supporting two-sided lighting without using
// gl_FrontFacing in the fragment shader.
gl_FrontColor.rgb = constant_term.rgb; gl_FrontColor.a = 1.0;
gl_BackColor.rgb = constant_term.rgb; gl_BackColor.a = 0.0;
//fogCoord = abs(ecPosition.z / ecPosition.w);
//fog_Func(fogType);
}

View file

@ -9,10 +9,12 @@ uniform float eye_alt;
uniform float terminator;
varying vec3 relPos;
varying vec2 rawPos;
varying float pixelSize;
float alt;
float Noise2D(in vec2 coord, in float wavelength);
float fog_func (in float targ)
{
@ -41,7 +43,7 @@ else
}
vec4 light_sprite (in vec2 coord, in float transmission)
vec4 light_sprite (in vec2 coord, in float transmission, in float noise)
{
coord.s = coord.s - 0.5;
@ -51,7 +53,8 @@ float r = length(coord);
if (pixelSize<1.3) {return vec4 (1.0,1.0,1.0,1.0) * 0.08;}
float sinphi = dot(vec2 (1.0,0.0), normalize(coord));
float angle = noise * 6.28;
float sinphi = dot(vec2 (sin(angle),cos(angle)), normalize(coord));
float ray = clamp(pow(sin((sinphi-3.0) * (sinphi-3.0)),10.0),0.0,1.0);
@ -76,6 +79,8 @@ void main()
float distance_in_layer;
float transmission_arg;
float noise = Noise2D(rawPos.xy ,1.0);
// angle with horizon
float ct = dot(vec3(0.0, 0.0, 1.0), relPos)/dist;
@ -139,7 +144,7 @@ void main()
float dist_att = exp(-0.3/attenuationScale/pixelSize);
//vec4 texel = texture2D(texture,gl_TexCoord[0].st);
vec4 texel = light_sprite(gl_TexCoord[0].st,transmission);
vec4 texel = light_sprite(gl_TexCoord[0].st,transmission, noise);
gl_FragColor = vec4 (gl_Color.rgb, texel.a * transmission * dist_att);

View file

@ -6,6 +6,7 @@
uniform float size;
varying vec3 relPos;
varying vec2 rawPos;
varying float pixelSize;
@ -17,6 +18,7 @@ void main()
vec4 ep = gl_ModelViewMatrixInverse * vec4(0.0,0.0,0.0,1.0);
relPos = gl_Vertex.xyz - ep.xyz;
rawPos = gl_Vertex.xy;
float dist = length(relPos);
float lightScale = size * size * size * size * size / 1000.0;
pixelSize = min(size * size/25.0,lightScale/dist);

View file

@ -11,8 +11,6 @@ varying vec3 worldPos;
uniform sampler2D texture;
uniform sampler3D NoiseTex;
uniform sampler2D snow_texture;
uniform sampler2D detail_texture;
uniform sampler2D mix_texture;
@ -50,95 +48,8 @@ float eShade;
float yprime_alt;
float mie_angle;
float rand2D(in vec2 co){
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}
float rand3D(in vec3 co){
return fract(sin(dot(co.xyz ,vec3(12.9898,78.233,144.7272))) * 43758.5453);
}
float cosine_interpolate(in float a, in float b, in float x)
{
float ft = x * 3.1415927;
float f = (1.0 - cos(ft)) * .5;
return a*(1.0-f) + b*f;
}
float simple_interpolate(in float a, in float b, in float x)
{
return a + smoothstep(0.0,1.0,x) * (b-a);
//return mix(a,b,x);
}
float interpolatedNoise2D(in float x, in float y)
{
float integer_x = x - fract(x);
float fractional_x = x - integer_x;
float integer_y = y - fract(y);
float fractional_y = y - integer_y;
float v1 = rand2D(vec2(integer_x, integer_y));
float v2 = rand2D(vec2(integer_x+1.0, integer_y));
float v3 = rand2D(vec2(integer_x, integer_y+1.0));
float v4 = rand2D(vec2(integer_x+1.0, integer_y +1.0));
float i1 = simple_interpolate(v1 , v2 , fractional_x);
float i2 = simple_interpolate(v3 , v4 , fractional_x);
return simple_interpolate(i1 , i2 , fractional_y);
}
float interpolatedNoise3D(in float x, in float y, in float z)
{
float integer_x = x - fract(x);
float fractional_x = x - integer_x;
float integer_y = y - fract(y);
float fractional_y = y - integer_y;
float integer_z = z - fract(z);
float fractional_z = z - integer_z;
float v1 = rand3D(vec3(integer_x, integer_y, integer_z));
float v2 = rand3D(vec3(integer_x+1.0, integer_y, integer_z));
float v3 = rand3D(vec3(integer_x, integer_y+1.0, integer_z));
float v4 = rand3D(vec3(integer_x+1.0, integer_y +1.0, integer_z));
float v5 = rand3D(vec3(integer_x, integer_y, integer_z+1.0));
float v6 = rand3D(vec3(integer_x+1.0, integer_y, integer_z+1.0));
float v7 = rand3D(vec3(integer_x, integer_y+1.0, integer_z+1.0));
float v8 = rand3D(vec3(integer_x+1.0, integer_y +1.0, integer_z+1.0));
float i1 = simple_interpolate(v1,v5, fractional_z);
float i2 = simple_interpolate(v2,v6, fractional_z);
float i3 = simple_interpolate(v3,v7, fractional_z);
float i4 = simple_interpolate(v4,v8, fractional_z);
float ii1 = simple_interpolate(i1,i2,fractional_x);
float ii2 = simple_interpolate(i3,i4,fractional_x);
return simple_interpolate(ii1 , ii2 , fractional_y);
}
float Noise2D(in vec2 coord, in float wavelength)
{
return interpolatedNoise2D(coord.x/wavelength, coord.y/wavelength);
}
float Noise3D(in vec3 coord, in float wavelength)
{
return interpolatedNoise3D(coord.x/wavelength, coord.y/wavelength, coord.z/wavelength);
}
float Noise2D(in vec2 coord, in float wavelength);
float Noise3D(in vec3 coord, in float wavelength);
@ -265,7 +176,6 @@ float noise_2000m = Noise3D(worldPos.xyz, 2000.0);
if ((quality_level > 3)&&(relPos.z + eye_alt +500.0 > snowlevel))
{
//snow_texel = texture2D(snow_texture, gl_TexCoord[0].st);
float sfactor;
snow_texel = vec4 (0.95, 0.95, 0.95, 1.0) * (0.9 + 0.1* noise_500m + 0.1* (1.0 - noise_10m) );
snow_texel.r = snow_texel.r * (0.9 + 0.05 * (noise_10m + noise_5m));

View file

@ -12,8 +12,6 @@ varying vec3 ecViewdir;
uniform sampler2D texture;
uniform sampler3D NoiseTex;
uniform sampler2D snow_texture;
uniform sampler2D detail_texture;
uniform sampler2D mix_texture;
uniform sampler2D grain_texture;

View file

@ -108,9 +108,10 @@ void main()
}
// Scale by random domains
float voronoi;
if (forest_effects > 0)
{
float voronoi = 0.5 + 1.0 * VoronoiNoise2D(gl_Color.xy, 200.0, 1.5, 1.5);
voronoi = 0.5 + 1.0 * VoronoiNoise2D(gl_Color.xy, 200.0, 1.5, 1.5);
position.xyz = position.xyz * voronoi;
}

45
gui/dialogs/earthview.xml Normal file
View file

@ -0,0 +1,45 @@
<?xml version="1.0"?>
<PropertyList>
<name>earthview</name>
<width>150</width>
<height>50</height>
<modal>false</modal>
<button>
<x>10</x>
<y>10</y>
<legend>Start</legend>
<equal>true</equal>
<binding>
<command>nasal</command>
<script>earthview.start()</script>
</binding>
</button>
<button>
<x>50</x>
<y>10</y>
<legend>Stop</legend>
<equal>true</equal>
<binding>
<command>nasal</command>
<script>earthview.stop()</script>
</binding>
</button>
<button>
<x>90</x>
<y>10</y>
<legend>Cancel</legend>
<equal>true</equal>
<key>Esc</key>
<binding>
<command>dialog-close</command>
</binding>
</button>
</PropertyList>

View file

@ -168,6 +168,16 @@
</binding>
</item>
<item>
<label>Earthview orbital rendering</label>
<name>earthview</name>
<binding>
<command>dialog-show</command>
<dialog-name>earthview</dialog-name>
</binding>
<enabled>true</enabled>
</item>
<item>
<name>stereoscopic-options</name>
<binding>