Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- Zilav
- modifed by SA547 for Oldrim meshes only - armor/clothing mod development
- Set emission, textureclamp, and glossiness values
- }
- unit NifBatchShaderTweak;
- const
- sPath = 'h:\tmp-dev'; // path to folders with nifs to update
- fEmissionMult = 1;
- fTextureClamp = 3;
- fGlossiness = 20;
- function Initialize: Integer;
- var
- TDirectory: TDirectory; // to access member functions
- i, j: integer;
- files: TStringDynArray;
- f: string;
- bChanged: Boolean;
- nif: TwbNifFile;
- shaders: TList;
- b: TwbNifBlock;
- begin
- nif := TwbNifFile.Create;
- shaders := TList.Create;
- try
- // get all *.nif files from this directory and subdirectories
- files := TDirectory.GetFiles(sPath, '*.nif', soAllDirectories);
- // process each file
- for i := 0 to Pred(Length(files)) do begin
- f := files[i];
- nif.LoadFromFile(f);
- bChanged := False;
- // get all shaders
- nif.BlocksByType('BSLightingShaderProperty', False, shaders);
- // update
- for j := 0 to Pred(shaders.Count) do begin
- b := TwbNifBlock(shaders[j]);
- if (b.NativeValues['Emissive Multiple'] <> fEmissionMult) or (b.NativeValues['Texture Clamp Mode'] <> fTextureClamp) or (b.NativeValues['Glossiness'] <> fGlossiness) then
- begin
- b.NativeValues['Emissive Multiple'] := fEmissionMult;
- b.NativeValues['Texture Clamp Mode'] := fTextureClamp;
- b.NativeValues['Glossiness'] := fGlossiness;
- bChanged := True;
- end;
- end;
- // save if nif has changed
- if bChanged then
- begin
- nif.SaveToFile(f);
- AddMessage('Updated: ' + f);
- end;
- shaders.Clear;
- end;
- finally
- nif.Free;
- shaders.Free;
- end;
- Result := 1;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement