Updated deferred rendering (STORM-1819 Ternary/Graded shadows)
This commit is contained in:
@@ -10595,7 +10595,7 @@
|
||||
<key>Type</key>
|
||||
<string>U32</string>
|
||||
<key>Value</key>
|
||||
<real>128</real>
|
||||
<real>512</real>
|
||||
</map>
|
||||
|
||||
<key>RenderSpecularResY</key>
|
||||
@@ -10619,7 +10619,7 @@
|
||||
<key>Type</key>
|
||||
<string>F32</string>
|
||||
<key>Value</key>
|
||||
<real>8</real>
|
||||
<real>384</real>
|
||||
</map>
|
||||
|
||||
<key>RenderDeferred</key>
|
||||
|
||||
@@ -128,7 +128,7 @@ void main()
|
||||
|
||||
if (sa > 0.0)
|
||||
{
|
||||
sa = texture2D(lightFunc,vec2(sa, spec.a)).r * min(dist_atten*4.0, 1.0);
|
||||
sa = 6 * texture2D(lightFunc, vec2(sa, spec.a)).r * min(dist_atten*4.0, 1.0);
|
||||
sa *= noise;
|
||||
col += da*sa*light_col[i].rgb*spec.rgb;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ void main()
|
||||
float sa = dot(normalize(lv-normalize(pos)),norm);
|
||||
if (sa > 0.0)
|
||||
{
|
||||
sa = texture2D(lightFunc, vec2(sa, spec.a)).r * min(dist_atten*4.0, 1.0);
|
||||
sa = 6 * texture2D(lightFunc, vec2(sa, spec.a)).r * min(dist_atten*4.0, 1.0);
|
||||
sa *= noise;
|
||||
col += da*sa*color.rgb*spec.rgb;
|
||||
}
|
||||
|
||||
@@ -29,11 +29,11 @@ out vec4 frag_color;
|
||||
#define frag_color gl_FragColor
|
||||
#endif
|
||||
|
||||
uniform float minimum_alpha;
|
||||
|
||||
uniform sampler2D diffuseMap;
|
||||
|
||||
VARYING vec4 post_pos;
|
||||
VARYING float pos_zd2;
|
||||
VARYING float pos_w;
|
||||
VARYING float target_pos_x;
|
||||
VARYING vec4 vertex_color;
|
||||
VARYING vec2 vary_texcoord0;
|
||||
|
||||
@@ -41,12 +41,20 @@ void main()
|
||||
{
|
||||
float alpha = diffuseLookup(vary_texcoord0.xy).a * vertex_color.a;
|
||||
|
||||
if (alpha < minimum_alpha)
|
||||
if (alpha < 0.05) // treat as totally transparent
|
||||
{
|
||||
discard;
|
||||
}
|
||||
|
||||
if (alpha < 0.88) // treat as semi-transparent
|
||||
{
|
||||
if (fract(0.5*floor(target_pos_x / pos_w )) < 0.25)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
}
|
||||
|
||||
frag_color = vec4(1,1,1,1);
|
||||
|
||||
gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0);
|
||||
gl_FragDepth = max(pos_zd2/pos_w+0.5, 0.0);
|
||||
}
|
||||
|
||||
@@ -25,12 +25,15 @@
|
||||
|
||||
uniform mat4 texture_matrix0;
|
||||
uniform mat4 modelview_projection_matrix;
|
||||
uniform float shadow_target_width;
|
||||
|
||||
ATTRIBUTE vec3 position;
|
||||
ATTRIBUTE vec4 diffuse_color;
|
||||
ATTRIBUTE vec2 texcoord0;
|
||||
|
||||
VARYING vec4 post_pos;
|
||||
VARYING float pos_zd2;
|
||||
VARYING float pos_w;
|
||||
VARYING float target_pos_x;
|
||||
VARYING vec4 vertex_color;
|
||||
VARYING vec2 vary_texcoord0;
|
||||
|
||||
@@ -39,8 +42,11 @@ void passTextureIndex();
|
||||
void main()
|
||||
{
|
||||
//transform vertex
|
||||
vec4 pos = modelview_projection_matrix*vec4(position.xyz, 1.0);
|
||||
post_pos = pos;
|
||||
vec4 pre_pos = vec4(position.xyz, 1.0);
|
||||
vec4 pos = modelview_projection_matrix * pre_pos;
|
||||
target_pos_x = 0.5 * (shadow_target_width - 1.0) * pos.x;
|
||||
pos_w = pos.w;
|
||||
pos_zd2 = pos.z * 0.5;
|
||||
|
||||
gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w);
|
||||
|
||||
|
||||
@@ -301,11 +301,11 @@ void main()
|
||||
//
|
||||
vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
|
||||
float sa = dot(refnormpersp, sun_dir.xyz);
|
||||
vec3 dumbshiny = vary_SunlitColor*texture2D(lightFunc, vec2(sa, spec.a)).r;
|
||||
vec3 dumbshiny = vary_SunlitColor*(6 * texture2D(lightFunc, vec2(sa, spec.a)).r);
|
||||
|
||||
// add the two types of shiny together
|
||||
vec3 spec_contrib = dumbshiny * spec.rgb;
|
||||
bloom = dot(spec_contrib, spec_contrib);
|
||||
bloom = dot(spec_contrib, spec_contrib) / 4;
|
||||
col += spec_contrib;
|
||||
|
||||
//add environmentmap
|
||||
|
||||
Reference in New Issue
Block a user