Micro-optimization and unneeded code removal

This commit is contained in:
yvt 2014-02-04 00:04:27 +09:00
parent 04b06b2e73
commit c0b8e6d783
7 changed files with 5 additions and 53 deletions

View File

@ -58,22 +58,13 @@ void main() {
color.xyz *= color.xyz; // linearize
// ambient occlusion
ambientOcclusionCoord = (ambientOcclusionCoordAttribute + .5) / 256.;
ambientOcclusionCoord = (ambientOcclusionCoordAttribute + .5) * (1. / 256.);
vec4 viewPos = viewMatrix * vertexPos;
/*float distance = length(viewPos.xyz) / fogDistance;
distance = clamp(distance, 0., 1.);
fogDensity = vec3(distance);
fogDensity = pow(fogDensity, vec3(1., .9, .7));
fogDensity *= fogDensity;*/
float distance = dot(viewPos.xyz, viewPos.xyz);
fogDensity = FogDensity(distance).xyz;
/*
detailCoord = (vec2(dot(tan1, vertexPos.xyz), dot(tan2, vertexPos.xyz))) / 2.;
*/
vec3 normal = normalAttribute; //cross(tan2, tan1);
vec3 normal = normalAttribute;
vec3 shadowVertexPos = vertexPos.xyz;
if(abs(normal.x) > .1) // avoid self shadowing
shadowVertexPos += normal * 0.01;

View File

@ -54,19 +54,10 @@ void main() {
color.xyz *= color.xyz; // linearize
vec4 viewPos = viewMatrix * vertexPos;
/*float distance = length(viewPos.xyz) / fogDistance;
distance = clamp(distance, 0., 1.);
fogDensity = vec3(distance);
fogDensity = pow(fogDensity, vec3(1., .9, .7));
fogDensity *= fogDensity;*/
float distance = dot(viewPos.xyz, viewPos.xyz);
fogDensity = FogDensity(distance).xyz;
/*
detailCoord = (vec2(dot(tan1, vertexPos.xyz), dot(tan2, vertexPos.xyz))) / 2.;
*/
vec3 normal = normalAttribute; //cross(tan2, tan1);
vec3 normal = normalAttribute;
vec3 shadowVertexPos = vertexPos.xyz;
PrepareForDynamicLightNoBump(shadowVertexPos, normal);

View File

@ -65,24 +65,13 @@ void main() {
// ambient occlusion
ambientOcclusionCoord = (ambientOcclusionCoordAttribute + .5) / 256.;
ambientOcclusionCoord = (ambientOcclusionCoordAttribute + .5) * (1. / 256.);
vec4 viewPos = viewMatrix * vertexPos;
/*
float distance = length(viewPos.xyz) / fogDistance;
distance = clamp(distance, 0., 1.);
fogDensity = vec3(distance);
fogDensity = pow(fogDensity, vec3(1., .9, .7));
fogDensity *= fogDensity;
*/
float distance = dot(viewPos.xyz, viewPos.xyz);
fogDensity = FogDensity(distance).xyz;
/*
detailCoord = (vec2(dot(tan1, vertexPos.xyz), dot(tan2, vertexPos.xyz))) / 2.;
*/
vec3 normal = normalAttribute; //cross(tan2, tan1);
vec3 normal = normalAttribute;
vec3 shadowVertexPos = vertexPos.xyz;
if(abs(normal.x) > .1) // avoid self shadowing
shadowVertexPos += normal * 0.01;

View File

@ -49,11 +49,6 @@ void main() {
// FIXME: cannot gamma correct because sprite may be
// alpha-blended.
vec4 viewPos = viewMatrix * vec4(pos,1.);
/*float distance = length(viewPos.xyz) / fogDistance;
distance = clamp(distance, 0., 1.);
fogDensity = vec4(distance);
fogDensity = pow(fogDensity, vec4(1., .9, .7, 1.));
fogDensity *= fogDensity;*/
float distance = dot(viewPos.xyz, viewPos.xyz);
fogDensity = FogDensity(distance);
}

View File

@ -65,7 +65,6 @@ void main() {
sunlight = max(sunlight, 0.);
flatShading = sunlight;
vec4 viewPos = viewModelMatrix * vertexPos;
float distance = dot(viewPos.xyz, viewPos.xyz);
fogDensity = FogDensity(distance).xyz;

View File

@ -103,16 +103,9 @@ void main() {
// FIXME: cannot gamma correct because sprite may be
// alpha-blended.
vec4 viewPos = viewMatrix * vec4(pos,1.);
/*float distance = length(viewPos.xyz) / fogDistance;
distance = clamp(distance, 0., 1.);
fogDensity = vec4(distance);
fogDensity = pow(fogDensity, vec4(1., .9, .7, 1.));
fogDensity *= fogDensity; */
float distance = dot(viewPos.xyz, viewPos.xyz);
fogDensity = FogDensity(distance);
// precompute some value in vertex shader to
// reduce instruction count in frag. shader
depthRange.z = 1. / (depthRange.y - depthRange.w);

View File

@ -86,12 +86,6 @@ void main() {
// fog.
// FIXME: cannot gamma correct because sprite may be
// alpha-blended.
/*vec4 viewPos = viewMatrix * vec4(pos,1.);
float distance = length(viewPos.xyz) / fogDistance;
distance = clamp(distance, 0., 1.);
fogDensity = vec4(distance);
fogDensity = pow(fogDensity, vec4(1., .9, .7, 1.));
fogDensity *= fogDensity;*/
float distance = dot(viewPos.xyz, viewPos.xyz);
fogDensity = FogDensity(distance);