| 201 | } |
| 202 | |
| 203 | bool ProcessedCustomMaterial::init( const FeatureSet &features, |
| 204 | const GFXVertexFormat *vertexFormat, |
| 205 | const MatFeaturesDelegate &featuresDelegate ) |
| 206 | { |
| 207 | // If we don't have a shader data... we have nothing to do. |
| 208 | if ( !mCustomMaterial->mShaderData ) |
| 209 | return true; |
| 210 | |
| 211 | // Custom materials only do one pass at the moment... so |
| 212 | // add one for the stage data to fill in. |
| 213 | ShaderRenderPassData *rpd = new ShaderRenderPassData(); |
| 214 | mPasses.push_back( rpd ); |
| 215 | |
| 216 | _setStageData(); |
| 217 | _initPassStateBlocks(); |
| 218 | mStateHint.clear(); |
| 219 | |
| 220 | // Note: We don't use the vertex format in a custom |
| 221 | // material at all right now. |
| 222 | // |
| 223 | // Maybe we can add some required semantics and |
| 224 | // validate that the format fits the shader? |
| 225 | |
| 226 | // Build a composite list of shader macros from |
| 227 | // the conditioner and the user defined lists. |
| 228 | Vector<GFXShaderMacro> macros; |
| 229 | macros.merge( mConditionerMacros ); |
| 230 | macros.merge( mUserMacros ); |
| 231 | |
| 232 | // Ask the shader data to give us a shader instance. |
| 233 | rpd->shader = mCustomMaterial->mShaderData->getShader( macros ); |
| 234 | if ( !rpd->shader ) |
| 235 | { |
| 236 | delete rpd; |
| 237 | mPasses.clear(); |
| 238 | return false; |
| 239 | } |
| 240 | |
| 241 | rpd->shaderHandles.init( rpd->shader, mCustomMaterial ); |
| 242 | _initMaterialParameters(); |
| 243 | mDefaultParameters = allocMaterialParameters(); |
| 244 | setMaterialParameters( mDefaultParameters, 0 ); |
| 245 | mStateHint.init( this ); |
| 246 | |
| 247 | for(int i = 0; i < mMaxTex; i++) |
| 248 | { |
| 249 | ShaderConstHandles *handles = _getShaderConstHandles( mPasses.size()-1 ); |
| 250 | AssertFatal(handles,""); |
| 251 | |
| 252 | if(rpd->mSamplerNames[i].isEmpty()) |
| 253 | continue; |
| 254 | |
| 255 | String samplerName = rpd->mSamplerNames[i].startsWith("$") ? rpd->mSamplerNames[i] : String("$") + rpd->mSamplerNames[i]; |
| 256 | GFXShaderConstHandle *handle = rpd->shader->getShaderConstHandle( samplerName ); |
| 257 | AssertFatal(handle,""); |
| 258 | handles->mTexHandlesSC[i] = handle; |
| 259 | } |
| 260 |
nothing calls this directly
no test coverage detected