1
0
Fork 0

Use quality level inside landmass fragment shader

This commit is contained in:
fredb 2010-04-10 15:08:29 +00:00
parent 714c500fa9
commit 1a986d8747
3 changed files with 38 additions and 21 deletions

View file

@ -13,6 +13,7 @@
<snow-level><use>/sim/rendering/snow-level-m</use></snow-level> <snow-level><use>/sim/rendering/snow-level-m</use></snow-level>
<depth-factor type="float">0.01</depth-factor> <depth-factor type="float">0.01</depth-factor>
<canopy-height type="float">15.0</canopy-height> <canopy-height type="float">15.0</canopy-height>
<quality-level><use>/sim/rendering/quality-level</use></quality-level>
</parameters> </parameters>
<generate> <generate>
<tangent type="int">6</tangent> <tangent type="int">6</tangent>
@ -128,6 +129,11 @@
<type>float</type> <type>float</type>
<value><use>canopy-height</use></value> <value><use>canopy-height</use></value>
</uniform> </uniform>
<uniform>
<name>quality_level</name>
<type>float</type>
<value><use>quality-level</use></value>
</uniform>
</pass> </pass>
</technique> </technique>
<technique n="9"> <technique n="9">
@ -230,6 +236,11 @@
<type>float</type> <type>float</type>
<value><use>snow-level</use></value> <value><use>snow-level</use></value>
</uniform> </uniform>
<uniform>
<name>quality_level</name>
<type>float</type>
<value><use>quality-level</use></value>
</uniform>
</pass> </pass>
</technique> </technique>
</PropertyList> </PropertyList>

View file

@ -13,13 +13,14 @@ uniform sampler3D NoiseTex;
uniform sampler2D BaseTex; uniform sampler2D BaseTex;
uniform sampler2D NormalTex; uniform sampler2D NormalTex;
uniform float depth_factor; uniform float depth_factor;
uniform float quality_level; // From /sim/rendering/quality-level
uniform float snowlevel; // From /sim/rendering/snow-level-m uniform float snowlevel; // From /sim/rendering/snow-level-m
const float scale = 1.0; const float scale = 1.0;
int linear_search_steps = 10;
float ray_intersect(sampler2D reliefMap, vec2 dp, vec2 ds) float ray_intersect(sampler2D reliefMap, vec2 dp, vec2 ds)
{ {
const int linear_search_steps = 10;
float size = 1.0 / float(linear_search_steps); float size = 1.0 / float(linear_search_steps);
float depth = 0.0; float depth = 0.0;
@ -54,17 +55,21 @@ float ray_intersect(sampler2D reliefMap, vec2 dp, vec2 ds)
void main (void) void main (void)
{ {
vec2 uv; if ( quality_level >= 3.5 ) {
linear_search_steps = 20;
}
vec2 uv, dp, ds;
vec3 N; vec3 N;
if ( bump > 0.9 ) float d;
if ( bump > 0.9 && quality_level >= 2.0 )
{ {
vec3 V = normalize(ecPosition.xyz); vec3 V = normalize(ecPosition.xyz);
float a = dot(VNormal, -V); float a = dot(VNormal, -V);
vec2 s = vec2(dot(V, VTangent), dot(V, VBinormal)); vec2 s = vec2(dot(V, VTangent), dot(V, VBinormal));
s *= depth_factor / a; s *= depth_factor / a;
vec2 ds = s; ds = s;
vec2 dp = gl_TexCoord[0].st; dp = gl_TexCoord[0].st;
float d = ray_intersect(NormalTex, dp, ds); d = ray_intersect(NormalTex, dp, ds);
uv = dp + ds * d; uv = dp + ds * d;
N = texture2D(NormalTex, uv).xyz * 2.0 - 1.0; N = texture2D(NormalTex, uv).xyz * 2.0 - 1.0;
@ -75,7 +80,6 @@ void main (void)
N = vec3(0.0, 0.0, 1.0); N = vec3(0.0, 0.0, 1.0);
} }
vec4 noisevec = texture3D(NoiseTex, (rawpos.xyz)*0.01*scale); vec4 noisevec = texture3D(NoiseTex, (rawpos.xyz)*0.01*scale);
vec4 nvL = texture3D(NoiseTex, (rawpos.xyz)*0.00066*scale); vec4 nvL = texture3D(NoiseTex, (rawpos.xyz)*0.00066*scale);
@ -109,8 +113,9 @@ void main (void)
vec3 l = gl_LightSource[0].position.xyz; vec3 l = gl_LightSource[0].position.xyz;
vec3 diffuse = gl_Color.rgb * max(0.0, dot(N, l)); vec3 diffuse = gl_Color.rgb * max(0.0, dot(N, l));
float shadow_factor = 1.0; float shadow_factor = 1.0;
/*
// Shadow // Shadow
if ( quality_level >= 3.0 ) {
dp += ds * d; dp += ds * d;
vec3 sl = normalize( vec3( dot( l, VTangent ), dot( l, VBinormal ), dot( -l, VNormal ) ) ); vec3 sl = normalize( vec3( dot( l, VTangent ), dot( l, VBinormal ), dot( -l, VNormal ) ) );
ds = sl.xy * depth_factor / sl.z; ds = sl.xy * depth_factor / sl.z;
@ -118,8 +123,9 @@ void main (void)
float dl = ray_intersect(NormalTex, dp, ds); float dl = ray_intersect(NormalTex, dp, ds);
if ( dl < d - 0.05 ) if ( dl < d - 0.05 )
shadow_factor = dot( constantColor.xyz, vec3( 1.0, 1.0, 1.0 ) ) * 0.25; shadow_factor = dot( constantColor.xyz, vec3( 1.0, 1.0, 1.0 ) ) * 0.25;
// end shadow }
*/ // end shadow
vec4 ambient_light = constantColor + gl_LightSource[0].diffuse * shadow_factor * vec4(diffuse, 1.0); vec4 ambient_light = constantColor + gl_LightSource[0].diffuse * shadow_factor * vec4(diffuse, 1.0);
c1 *= ambient_light; c1 *= ambient_light;

View file

@ -17,7 +17,7 @@ uniform sampler2D BaseTex;
uniform sampler2D NormalTex; uniform sampler2D NormalTex;
uniform float depth_factor; uniform float depth_factor;
uniform float tile_size; uniform float tile_size;
uniform float quality_level; uniform float quality_level; // From /sim/rendering/quality-level
uniform vec3 night_color; uniform vec3 night_color;
int linear_search_steps = 10; int linear_search_steps = 10;
@ -79,7 +79,7 @@ void main (void)
vec3 diffuse = gl_Color.rgb * max(0.0, dot(N, l)); vec3 diffuse = gl_Color.rgb * max(0.0, dot(N, l));
float shadow_factor = 1.0; float shadow_factor = 1.0;
// Shadow // Shadow
if ( quality_level >= 3.0 ) { if ( quality_level >= 3.0 ) {
dp += ds * d; dp += ds * d;
vec3 sl = normalize( vec3( dot( l, VTangent ), dot( l, VBinormal ), dot( -l, VNormal ) ) ); vec3 sl = normalize( vec3( dot( l, VTangent ), dot( l, VBinormal ), dot( -l, VNormal ) ) );
@ -89,7 +89,7 @@ void main (void)
if ( dl < d - 0.05 ) if ( dl < d - 0.05 )
shadow_factor = dot( constantColor.xyz, vec3( 1.0, 1.0, 1.0 ) ) * 0.25; shadow_factor = dot( constantColor.xyz, vec3( 1.0, 1.0, 1.0 ) ) * 0.25;
} }
// end shadow // end shadow
vec4 ambient_light = constantColor + gl_LightSource[0].diffuse * vec4(diffuse, 1.0); vec4 ambient_light = constantColor + gl_LightSource[0].diffuse * vec4(diffuse, 1.0);
float reflectance = ambient_light.r * 0.3 + ambient_light.g * 0.59 + ambient_light.b * 0.11; float reflectance = ambient_light.r * 0.3 + ambient_light.g * 0.59 + ambient_light.b * 0.11;