SO3Engine
|
SO3DeferredLightDirectionalMaterialGenerator.cpp
Go to the documentation of this file.
38Ogre::GpuProgramPtr SDeferredLightDirectionalMaterialGenerator::GenerateVertexShader(SGBuffer* gbuffer, Ogre::uint32 permutationValue)
98Ogre::GpuProgramPtr SDeferredLightDirectionalMaterialGenerator::GenerateFragmentShader(SGBuffer* gbuffer, Ogre::uint32 permutationValue)
128 ss << " " << gbuffer->GetGBufferCompositorPixelInputStructureTypeName() << " gBuffer," << std::endl; // Input parameters (list of mrts)
137 ss << " uniform sampler2D ShadowTex : register(s" << gbuffer->GetNumberMrt() << ")," << std::endl;
163 ss << " checkShadow(ShadowTex, viewPos, invView, shadowViewProjMat, shadowFarClip, shadowCamPos);" << std::endl;
167 ss << " total_light_contrib = max(0.0,dot(objToLightDir, normal)) * lightDiffuseColor.rgb;" << std::endl;
172 ss << " float3 light_specular = pow(max(dot(normal, h), 0), specularity) * lightSpecularColor.rgb;" << std::endl;
174 // If GBuffer supports specular color, compute specular component using the material specular colour too.
186 Ogre::String programName = materialBaseName +"Shaders/Pixel/"+ gbuffer->GetName() + Ogre::StringConverter::toString(permutationValue);
190 Ogre::LogManager::getSingleton().getDefaultLog()->logMessage(programSource, Ogre::LML_CRITICAL);
195 Ogre::HighLevelGpuProgramPtr ptrProgram = Ogre::HighLevelGpuProgramManager::getSingleton().createProgram(programName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, "cg", Ogre::GPT_FRAGMENT_PROGRAM);
203 params->setNamedAutoConstant("lightDiffuseColor", Ogre::GpuProgramParameters::ACT_LIGHT_DIFFUSE_COLOUR, 0);
205 params->setNamedAutoConstant("lightSpecularColor", Ogre::GpuProgramParameters::ACT_LIGHT_SPECULAR_COLOUR, 0);
207 params->setNamedAutoConstant("lightPower", Ogre::GpuProgramParameters::ACT_LIGHT_POWER_SCALE, 0);
209 params->setNamedAutoConstant("lightDir", Ogre::GpuProgramParameters::ACT_LIGHT_DIRECTION_VIEW_SPACE, 0);
211 params->setNamedAutoConstant("farClipDistance", Ogre::GpuProgramParameters::ACT_FAR_CLIP_DISTANCE);
214 if ((permutationValue & SDeferredLightPermutation::SO3_LP_CAST_SHADOWS) && (params->_findNamedConstantDefinition("invView")))
222Ogre::MaterialPtr SDeferredLightDirectionalMaterialGenerator::GenerateTemplateMaterial(SGBuffer* gbuffer, Ogre::uint32 permutationValue)
224 Ogre::MaterialPtr matPtr = SDeferredLightMaterialGenerator::GenerateTemplateMaterial(gbuffer, permutationValue);
virtual ~SDeferredLightDirectionalMaterialGenerator()
virtual Ogre::GpuProgramPtr GenerateFragmentShader(SGBuffer *gbuffer, Ogre::uint32 permutationValue)
SDeferredLightDirectionalMaterialGenerator()
virtual Ogre::GpuProgramPtr GenerateVertexShader(SGBuffer *gbuffer, Ogre::uint32 permutationValue)
virtual Ogre::MaterialPtr GenerateTemplateMaterial(SGBuffer *gbuffer, Ogre::uint32 permutationValue)
virtual Ogre::MaterialPtr GenerateTemplateMaterial(SGBuffer *gbuffer, Ogre::uint32 permutationValue)
Definition SO3DeferredLightMaterialGenerator.cpp:44
@ SO3_LP_CAST_SHADOWS
Definition SO3DeferredLightPermutation.h:42
Definition SO3GBuffer.h:37
Ogre::String GenerateGBufferCompositorPixelInputStructure()
Definition SO3GBuffer.cpp:63
Ogre::String GetGBufferCompositorPixelInputStructureTypeName()
Definition SO3GBuffer.cpp:58
const Ogre::String materialBaseName
Base name of materials generated by this.
Definition SO3MaterialGenerator.h:50
Definition SO3DataScol.h:38
Generated by 1.9.8