If I select a material in the material editor and look for the path to one of it's texture I see a relative path like this:
../../../../path/to/texture/subfolder/texture_bump.png
I tried to access the path using this script
mat = findMaterial("myMaterial")
image = vrFieldAccess(mat.fields().getFieldContainer("bumpMap"))
print image.getString("name")
but it generates the same output.
../../../../path/to/texture/subfolder/texture_bump.png
How do I get the full path? Even if it is a network path? Something like this:
N:\path/to/texture/subfolder/texture_bump.png
or this:
\\netdrv/path/to/texture/subfolder/texture_bump.png
I know that VRED sees the full path because the textures are rendering properly in the viewport.
Solved! Go to Solution.
Solved by Christian_Garimberti. Go to Solution.
Hi,
have you tried this?
from os.path import abspath
filename = abspath('../../mypath/myfile.txt')
print(filename)
every ../ should be a folder a step up from the current vpb file location
Best
Chris
Christian Garimberti
Technical Manager and Visualization Enthusiast
Qs Informatica S.r.l. | Qs Infor S.r.l. | My Website
Facebook | Instagram | Youtube | LinkedIn
While I don´t know how this path was created just note that VRED doesn´t care about the path by default since all textures are inlined. So unless you have explicitly turned the inlining of textures off in the preferences before saving the file VRED will render correctly even if you delete the texture file on disk.
Do you mean that the textures are stored inside the .vpb-file? That would explain some of the confusion I've been experiencing that some texture does not show up in the folders that are specified in the material editor after I've copied the .vpb-file to anther directory, yet it was still rendering properly.
Thank you for pointing that out!
Keeping in mind the above considerations, note that the functions i wrote can returns a path that not exists.
Best
Chris
Christian Garimberti
Technical Manager and Visualization Enthusiast
Qs Informatica S.r.l. | Qs Infor S.r.l. | My Website
Facebook | Instagram | Youtube | LinkedIn
Yes, by default the textures are always embedded in the vpb so you can easily take the vpb with you and don´t need to care about textures. What is not embedded are HTML files if you use them and image sequences if you have not set the inline sequence option in the material.
Thank you for that code it does the job! But as has been pointed out to me, the textures are stored in the scene file so the path is not always correct, especially not if you move the scene file around. But still, you gave me a solution to my problem. Thanks!
Can't find what you're looking for? Ask the community or share your knowledge.