Use quality level inside landmass fragment shader
This commit is contained in:
parent
714c500fa9
commit
1a986d8747
3 changed files with 38 additions and 21 deletions
|
@ -13,6 +13,7 @@
|
|||
<snow-level><use>/sim/rendering/snow-level-m</use></snow-level>
|
||||
<depth-factor type="float">0.01</depth-factor>
|
||||
<canopy-height type="float">15.0</canopy-height>
|
||||
<quality-level><use>/sim/rendering/quality-level</use></quality-level>
|
||||
</parameters>
|
||||
<generate>
|
||||
<tangent type="int">6</tangent>
|
||||
|
@ -128,6 +129,11 @@
|
|||
<type>float</type>
|
||||
<value><use>canopy-height</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>quality_level</name>
|
||||
<type>float</type>
|
||||
<value><use>quality-level</use></value>
|
||||
</uniform>
|
||||
</pass>
|
||||
</technique>
|
||||
<technique n="9">
|
||||
|
@ -230,6 +236,11 @@
|
|||
<type>float</type>
|
||||
<value><use>snow-level</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>quality_level</name>
|
||||
<type>float</type>
|
||||
<value><use>quality-level</use></value>
|
||||
</uniform>
|
||||
</pass>
|
||||
</technique>
|
||||
</PropertyList>
|
||||
|
|
|
@ -13,13 +13,14 @@ uniform sampler3D NoiseTex;
|
|||
uniform sampler2D BaseTex;
|
||||
uniform sampler2D NormalTex;
|
||||
uniform float depth_factor;
|
||||
uniform float quality_level; // From /sim/rendering/quality-level
|
||||
uniform float snowlevel; // From /sim/rendering/snow-level-m
|
||||
|
||||
const float scale = 1.0;
|
||||
int linear_search_steps = 10;
|
||||
|
||||
float ray_intersect(sampler2D reliefMap, vec2 dp, vec2 ds)
|
||||
{
|
||||
const int linear_search_steps = 10;
|
||||
|
||||
float size = 1.0 / float(linear_search_steps);
|
||||
float depth = 0.0;
|
||||
|
@ -54,17 +55,21 @@ float ray_intersect(sampler2D reliefMap, vec2 dp, vec2 ds)
|
|||
|
||||
void main (void)
|
||||
{
|
||||
vec2 uv;
|
||||
if ( quality_level >= 3.5 ) {
|
||||
linear_search_steps = 20;
|
||||
}
|
||||
vec2 uv, dp, ds;
|
||||
vec3 N;
|
||||
if ( bump > 0.9 )
|
||||
float d;
|
||||
if ( bump > 0.9 && quality_level >= 2.0 )
|
||||
{
|
||||
vec3 V = normalize(ecPosition.xyz);
|
||||
float a = dot(VNormal, -V);
|
||||
vec2 s = vec2(dot(V, VTangent), dot(V, VBinormal));
|
||||
s *= depth_factor / a;
|
||||
vec2 ds = s;
|
||||
vec2 dp = gl_TexCoord[0].st;
|
||||
float d = ray_intersect(NormalTex, dp, ds);
|
||||
ds = s;
|
||||
dp = gl_TexCoord[0].st;
|
||||
d = ray_intersect(NormalTex, dp, ds);
|
||||
|
||||
uv = dp + ds * d;
|
||||
N = texture2D(NormalTex, uv).xyz * 2.0 - 1.0;
|
||||
|
@ -75,7 +80,6 @@ void main (void)
|
|||
N = vec3(0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
|
||||
vec4 noisevec = texture3D(NoiseTex, (rawpos.xyz)*0.01*scale);
|
||||
vec4 nvL = texture3D(NoiseTex, (rawpos.xyz)*0.00066*scale);
|
||||
|
||||
|
@ -109,17 +113,19 @@ void main (void)
|
|||
vec3 l = gl_LightSource[0].position.xyz;
|
||||
vec3 diffuse = gl_Color.rgb * max(0.0, dot(N, l));
|
||||
float shadow_factor = 1.0;
|
||||
/*
|
||||
// Shadow
|
||||
dp += ds * d;
|
||||
vec3 sl = normalize( vec3( dot( l, VTangent ), dot( l, VBinormal ), dot( -l, VNormal ) ) );
|
||||
ds = sl.xy * depth_factor / sl.z;
|
||||
dp -= ds * d;
|
||||
float dl = ray_intersect(NormalTex, dp, ds);
|
||||
if ( dl < d - 0.05 )
|
||||
shadow_factor = dot( constantColor.xyz, vec3( 1.0, 1.0, 1.0 ) ) * 0.25;
|
||||
// end shadow
|
||||
*/
|
||||
|
||||
// Shadow
|
||||
if ( quality_level >= 3.0 ) {
|
||||
dp += ds * d;
|
||||
vec3 sl = normalize( vec3( dot( l, VTangent ), dot( l, VBinormal ), dot( -l, VNormal ) ) );
|
||||
ds = sl.xy * depth_factor / sl.z;
|
||||
dp -= ds * d;
|
||||
float dl = ray_intersect(NormalTex, dp, ds);
|
||||
if ( dl < d - 0.05 )
|
||||
shadow_factor = dot( constantColor.xyz, vec3( 1.0, 1.0, 1.0 ) ) * 0.25;
|
||||
}
|
||||
// end shadow
|
||||
|
||||
vec4 ambient_light = constantColor + gl_LightSource[0].diffuse * shadow_factor * vec4(diffuse, 1.0);
|
||||
|
||||
c1 *= ambient_light;
|
||||
|
|
|
@ -17,7 +17,7 @@ uniform sampler2D BaseTex;
|
|||
uniform sampler2D NormalTex;
|
||||
uniform float depth_factor;
|
||||
uniform float tile_size;
|
||||
uniform float quality_level;
|
||||
uniform float quality_level; // From /sim/rendering/quality-level
|
||||
uniform vec3 night_color;
|
||||
|
||||
int linear_search_steps = 10;
|
||||
|
@ -79,7 +79,7 @@ void main (void)
|
|||
vec3 diffuse = gl_Color.rgb * max(0.0, dot(N, l));
|
||||
float shadow_factor = 1.0;
|
||||
|
||||
// Shadow
|
||||
// Shadow
|
||||
if ( quality_level >= 3.0 ) {
|
||||
dp += ds * d;
|
||||
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 )
|
||||
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);
|
||||
float reflectance = ambient_light.r * 0.3 + ambient_light.g * 0.59 + ambient_light.b * 0.11;
|
||||
|
|
Loading…
Reference in a new issue