SO3Engine
|
SO3DeferredLightPointMaterialGenerator.cpp
Go to the documentation of this file.
38Ogre::GpuProgramPtr SDeferredLightPointMaterialGenerator::GenerateVertexShader(SGBuffer* gbuffer, Ogre::uint32 permutationValue)
79Ogre::GpuProgramPtr SDeferredLightPointMaterialGenerator::GenerateFragmentShader(SGBuffer* gbuffer, Ogre::uint32 permutationValue)
117 ss << " " << gbuffer->GetGBufferCompositorPixelInputStructureTypeName() << " gBuffer," << std::endl; // Input parameters (list of mrts)
129 ss << " uniform sampler2D ShadowTex : register(s" << gbuffer->GetNumberMrt() << ")," << std::endl;
167 ss << " checkShadow(ShadowTex, viewPos, invView, shadowViewProjMat, shadowFarClip, len);" << std::endl;
171 ss << " total_light_contrib = max(0.0,dot(objToLightDir, normal)) * lightDiffuseColor.rgb;" << std::endl;
176 ss << " float3 light_specular = pow(max(dot(normal, h), 0), specularity) * lightSpecularColor.rgb;" << std::endl;
178 // If GBuffer supports specular color, compute specular component using the material specular colour too.
201 ss << " float quadricAttenuation = lightFalloff.w / (lightFalloff.x * lightFalloff.x);" << std::endl;
202 ss << " float attenuation = 1 / dot(float3(constantAttenuation, linearAttenuation, quadricAttenuation), float3(1.0, len, len_sq));" << std::endl;
206 ss << " float attenuation = dot(lightFalloff.yzw, float3(1.0, len, len_sq));" << std::endl; // Simpler technique, no need to scale to range
216 Ogre::String programName = materialBaseName +"Shaders/Pixel/"+ gbuffer->GetName() + Ogre::StringConverter::toString(permutationValue);
220 Ogre::LogManager::getSingleton().getDefaultLog()->logMessage(programSource, Ogre::LML_CRITICAL);
225 Ogre::HighLevelGpuProgramPtr ptrProgram = Ogre::HighLevelGpuProgramManager::getSingleton().createProgram(programName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, "cg", Ogre::GPT_FRAGMENT_PROGRAM);
242 params->setNamedAutoConstant("lightDiffuseColor", Ogre::GpuProgramParameters::ACT_LIGHT_DIFFUSE_COLOUR, 0);
244 params->setNamedAutoConstant("lightSpecularColor", Ogre::GpuProgramParameters::ACT_LIGHT_SPECULAR_COLOUR, 0);
246 params->setNamedAutoConstant("lightFalloff", Ogre::GpuProgramParameters::ACT_LIGHT_ATTENUATION, 0);
248 params->setNamedAutoConstant("lightPos", Ogre::GpuProgramParameters::ACT_LIGHT_POSITION_VIEW_SPACE, 0);
250 params->setNamedAutoConstant("lightPower", Ogre::GpuProgramParameters::ACT_LIGHT_POWER_SCALE, 0);
252 params->setNamedAutoConstant("farClipDistance", Ogre::GpuProgramParameters::ACT_FAR_CLIP_DISTANCE);
268Ogre::MaterialPtr SDeferredLightPointMaterialGenerator::GenerateTemplateMaterial(SGBuffer* gbuffer, Ogre::uint32 permutationValue)
270 Ogre::MaterialPtr matPtr = SDeferredLightMaterialGenerator::GenerateTemplateMaterial(gbuffer, permutationValue);
virtual Ogre::MaterialPtr GenerateTemplateMaterial(SGBuffer *gbuffer, Ogre::uint32 permutationValue)
Definition SO3DeferredLightMaterialGenerator.cpp:44
@ SO3_LP_CAST_SHADOWS
Definition SO3DeferredLightPermutation.h:42
virtual Ogre::GpuProgramPtr GenerateVertexShader(SGBuffer *gbuffer, Ogre::uint32 permutationValue)
virtual Ogre::GpuProgramPtr GenerateFragmentShader(SGBuffer *gbuffer, Ogre::uint32 permutationValue)
virtual Ogre::MaterialPtr GenerateTemplateMaterial(SGBuffer *gbuffer, Ogre::uint32 permutationValue)
SDeferredLightPointMaterialGenerator()
virtual ~SDeferredLightPointMaterialGenerator()
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