Converted tabs to four spaces

This commit is contained in:
Robert Osfield
2008-10-06 08:58:50 +00:00
parent 236832f669
commit 45085f3eea
7 changed files with 328 additions and 328 deletions

View File

@@ -106,163 +106,163 @@ StandardShadowMap::StandardShadowMap():
"const int NumEnabledLights = 1; \n"
" \n"
"void DynamicShadow( in vec4 ecPosition ); \n"
" \n"
" \n"
"varying vec4 colorAmbientEmissive; \n"
" \n"
"void SpotLight(in int i, \n"
" in vec3 eye, \n"
" in vec3 ecPosition3, \n"
" in vec3 normal, \n"
" in vec3 eye, \n"
" in vec3 ecPosition3, \n"
" in vec3 normal, \n"
" inout vec4 ambient, \n"
" inout vec4 diffuse, \n"
" inout vec4 specular) \n"
"{ \n"
" inout vec4 diffuse, \n"
" inout vec4 specular) \n"
"{ \n"
" float nDotVP; // normal . light direction \n"
" float nDotHV; // normal . light half vector \n"
" float pf; // power factor \n"
" float spotDot; // cosine of angle between spotlight \n"
" float nDotHV; // normal . light half vector \n"
" float pf; // power factor \n"
" float spotDot; // cosine of angle between spotlight \n"
" float spotAttenuation; // spotlight attenuation factor \n"
" float attenuation; // computed attenuation factor \n"
" float d; // distance from surface to light source \n"
" float attenuation; // computed attenuation factor \n"
" float d; // distance from surface to light source \n"
" vec3 VP; // direction from surface to light position \n"
" vec3 halfVector; // direction of maximum highlights \n"
" \n"
" // Compute vector from surface to light position \n"
" VP = vec3(gl_LightSource[i].position) - ecPosition3; \n"
" \n"
" // Compute vector from surface to light position \n"
" VP = vec3(gl_LightSource[i].position) - ecPosition3; \n"
" \n"
" // Compute distance between surface and light position \n"
" d = length(VP); \n"
" \n"
" // Compute distance between surface and light position \n"
" d = length(VP); \n"
" \n"
" // Normalize the vector from surface to light position \n"
" VP = normalize(VP); \n"
" \n"
" // Compute attenuation \n"
" VP = normalize(VP); \n"
" \n"
" // Compute attenuation \n"
" attenuation = 1.0 / (gl_LightSource[i].constantAttenuation + \n"
" gl_LightSource[i].linearAttenuation * d + \n"
" gl_LightSource[i].linearAttenuation * d + \n"
" gl_LightSource[i].quadraticAttenuation *d*d); \n"
" \n"
" \n"
" // See if point on surface is inside cone of illumination \n"
" spotDot = dot(-VP, normalize(gl_LightSource[i].spotDirection)); \n"
" \n"
" if (spotDot < gl_LightSource[i].spotCosCutoff) \n"
" spotAttenuation = 0.0; // light adds no contribution \n"
" else \n"
" spotDot = dot(-VP, normalize(gl_LightSource[i].spotDirection)); \n"
" \n"
" if (spotDot < gl_LightSource[i].spotCosCutoff) \n"
" spotAttenuation = 0.0; // light adds no contribution \n"
" else \n"
" spotAttenuation = pow(spotDot, gl_LightSource[i].spotExponent);\n"
" \n"
" // Combine the spotlight and distance attenuation. \n"
" attenuation *= spotAttenuation; \n"
" \n"
" halfVector = normalize(VP + eye); \n"
" \n"
" nDotVP = max(0.0, dot(normal, VP)); \n"
" nDotHV = max(0.0, dot(normal, halfVector)); \n"
" \n"
" \n"
" // Combine the spotlight and distance attenuation. \n"
" attenuation *= spotAttenuation; \n"
" \n"
" halfVector = normalize(VP + eye); \n"
" \n"
" nDotVP = max(0.0, dot(normal, VP)); \n"
" nDotHV = max(0.0, dot(normal, halfVector)); \n"
" \n"
" if (nDotVP == 0.0) \n"
" pf = 0.0; \n"
" else \n"
" pf = pow(nDotHV, gl_FrontMaterial.shininess); \n"
" \n"
" ambient += gl_LightSource[i].ambient * attenuation; \n"
" diffuse += gl_LightSource[i].diffuse * nDotVP * attenuation; \n"
" specular += gl_LightSource[i].specular * pf * attenuation; \n"
"} \n"
" \n"
"void PointLight(in int i, \n"
" in vec3 eye, \n"
" in vec3 ecPosition3, \n"
" in vec3 normal, \n"
" inout vec4 ambient, \n"
" inout vec4 diffuse, \n"
" pf = 0.0; \n"
" else \n"
" pf = pow(nDotHV, gl_FrontMaterial.shininess); \n"
" \n"
" ambient += gl_LightSource[i].ambient * attenuation; \n"
" diffuse += gl_LightSource[i].diffuse * nDotVP * attenuation; \n"
" specular += gl_LightSource[i].specular * pf * attenuation; \n"
"} \n"
" \n"
"void PointLight(in int i, \n"
" in vec3 eye, \n"
" in vec3 ecPosition3, \n"
" in vec3 normal, \n"
" inout vec4 ambient, \n"
" inout vec4 diffuse, \n"
" inout vec4 specular) \n"
"{ \n"
" float nDotVP; // normal . light direction \n"
" float nDotHV; // normal . light half vector \n"
" float pf; // power factor \n"
" float attenuation; // computed attenuation factor \n"
" float d; // distance from surface to light source \n"
" vec3 VP; // direction from surface to light position \n"
" vec3 halfVector; // direction of maximum highlights \n"
" \n"
" // Compute vector from surface to light position \n"
" VP = vec3(gl_LightSource[i].position) - ecPosition3; \n"
" \n"
" // Compute distance between surface and light position \n"
" d = length(VP); \n"
" \n"
"{ \n"
" float nDotVP; // normal . light direction \n"
" float nDotHV; // normal . light half vector \n"
" float pf; // power factor \n"
" float attenuation; // computed attenuation factor \n"
" float d; // distance from surface to light source \n"
" vec3 VP; // direction from surface to light position \n"
" vec3 halfVector; // direction of maximum highlights \n"
" \n"
" // Compute vector from surface to light position \n"
" VP = vec3(gl_LightSource[i].position) - ecPosition3; \n"
" \n"
" // Compute distance between surface and light position \n"
" d = length(VP); \n"
" \n"
" // Normalize the vector from surface to light position \n"
" VP = normalize(VP); \n"
" \n"
" // Compute attenuation \n"
" attenuation = 1.0 / (gl_LightSource[i].constantAttenuation + \n"
" gl_LightSource[i].linearAttenuation * d + \n"
" VP = normalize(VP); \n"
" \n"
" // Compute attenuation \n"
" attenuation = 1.0 / (gl_LightSource[i].constantAttenuation + \n"
" gl_LightSource[i].linearAttenuation * d + \n"
" gl_LightSource[i].quadraticAttenuation * d*d);\n"
" \n"
" halfVector = normalize(VP + eye); \n"
" \n"
" nDotVP = max(0.0, dot(normal, VP)); \n"
" nDotHV = max(0.0, dot(normal, halfVector)); \n"
" \n"
" if (nDotVP == 0.0) \n"
" pf = 0.0; \n"
" else \n"
" \n"
" halfVector = normalize(VP + eye); \n"
" \n"
" nDotVP = max(0.0, dot(normal, VP)); \n"
" nDotHV = max(0.0, dot(normal, halfVector)); \n"
" \n"
" if (nDotVP == 0.0) \n"
" pf = 0.0; \n"
" else \n"
" pf = pow(nDotHV, gl_FrontMaterial.shininess); \n"
" \n"
" ambient += gl_LightSource[i].ambient * attenuation; \n"
" diffuse += gl_LightSource[i].diffuse * nDotVP * attenuation; \n"
" specular += gl_LightSource[i].specular * pf * attenuation; \n"
"} \n"
" \n"
"void DirectionalLight(in int i, \n"
" in vec3 normal, \n"
" inout vec4 ambient, \n"
" inout vec4 diffuse, \n"
" inout vec4 specular) \n"
"{ \n"
" float nDotVP; // normal . light direction \n"
" float nDotHV; // normal . light half vector \n"
" float pf; // power factor \n"
" \n"
" nDotVP = max(0.0, dot(normal, \n"
" normalize(vec3(gl_LightSource[i].position)))); \n"
" nDotHV = max(0.0, dot(normal, \n"
" vec3(gl_LightSource[i].halfVector))); \n"
" \n"
" if (nDotVP == 0.0) \n"
" pf = 0.0; \n"
" else \n"
" pf = pow(nDotHV, gl_FrontMaterial.shininess); \n"
" \n"
" ambient += gl_LightSource[i].ambient; \n"
" diffuse += gl_LightSource[i].diffuse * nDotVP; \n"
" specular += gl_LightSource[i].specular * pf; \n"
"} \n"
" \n"
"void main( ) \n"
"{ \n"
" // Transform vertex to clip space \n"
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; \n"
" vec3 normal = normalize( gl_NormalMatrix * gl_Normal ); \n"
" \n"
" vec4 ecPos = gl_ModelViewMatrix * gl_Vertex; \n"
" \n"
" ambient += gl_LightSource[i].ambient * attenuation; \n"
" diffuse += gl_LightSource[i].diffuse * nDotVP * attenuation; \n"
" specular += gl_LightSource[i].specular * pf * attenuation; \n"
"} \n"
" \n"
"void DirectionalLight(in int i, \n"
" in vec3 normal, \n"
" inout vec4 ambient, \n"
" inout vec4 diffuse, \n"
" inout vec4 specular) \n"
"{ \n"
" float nDotVP; // normal . light direction \n"
" float nDotHV; // normal . light half vector \n"
" float pf; // power factor \n"
" \n"
" nDotVP = max(0.0, dot(normal, \n"
" normalize(vec3(gl_LightSource[i].position)))); \n"
" nDotHV = max(0.0, dot(normal, \n"
" vec3(gl_LightSource[i].halfVector))); \n"
" \n"
" if (nDotVP == 0.0) \n"
" pf = 0.0; \n"
" else \n"
" pf = pow(nDotHV, gl_FrontMaterial.shininess); \n"
" \n"
" ambient += gl_LightSource[i].ambient; \n"
" diffuse += gl_LightSource[i].diffuse * nDotVP; \n"
" specular += gl_LightSource[i].specular * pf; \n"
"} \n"
" \n"
"void main( ) \n"
"{ \n"
" // Transform vertex to clip space \n"
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; \n"
" vec3 normal = normalize( gl_NormalMatrix * gl_Normal ); \n"
" \n"
" vec4 ecPos = gl_ModelViewMatrix * gl_Vertex; \n"
" float ecLen = length( ecPos ); \n"
" vec3 ecPosition3 = ecPos.xyz / ecPos.w; \n"
" \n"
" vec3 eye = vec3( 0.0, 0.0, 1.0 ); \n"
" //vec3 eye = -normalize(ecPosition3); \n"
" \n"
" DynamicShadow( ecPos ); \n"
" \n"
" gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; \n"
" \n"
" // Front Face lighting \n"
" \n"
" // Clear the light intensity accumulators \n"
" vec4 amb = vec4(0.0); \n"
" vec4 diff = vec4(0.0); \n"
" vec4 spec = vec4(0.0); \n"
" \n"
" // Loop through enabled lights, compute contribution from each \n"
" for (int i = 0; i < NumEnabledLights; i++) \n"
" DynamicShadow( ecPos ); \n"
" \n"
" gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; \n"
" \n"
" // Front Face lighting \n"
" \n"
" // Clear the light intensity accumulators \n"
" vec4 amb = vec4(0.0); \n"
" vec4 diff = vec4(0.0); \n"
" vec4 spec = vec4(0.0); \n"
" \n"
" // Loop through enabled lights, compute contribution from each \n"
" for (int i = 0; i < NumEnabledLights; i++) \n"
" { \n"
" if (gl_LightSource[i].position.w == 0.0) \n"
" DirectionalLight(i, normal, amb, diff, spec); \n"
@@ -272,20 +272,20 @@ StandardShadowMap::StandardShadowMap():
" SpotLight(i, eye, ecPosition3, normal, amb, diff, spec); \n"
" } \n"
" \n"
" colorAmbientEmissive = gl_FrontLightModelProduct.sceneColor + \n"
" colorAmbientEmissive = gl_FrontLightModelProduct.sceneColor + \n"
" amb * gl_FrontMaterial.ambient; \n"
" \n"
" gl_FrontColor = colorAmbientEmissive + \n"
" diff * gl_FrontMaterial.diffuse; \n"
" \n"
" gl_FrontSecondaryColor = vec4(spec*gl_FrontMaterial.specular); \n"
" \n"
" gl_BackColor = gl_FrontColor; \n"
" gl_BackSecondaryColor = gl_FrontSecondaryColor; \n"
" \n"
" gl_FogFragCoord = ecLen; \n"
"} \n" );
}
" \n"
" gl_FrontSecondaryColor = vec4(spec*gl_FrontMaterial.specular); \n"
" \n"
" gl_BackColor = gl_FrontColor; \n"
" gl_BackSecondaryColor = gl_FrontSecondaryColor; \n"
" \n"
" gl_FogFragCoord = ecLen; \n"
"} \n" );
}
StandardShadowMap::StandardShadowMap
(const StandardShadowMap& copy, const osg::CopyOp& copyop) :
@@ -313,10 +313,10 @@ StandardShadowMap::StandardShadowMap
( copy._shadowFragmentShader->clone(copyop) );
}
StandardShadowMap::~StandardShadowMap(void)
{
StandardShadowMap::~StandardShadowMap(void)
{
}
}
void StandardShadowMap::updateTextureCoordIndices
( unsigned int fromTextureCoordIndex, unsigned int toTextureCoordIndex )
@@ -455,10 +455,10 @@ void StandardShadowMap::ViewData::init( ThisClass *st, osgUtil::CullVisitor *cv
_camera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
_camera->setClearColor( osg::Vec4(1.0f,1.0f,1.0f,1.0f) );
#endif
_camera->setComputeNearFarMode(osg::Camera::DO_NOT_COMPUTE_NEAR_FAR);
_camera->setComputeNearFarMode(osg::Camera::DO_NOT_COMPUTE_NEAR_FAR);
_camera->setViewport(0,0, st->_textureSize.x(), st->_textureSize.y() );
_camera->setRenderOrder(osg::Camera::PRE_RENDER);
_camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
_camera->setRenderOrder(osg::Camera::PRE_RENDER);
_camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
_camera->attach(osg::Camera::DEPTH_BUFFER, _texture.get());
}
@@ -490,7 +490,7 @@ void StandardShadowMap::ViewData::init( ThisClass *st, osgUtil::CullVisitor *cv
_stateset->setTextureMode(st->_shadowTextureUnit,GL_TEXTURE_GEN_Q,osg::StateAttribute::ON);
}
{ // Setup shaders used in shadow casting
{ // Setup shaders used in shadow casting
osg::Program * program = new osg::Program();
_stateset->setAttribute( program );
@@ -558,7 +558,7 @@ void StandardShadowMap::ViewData::init( ThisClass *st, osgUtil::CullVisitor *cv
#if 0
stateset->setMode
( GL_ALPHA_TEST, osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF );
#endif
#endif
#if 0 // fixed pipeline seems faster (at least on my 7800)
program->addShader( new osg::Shader( osg::Shader::FRAGMENT,
@@ -625,7 +625,7 @@ const osg::Light* StandardShadowMap::ViewData::selectLight
if( lightPos[3] == 0 )
lightDir.set( -lightPos[0], -lightPos[1], -lightPos[2] );
else
lightDir = light->getDirection();
lightDir = light->getDirection();
lightPos = lightPos * localToWorld;
lightDir = osg::Matrix::transform3x3( lightDir, localToWorld );
@@ -731,7 +731,7 @@ void StandardShadowMap::ViewData::cullShadowReceivingScene( )
}
void StandardShadowMap::ViewData::cullShadowCastingScene( )
{
{
// record the traversal mask on entry so we can reapply it later.
unsigned int traversalMask = _cv->getTraversalMask();