Horde3D http://www.horde3d.org/forums/ |
|
Nitpicking http://www.horde3d.org/forums/viewtopic.php?f=3&t=172 |
Page 1 of 1 |
Author: | slvmnd [ 04.10.2007, 20:26 ] |
Post subject: | Nitpicking |
Just some small things that could be better: 1) All functions in the API which takes const char* crash when called with the null pointer, this is a problem for me because i expose Horde functions to lua scripts and I don't want it to be possible to crash the program no matter what you type in the script files. So for example setNodeName(myModel, 0) should check for null and return false instead of assigning the pointer to a std::string (which crashes in strlen in msvc8). 2) (not in the actual engine) Shadows should not have any components of specularity in them, that looks weird. Fix to lightingUtils_frag.txt: Code: vec3 doLighting( const vec3 pos, const vec3 normal, const vec3 albedo, const float specMask, const float viewDist)
{ vec3 light = lightPos.xyz - pos; // Distance attenuation float lightDist = length( light ) / lightPos.w; float att = 1.0 - lightDist * lightDist; light = normalize( light ); // Spotlight falloff float angle = dot( lightDir, -light ); if( angle > lightCosCutoff ) att *= (angle - lightCosCutoff) / 0.2; else att = 0.0; // Half lambert lighting float NdotL = dot( normal, light ); float diffuse = NdotL * 0.5 + 0.5; diffuse = diffuse * diffuse; // Final color vec3 col = albedo * lightColor * (diffuse + 0.3)*att; // (Diffuse & ambient) color // Shadow if( NdotL > 0.0 && att > 0.0 ) { mat4 lightMat; if( viewDist < shadowSplitDists.x ) lightMat = shadowMats[0]; else if( viewDist < shadowSplitDists.y ) lightMat = shadowMats[1]; else if( viewDist < shadowSplitDists.z ) lightMat = shadowMats[2]; else lightMat = shadowMats[3]; vec4 projShadow = lightMat * vec4( pos, 1.0 ); projShadow.z = lightDist; projShadow.xy /= projShadow.w; float shade = PCF( projShadow ); // Specular vec3 eye = normalize( viewer - pos ); vec3 refl = reflect( -light, normal ); float spec = pow( clamp( dot( refl, eye ), 0.0, 1.0 ), 8.0 ) * specMask; col += vec3( 0.3, 0.3, 0.4 ) * spec * att * shade; col *= max( 0.5, shade ); } return col; } |
Author: | marciano [ 06.10.2007, 11:34 ] |
Post subject: | |
Thanks for your feedback. 1) This thing is already on my TODO list and will be realized for the next release. Should be quite easy to do. 2) Yes right, specular needs to be masked off for shadowed fragments. Thanks! |
Page 1 of 1 | All times are UTC + 1 hour |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |