Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TESNPC * actorBase = DYNAMIC_CAST(thisObj->baseForm, TESForm, TESNPC);
- if(actorBase) {
- TESRace * race = actorBase->race.race;
- UInt8 gender = CALL_MEMBER_FN(actorBase, GetSex)();
- auto chargenData = race->chargenData[gender];
- NiNode * root = thisObj->GetObjectRootNode();
- VisitObjects(root, [&](NiAVObject* object) {
- BSTriShape * trishape = object->GetAsBSTriShape();
- if(trishape) {
- BSLightingShaderProperty * lightingShader = ni_cast(trishape->shaderProperty, BSLightingShaderProperty);
- if(lightingShader) {
- BSLightingShaderMaterialBase * material = static_cast<BSLightingShaderMaterialBase *>(lightingShader->shaderMaterial);
- if(material->GetType() == BSLightingShaderMaterialBase::kType_SkinTint) {
- BSLightingShaderMaterialFace * faceMaterial = static_cast<BSLightingShaderMaterialFace*>(CreateShaderMaterialByType(BSLightingShaderMaterialBase::kType_Face));
- CALL_MEMBER_FN(faceMaterial, Copy)(material);
- CALL_MEMBER_FN(lightingShader, SetFlag)(21, false); // Turn off SkinTint
- CALL_MEMBER_FN(lightingShader, SetFlag)(9, true); // Turn on FaceTint
- faceMaterial->baseDiffuse = material->spDiffuseTexture;
- tArray<BGSCharacterTint::Entry*> tempTints;
- CopyCharacterTints(&tempTints, actorBase->tints);
- FillTintTemplates(&tempTints, chargenData);
- MergeTintTextures(actorBase, &tempTints, (*g_faceGenManager)->unk3478, (*g_faceGenManager)->unk3230, 1, 0);
- CALL_MEMBER_FN(g_renderTargetManager, LockTextureType)(16);
- CALL_MEMBER_FN(g_renderTargetManager, LockTextureType)(17);
- CALL_MEMBER_FN(g_renderTargetManager, LockTextureType)(18);
- NiPointer<NiTexture> diffuse = CreateTexture("FaceCustomizationDiffuse", 1);
- diffuse->rendererData = CALL_MEMBER_FN(g_renderTargetManager, GetRenderData)(16, 1, 1, 0);
- faceMaterial->spDiffuseTexture = diffuse;
- NiPointer<NiTexture> normal = CreateTexture("FaceCustomizationNormals", 0);
- normal->rendererData = CALL_MEMBER_FN(g_renderTargetManager, GetRenderData)(17, 1, 1, 0);
- faceMaterial->spNormalTexture = normal;
- NiPointer<NiTexture> spec = CreateTexture("FaceCustomizationSmoothSpec", 0);
- spec->rendererData = CALL_MEMBER_FN(g_renderTargetManager, GetRenderData)(18, 1, 1, 0);
- faceMaterial->spSmoothnessSpecMaskTexture = spec;
- CALL_MEMBER_FN(g_renderTargetManager, ReleaseTextureType)(16);
- CALL_MEMBER_FN(g_renderTargetManager, ReleaseTextureType)(17);
- CALL_MEMBER_FN(g_renderTargetManager, ReleaseTextureType)(18);
- CALL_MEMBER_FN(lightingShader, SetMaterial)(faceMaterial, true);
- }
- }
- }
- return false;
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement