Skip to content
Snippets Groups Projects
Commit e1db8d41 authored by David Parks's avatar David Parks
Browse files
parents d9e8ee7c dc38ef5d
No related branches found
No related tags found
No related merge requests found
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
ATTRIBUTE vec4 weight4; ATTRIBUTE vec4 weight4;
uniform mat4 matrixPalette[64]; uniform mat4 matrixPalette[32];
mat4 getObjectSkinnedTransform() mat4 getObjectSkinnedTransform()
{ {
......
...@@ -121,7 +121,7 @@ vec3 calcDirectionalLight(vec3 n, vec3 l) ...@@ -121,7 +121,7 @@ vec3 calcDirectionalLight(vec3 n, vec3 l)
} }
vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spec, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spec, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, inout float glare)
{ {
//get light vector //get light vector
vec3 lv = lp.xyz-v; vec3 lv = lp.xyz-v;
...@@ -169,7 +169,13 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe ...@@ -169,7 +169,13 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe
if (nh > 0.0) if (nh > 0.0)
{ {
float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da);
col += lit*scol*light_col.rgb*spec.rgb; vec3 speccol = lit*scol*light_col.rgb*spec.rgb;
col += speccol;
float cur_glare = max(speccol.r, speccol.g);
cur_glare = max(cur_glare, speccol.b);
glare = max(glare, speccol.r);
glare += max(cur_glare, 0.0);
//col += spec.rgb; //col += spec.rgb;
} }
} }
...@@ -442,7 +448,7 @@ void main() ...@@ -442,7 +448,7 @@ void main()
#endif #endif
#if HAS_SPECULAR_MAP #if HAS_SPECULAR_MAP
vec4 spec = texture2D(specularMap, vary_texcoord2.xy); vec4 spec = texture2D(specularMap, vary_texcoord2.xy)*specular_color;
#else #else
vec4 spec = specular_color; vec4 spec = specular_color;
#endif #endif
...@@ -472,7 +478,7 @@ void main() ...@@ -472,7 +478,7 @@ void main()
vec4 final_specular = spec; vec4 final_specular = spec;
#if HAS_SPECULAR_MAP #if HAS_SPECULAR_MAP
//final_color.rgb *= 1 - spec.a * env_intensity; //final_color.rgb *= 1 - spec.a * env_intensity;
final_specular.rgb *= specular_color.rgb; //final_specular.rgb *= specular_color.rgb;
vec4 final_normal = vec4(encode_normal(normalize(tnorm)), spec.a * env_intensity, 0.0); vec4 final_normal = vec4(encode_normal(normalize(tnorm)), spec.a * env_intensity, 0.0);
final_specular.a = specular_color.a * norm.a; final_specular.a = specular_color.a * norm.a;
...@@ -577,6 +583,8 @@ void main() ...@@ -577,6 +583,8 @@ void main()
col.rgb *= diffuse.rgb; col.rgb *= diffuse.rgb;
float glare = 0.0;
if (spec.a > 0.0) // specular reflection if (spec.a > 0.0) // specular reflection
{ {
// the old infinite-sky shiny reflection // the old infinite-sky shiny reflection
...@@ -588,6 +596,10 @@ void main() ...@@ -588,6 +596,10 @@ void main()
// add the two types of shiny together // add the two types of shiny together
vec3 spec_contrib = dumbshiny * spec.rgb; vec3 spec_contrib = dumbshiny * spec.rgb;
bloom = dot(spec_contrib, spec_contrib) / 6; bloom = dot(spec_contrib, spec_contrib) / 6;
glare = max(spec_contrib.r, spec_contrib.g);
glare = max(glare, spec_contrib.b);
col += spec_contrib; col += spec_contrib;
} }
...@@ -595,8 +607,15 @@ void main() ...@@ -595,8 +607,15 @@ void main()
{ {
//add environmentmap //add environmentmap
vec3 env_vec = env_mat * refnormpersp; vec3 env_vec = env_mat * refnormpersp;
col = mix(col.rgb, pow(textureCube(environmentMap, env_vec).rgb, vec3(2.2)) * 2.2, vec3 refcol = pow(textureCube(environmentMap, env_vec).rgb, vec3(2.2)) * 2.2;
col = mix(col.rgb, refcol,
max(envIntensity-diffuse.a*2.0, 0.0)); max(envIntensity-diffuse.a*2.0, 0.0));
float cur_glare = max(refcol.r, refcol.g);
cur_glare = max(cur_glare, refcol.b);
cur_glare *= envIntensity*4.0;
glare += cur_glare;
} }
col = atmosLighting(col); col = atmosLighting(col);
...@@ -604,18 +623,19 @@ void main() ...@@ -604,18 +623,19 @@ void main()
vec3 npos = normalize(-pos.xyz); vec3 npos = normalize(-pos.xyz);
#define LIGHT_LOOP(i) col.rgb = col.rgb + calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse.rgb, final_specular, pos.xyz, norm.xyz, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); #define LIGHT_LOOP(i) col.rgb = col.rgb + calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse.rgb, final_specular, pos.xyz, norm.xyz, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, glare);
LIGHT_LOOP(1) /*LIGHT_LOOP(1)
LIGHT_LOOP(2) LIGHT_LOOP(2)
LIGHT_LOOP(3) LIGHT_LOOP(3)
LIGHT_LOOP(4) LIGHT_LOOP(4)
LIGHT_LOOP(5) LIGHT_LOOP(5)
LIGHT_LOOP(6) LIGHT_LOOP(6)
LIGHT_LOOP(7) LIGHT_LOOP(7)*/
frag_color.rgb = col.rgb; frag_color.rgb = col.rgb;
frag_color.a = diffcol.a*vertex_color.a; glare = min(glare, 1.0);
frag_color.a = max(diffcol.a*vertex_color.a, glare);
#else #else
frag_data[0] = final_color; frag_data[0] = final_color;
......
...@@ -442,7 +442,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) ...@@ -442,7 +442,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
LLMaterial* mat = NULL; LLMaterial* mat = NULL;
if (deferred_render && !LLPipeline::sUnderWaterRender) if (!params.mFullbright && deferred_render && !LLPipeline::sUnderWaterRender)
{ {
mat = params.mMaterial; mat = params.mMaterial;
} }
......
...@@ -1587,9 +1587,11 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow) ...@@ -1587,9 +1587,11 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow)
{ {
if (sShaderLevel > 0) if (sShaderLevel > 0)
{ //upload matrix palette to shader { //upload matrix palette to shader
LLMatrix4 mat[64]; LLMatrix4 mat[32];
for (U32 i = 0; i < skin->mJointNames.size(); ++i) U32 count = llmin((U32) skin->mJointNames.size(), (U32) 32);
for (U32 i = 0; i < count; ++i)
{ {
LLJoint* joint = avatar->getJoint(skin->mJointNames[i]); LLJoint* joint = avatar->getJoint(skin->mJointNames[i]);
if (joint) if (joint)
...@@ -1602,7 +1604,7 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow) ...@@ -1602,7 +1604,7 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow)
stop_glerror(); stop_glerror();
LLDrawPoolAvatar::sVertexProgram->uniformMatrix4fv("matrixPalette", LLDrawPoolAvatar::sVertexProgram->uniformMatrix4fv("matrixPalette",
skin->mJointNames.size(), count,
FALSE, FALSE,
(GLfloat*) mat[0].mMatrix); (GLfloat*) mat[0].mMatrix);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment