SO3Engine
|
SO3ShaderGeneratorCG.cpp
Go to the documentation of this file.
20SShaderGeneratorCG::SShaderGeneratorCG(Ogre::Technique* technique, Ogre::Pass* pass, ShaderType type, bool ignoreSlicePlane) : SShaderGenerator(technique, pass, type, ignoreSlicePlane)
123 mSource << "\toUv" << mSortedTexUnits[i] << " = mul(texMat" << mSortedTexUnits[i] << ", float4(" << "uv" << mSortedTexUnits[i] << ", 0.0, 1.0)).xy;\n";
325 mSource << "\t\tclip((slicePlane.x * wp.x + slicePlane.y * wp.y + slicePlane.z * wp.z + slicePlane.w > 0.0) ? -1.0 : 1.0);\n";
353 mSource << "\tfloat3 normal = mul(transpose(tbn), (normalTex.xyz -0.5) * 2); // to object space\n";
383 mSource << "\tlightDist = length(lightPos[i].xyz - wp.xyz) / (lightAtt[i].r / lightAtt[i].r);\n";
388 mSource << "\t\tla = 1.0 / (lightAtt[i].g + lightAtt[i].b * lightDist + lightAtt[i].a * ila);\n";
392 mSource << "\tspot = ((spotlightParams[i].w == 0.0) ? 1.0 : // if so, then it's not a spot light\n";
393 mSource << "\t saturate((dot(-normalize(spotlightDir[i].xyz - (spotlightDir[i].w * wp.xyz)), ld) - spotlightParams[i].y) / (spotlightParams[i].x - spotlightParams[i].y)));\n";
396 mSource << "\tshinlt = pow(max(dot(normal, normalize(ld + camDir)), 0.0), matShininess + 0.1) * lc;\n";
499 mSource << "\tfloat3 light0C = clamp(ambientColor + (diffuseLight * diffuseContrib) + specularContrib.rgb, 0.0, 1.0);\n";
502 mSource << "\tfloat alpha = clamp(matDif.a + (specularContrib.a * shincontrib * matDif.a), 0.0, 1.0);\n";
504 mSource << "\tfloat alpha = clamp(iColor.a + (specularContrib.a * shincontrib * iColor.a), 0.0, 1.0);\n";
522 mSource << "\tfloat mref = 2.0 * sqrt((refVec.x * refVec.x) + (refVec.y * refVec.y) + (refVec.z * refVec.z));\n";
529 mSource << "\tfloat fresnel = fresnelMul * reflectivity * pow(1 + dot(-camDir, normal), fresnelPow - (reflectivity * fresnelMul));\n";
551 mSource << "\treturn float4((fog * (light0C + reflectColor)) + fogColor.xyz * (1.0 - fog), alpha);\n";
555 mSource << "\treturn float4((fog * (ambientColor.rgb + reflectColor)) + fogColor.xyz * (1.0 - fog), ambientColor.a);\n";
563 mSource << "\treturn float4((fog * ambientColor.rgb) + (fogColor.xyz * (1.0 - fog)), ambientColor.a);\n";
581 out << "\t\t\t\tparam_named_auto " << "texMat" << mSortedTexUnits[i] << " texture_matrix " << mSortedTexUnits[i] << "\n";
604 out << "\t\t\t\tparam_named fresnelPow float " << ((mPass->getShininess() / 255.0f) * 2.0f) << "\n";
720 Ogre::GpuProgramPtr shaderPtr = Ogre::GpuProgramManager::getSingletonPtr()->getByName(GetShaderName(), Ogre::RGN_DEFAULT);
745 vpParams->setNamedAutoConstant("witMat", Ogre::GpuProgramParameters::ACT_INVERSE_TRANSPOSE_WORLD_MATRIX);
773 passParams->setNamedAutoConstant(pname.str(), Ogre::GpuProgramParameters::ACT_TEXTURE_MATRIX, mSortedTexUnits[i]);
780 Ogre::GpuProgramPtr shaderPtr = Ogre::GpuProgramManager::getSingletonPtr()->getByName(GetShaderName(), Ogre::RGN_DEFAULT);
814 vpParams->setNamedAutoConstant("ambient", Ogre::GpuProgramParameters::ACT_AMBIENT_LIGHT_COLOUR);
818 vpParams->setNamedAutoConstant("matAmb", Ogre::GpuProgramParameters::ACT_SURFACE_AMBIENT_COLOUR);
819 vpParams->setNamedAutoConstant("matDif", Ogre::GpuProgramParameters::ACT_SURFACE_DIFFUSE_COLOUR);
822 vpParams->setNamedAutoConstant("matEmissive", Ogre::GpuProgramParameters::ACT_SURFACE_EMISSIVE_COLOUR);
823 vpParams->setNamedAutoConstant("matSpec", Ogre::GpuProgramParameters::ACT_SURFACE_SPECULAR_COLOUR);
824 vpParams->setNamedAutoConstant("matShininess", Ogre::GpuProgramParameters::ACT_SURFACE_SHININESS);
826 vpParams->setNamedAutoConstant("lightDif", Ogre::GpuProgramParameters::ACT_LIGHT_DIFFUSE_COLOUR_ARRAY, mNbLights);
827 vpParams->setNamedAutoConstant("lightPos", Ogre::GpuProgramParameters::ACT_LIGHT_POSITION_ARRAY, mNbLights);
828 vpParams->setNamedAutoConstant("lightAtt", Ogre::GpuProgramParameters::ACT_LIGHT_ATTENUATION_ARRAY, mNbLights);
829 //vpParams->setNamedAutoConstant("lightSpec", Ogre::GpuProgramParameters::ACT_LIGHT_SPECULAR_COLOUR_ARRAY, mNbLights);
830 vpParams->setNamedAutoConstant("spotlightParams", Ogre::GpuProgramParameters::ACT_SPOTLIGHT_PARAMS_ARRAY, mNbLights);
831 vpParams->setNamedAutoConstant("spotlightDir", Ogre::GpuProgramParameters::ACT_LIGHT_DIRECTION_ARRAY, mNbLights);
836 vpParams->setNamedAutoConstant("iTWMat", Ogre::GpuProgramParameters::ACT_INVERSE_TRANSPOSE_WORLD_MATRIX);
880 passParams->setNamedConstant("fresnelPow", ((mPass->getShininess() / 255.0f) * (mRefTexCoef * 10.0f)));
SShaderGeneratorCG(Ogre::Technique *, Ogre::Pass *pass, ShaderType type, bool ignoreSlicePlane=false)
Definition SO3ShaderGeneratorCG.cpp:20
virtual std::string GetUniformParams()
Definition SO3ShaderGeneratorCG.cpp:569
~SShaderGeneratorCG()
Definition SO3ShaderGeneratorCG.cpp:25
virtual void ComputeShaderCode()
Definition SO3ShaderGeneratorCG.cpp:30
virtual std::string GetProgram()
Definition SO3ShaderGeneratorCG.cpp:614
virtual void ApplyShader()
Definition SO3ShaderGeneratorCG.cpp:715
Definition SO3ShaderGenerator.h:42
std::string GetShaderName()
Definition SO3ShaderGenerator.cpp:669
std::vector< unsigned int > mSortedTexUnits
Definition SO3ShaderGenerator.h:91
std::vector< ShaderMapType > mTexTypes
Definition SO3ShaderGenerator.h:89
std::vector< bool > mSortedCubeUv
Definition SO3ShaderGenerator.h:94
bool IsUvAnimated(int uvindex)
Definition SO3ShaderGenerator.cpp:674
std::vector< unsigned int > mTexUnits
Definition SO3ShaderGenerator.h:90
static GeneratedShaders mGeneratedShaders
Definition SO3ShaderGenerator.h:45
Definition SO3DataScol.h:38
Generated by 1.9.8