SO3Engine
|
SO3ShaderGeneratorUnified.cpp
Go to the documentation of this file.
20 SShaderGeneratorUnified::SShaderGeneratorUnified(Ogre::Technique* technique, Ogre::Pass* pass, ShaderType type, bool ignoreSlicePlane) : SShaderGenerator(technique, pass, type, ignoreSlicePlane)
164 mSource << "\toUv" << mSortedTexUnits[i] << " = mul(texMat" << mSortedTexUnits[i] << ", vec4(" << "uv" << mSortedTexUnits[i] << ", 0.0, 1.0)).xy;\n";
438 mSource << "\tif (((slicePlane.x + slicePlane.y + slicePlane.z) != 0.0) && (slicePlane.x * oWp.x + slicePlane.y * oWp.y + slicePlane.z * oWp.z + slicePlane.w > 0.0))\n";
462 mSource << "\tmat3 tbn = mtxFromRows(oTang * vec3_splat(normalMul), oBinormal * vec3_splat(normalMul), oNorm.xyz);\n";
463 mSource << "\tvec3 normal = mul(transposeM(tbn), (normalTex.xyz - vec3_splat(0.5)) * vec3_splat(2.0)); // to object space\n";
496 mSource << "\t\tla = 1.0 / (lightAtt[i].y + lightAtt[i].z * lightDist + lightAtt[i].w * lightDist * lightDist);\n";
498 mSource << "\t\tfloat spot = ((spotlightParams[i].w == 0.0) ? 1.0 : // if so, then it's not a spot light\n";
499 mSource << "\t\t saturate(((dot(-normalize(spotlightDir[i].xyz - (vec3_splat(spotlightDir[i].w) * oWp.xyz)), ld) - spotlightParams[i].y) / (spotlightParams[i].x - spotlightParams[i].y))));\n";
506 mSource << "\tshinlt = pow(max(dot(normal, normalize(ld + camDir)), 0.0), matShininess + 0.1) * lc;\n";
605 mSource << "\tvec3 light0C = saturate(ambientColor + (diffuseLight * diffuseContrib) + specularContrib.rgb);\n";
608 mSource << "\tfloat alpha = saturate(matDif.a + (specularContrib.a * shincontrib * matDif.a));\n";
610 mSource << "\tfloat alpha = saturate(oColor.a + (specularContrib.a * shincontrib * oColor.a));\n";
631 mSource << "\tfloat mref = 2.0 * sqrt((refVec.x * refVec.x) + (refVec.y * refVec.y) + (refVec.z * refVec.z));\n";
638 mSource << "\tfloat fresnel = fresnelMul * reflectivity * pow(1.0 + dot(-camDir, normal), fresnelPow - (reflectivity * fresnelMul));\n";
652 mSource << "\tvec3 refTexMsk = texture2D(reflectMskMap, oUv" << refMskUv << ".xy" << ").rgb;\n";
659 mSource << "\tgl_FragColor = vec4((vec3_splat(fog) * (light0C + reflectColor)) + (fogColor.rgb * vec3_splat(1.0 - fog)), alpha);\n";
663 mSource << "\tgl_FragColor = vec4((vec3_splat(fog) * (ambientColor.rgb + reflectColor)) + (fogColor.rgb * vec3_splat(1.0 - fog)), ambientColor.w);\n";
669 mSource << "\tgl_FragColor = vec4((vec3_splat(fog) * light0C) + (fogColor.rgb * vec3_splat(1.0 - fog)), alpha);\n";
671 mSource << "\tgl_FragColor = vec4((vec3_splat(fog) * ambientColor.rgb) + (fogColor.rgb * vec3_splat(1.0 - fog)), ambientColor.w);\n";
689 out << "\t\t\t\tparam_named_auto " << "texMat" << mSortedTexUnits[i] << " texture_matrix " << mSortedTexUnits[i] << "\n";
712 out << "\t\t\t\tparam_named fresnelPow float " << ((mPass->getShininess() / 255.0f) * 2.0f) << "\n";
839 out << "\t\tparam_named_auto lightDif light_diffuse_colour_power_scaled_array " << mNbLights << "\n";
891 bool isGlSL = (rendererName == "Direct3D9 Rendering Subsystem" || rendererName == "Direct3D11 Rendering Subsystem") ? false : true;
893 Ogre::String language = ((rendererName == "OpenGL ES 2.x Rendering Subsystem") || (rendererName == "Metal Rendering Subsystem")) ? "glsles" : (rendererName == "Vulkan Rendering Subsystem") ? "glslang" : isGlSL ? "glsl" : "hlsl";
898 Ogre::GpuProgramPtr shaderPtr = Ogre::GpuProgramManager::getSingletonPtr()->getByName(GetShaderName(), Ogre::RGN_DEFAULT);
913 //Ogre::LogManager::getSingleton().getDefaultLog()->logMessage(">>>> Generated shader - " + GetShaderName() + " - :\n" + mSource.str() + "\n>>>>>\n");
921 vpParams->setNamedAutoConstant("witMat", Ogre::GpuProgramParameters::ACT_INVERSE_TRANSPOSE_WORLD_MATRIX);
949 passParams->setNamedAutoConstant(pname.str(), Ogre::GpuProgramParameters::ACT_TEXTURE_MATRIX, mSortedTexUnits[i]);
956 Ogre::GpuProgramPtr shaderPtr = Ogre::GpuProgramManager::getSingletonPtr()->getByName(GetShaderName(), Ogre::RGN_DEFAULT);
971 //Ogre::LogManager::getSingleton().getDefaultLog()->logMessage(">>>> Generated shader - " + GetShaderName() + " - :\n" + mSource.str() + "\n>>>>>\n");
988 vpParams->setNamedAutoConstant("ambient", Ogre::GpuProgramParameters::ACT_AMBIENT_LIGHT_COLOUR);
992 vpParams->setNamedAutoConstant("matAmb", Ogre::GpuProgramParameters::ACT_SURFACE_AMBIENT_COLOUR);
993 vpParams->setNamedAutoConstant("matDif", Ogre::GpuProgramParameters::ACT_SURFACE_DIFFUSE_COLOUR);
996 vpParams->setNamedAutoConstant("matEmissive", Ogre::GpuProgramParameters::ACT_SURFACE_EMISSIVE_COLOUR);
997 vpParams->setNamedAutoConstant("matSpec", Ogre::GpuProgramParameters::ACT_SURFACE_SPECULAR_COLOUR);
998 vpParams->setNamedAutoConstant("matShininess", Ogre::GpuProgramParameters::ACT_SURFACE_SHININESS);
1000 vpParams->setNamedAutoConstant("lightDif", Ogre::GpuProgramParameters::ACT_LIGHT_DIFFUSE_COLOUR_POWER_SCALED_ARRAY, mNbLights);
1001 vpParams->setNamedAutoConstant("lightPos", Ogre::GpuProgramParameters::ACT_LIGHT_POSITION_ARRAY, mNbLights);
1002 vpParams->setNamedAutoConstant("lightAtt", Ogre::GpuProgramParameters::ACT_LIGHT_ATTENUATION_ARRAY, mNbLights);
1003 //vpParams->setNamedAutoConstant("lightSpec", Ogre::GpuProgramParameters::ACT_LIGHT_SPECULAR_COLOUR_ARRAY, mNbLights);
1004 vpParams->setNamedAutoConstant("spotlightParams", Ogre::GpuProgramParameters::ACT_SPOTLIGHT_PARAMS_ARRAY, mNbLights);
1005 vpParams->setNamedAutoConstant("spotlightDir", Ogre::GpuProgramParameters::ACT_LIGHT_DIRECTION_ARRAY, mNbLights);
1010 vpParams->setNamedAutoConstant("iTWMat", Ogre::GpuProgramParameters::ACT_INVERSE_TRANSPOSE_WORLD_MATRIX);
1093 passParams->setNamedConstant("fresnelPow", ((mPass->getShininess() / 255.0f) * (mRefTexCoef * 10.0f)));
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
virtual std::string GetProgram()
Definition SO3ShaderGeneratorUnified.cpp:722
virtual std::string GetUniformParams()
Definition SO3ShaderGeneratorUnified.cpp:677
SShaderGeneratorUnified(Ogre::Technique *, Ogre::Pass *pass, ShaderType type, bool ignoreSlicePlane=false)
Definition SO3ShaderGeneratorUnified.cpp:20
~SShaderGeneratorUnified()
Definition SO3ShaderGeneratorUnified.cpp:24
virtual void ApplyShader()
Definition SO3ShaderGeneratorUnified.cpp:888
virtual void ComputeShaderCode()
Definition SO3ShaderGeneratorUnified.cpp:29
Definition SO3DataScol.h:38
Generated by 1.9.8