void ReplaceMaterialParam(const Palleon::MaterialPtr& material, const char* paramName, const CVector4& newParamValue) { auto param = material->GetEffectParameter(paramName); CVector4 paramValue(0, 0, 0, 0); if(param.IsVector3()) { paramValue = CVector4(param.GetVector3(), 0); } else { paramValue = param.GetVector4(); } paramValue.x = (newParamValue.x == 1000.f) ? paramValue.x : newParamValue.x; paramValue.y = (newParamValue.y == 1000.f) ? paramValue.y : newParamValue.y; paramValue.z = (newParamValue.z == 1000.f) ? paramValue.z : newParamValue.z; paramValue.w = (newParamValue.w == 1000.f) ? paramValue.w : newParamValue.w; if(param.IsVector3()) { param.SetVector3(paramValue.xyz()); } else { param.SetVector4(paramValue); } material->SetEffectParameter(paramName, param); }
void ae3d::Shader::SetRenderTexture( const char* name, const ae3d::RenderTexture* texture, int textureUnit ) { glActiveTexture( GL_TEXTURE0 + textureUnit ); glBindTexture( texture->IsCube() ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D, texture->GetID() ); GfxDevice::IncTextureBinds(); SetInt( name, textureUnit ); const std::string scaleOffsetName = std::string( name ) + std::string( "_ST" ); SetVector4( scaleOffsetName.c_str(), &texture->GetScaleOffset().x ); }