Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Materials are not exported if the texture path is relative to the blend file #27

Open
AmyLillya opened this issue May 14, 2024 · 46 comments

Comments

@AmyLillya
Copy link

AmyLillya commented May 14, 2024

When exporting the .spm model from blender, the model has no materials in game, it defaults to a white shader. The kart folder has all the textures there.

blender_MQWLkpA88U
supertuxkart_Exr5sa1ZhP

The materials.xml file is exported with no parameters. I tried to manually set them in the same way as other custom karts but that didn't work.

@AmyLillya
Copy link
Author

After bashing my head trying to figure out what was breaking exporting the materials I finally found what the issue is!

I noticed that if I create a brand new .blend file, append all the objects for the kart, and export without saving the .blend file, then all the materials get exported correctly. However if I save the .blend file before exporting then the materials break in-game.

That gave me the clue that what breaks the exporter is when the texture used by the material have a relative path, that is, they are located somewhere inside the folder where the .blend file is. For example:

This texture is inside the folder where the .blend file is located, receiving a relative path. This breaks the exporter:
stk exporter problem 1

This texture is located in a separate folder in the system, receiving an absolute path. This exports correctly:
blender_zuWDMo6kQg

I don't know how the .spm exporter works and if it could be changed to work with relative paths. At least a note in the kart creation manual warning to not use relative path would be much appreciated and could save a lot of frustration for someone who's a beginner like me.

@AmyLillya AmyLillya changed the title Materials are not being exported on Blender 4.1 Materials are not exported if the texture path is relative to the blend file May 16, 2024
@AmyLillya
Copy link
Author

Forgot to mention, the addon does work on the latest Blender version, the issue was not related to that.

@awab1433
Copy link

awab1433 commented Sep 3, 2024

I think thats my problem?!
Im also dead in my tracks with the kart wheels not exporting properly
Please guide.

@awab1433
Copy link

awab1433 commented Sep 3, 2024

Also, how do you generate a texture file like u did above?

@RQWorldblender
Copy link
Collaborator

RQWorldblender commented Sep 3, 2024

Reading about what happened, there is a way to make paths used for Blender files absolute or relative.
In File -> External Data -> Make Paths Absolute or Make Paths Relative, these options can be used as a temporary workaround.
However, the issue here seems to be elsewhere, either a change made since Blender 4.0 or the bundled Python version. I haven't been making any add-ons recently since the Blender 2.93 LTS version, I'm going to need to catch up with the latest changes. Although I did make a commit this week, the changes are for the SPM importer, so I have to do more investigation unless someone else steps up.

@AmyLillya @awab1433 Perhaps it may help if you can send me some relevant files I can look through that can help in my investigation?

@awab1433
Copy link

awab1433 commented Sep 3, 2024 via email

@RQWorldblender
Copy link
Collaborator

only 1 wheel is exported, and in the xml file, the same wheel (rear right) is used for all 4 wheels. only happens when i get models on sketchfab.

Is it okay if I can see your .blend file that you're working on, to see if I can reproduce the issue you're having? I'm using Blender 4.2.1 LTS, so I may not always be on the latest version.
Have you also set up your model centered at the origin? The wheel positions are based on the 4 quads, and a kart should be facing north when you view it from the top. The wheels determined are based on which quad they are in during export time.

@awab1433
Copy link

awab1433 commented Sep 3, 2024 via email

@RQWorldblender
Copy link
Collaborator

this issue is with every model i make im using blender 2.83, so it might not be compatible with yours. I can send you the textures if you want!

I suggest that you upgrade to a more recent Blender version, unless something is holding you back from doing so. They have LTS versions especially for those who can't upgrade as fast for whatever reason. I made the initial port of these scripts using 2.83 LTS, but other people have been working on them for long enough that more recent Blender versions are the target (the 3.x and 4.x series). Blender is apparently of one many faster-moving free/open-source projects, so I fell behind on some of the changes until this month.
If that still doesn't work out, you can attach your files here.

@awab1433
Copy link

awab1433 commented Sep 3, 2024 via email

@RQWorldblender
Copy link
Collaborator

RQWorldblender commented Sep 3, 2024

Perfect! I'll upgrade and check if it works, although I was advised to stay on 2.8 due to issues with the exporter? Thank ypu for reaching out and helping the community!

You're welcome! The readme has actually been changed so that the minimum Blender version is now >= 3.0. My intuition was right that you should upgrade your Blender version to something more recent.

@awab1433
Copy link

awab1433 commented Sep 4, 2024 via email

@awab1433
Copy link

awab1433 commented Sep 4, 2024 via email

@awab1433
Copy link

awab1433 commented Sep 4, 2024 via email

@awab1433
Copy link

awab1433 commented Sep 4, 2024 via email

@RQWorldblender
Copy link
Collaborator

@awab1433 Maybe it would help if you sent your files over. It's okay to be on Blender 4.2.x actually. I'm also not able to see any images you send since you respond via email.

@awab1433
Copy link

awab1433 commented Sep 5, 2024

https://drive.google.com/drive/folders/1S7QNdQRX3PsKgZJDBJi9eNmci9-QZxMq?usp=sharing

the folder nitro blade is what is exported, while the bled file is the blender file

@RQWorldblender
Copy link
Collaborator

RQWorldblender commented Sep 5, 2024

@awab1433 I downloaded the Blender file you sent me, and there is something peculiar I noticed: your whole vehicle has almost everything set up to be parented to an empty object. I think this empty object may be causing issues - I'm gong to try exporting without using this empty object, and I will also center your vehicle more closely to the origin. You could also consider putting several objects into collections to make them easier to manage.

Upon looking at your vehicle more, I noticed some more errors that can be fixed:

  • Your wheels are set up as empty objects, and it looks like the exporter doesn't recognize empty objects. I'm also going to remove the empty objects and make the wheels themselves the actual wheels.
  • It looks like you're only using solid colors, so you can use vertex coloring / color attributes as an alternative.
  • In the materials panel, there is also a section for Antarctica / SuperTuxKart Properties where you can define how those materials will appear in-game. Since you haven't defined any special behavior for any materials, it's normal for your materials.xml file to come out as almost empty until you define something. PBR Solid is apparently the default option if nothing is selected.
  • Your objects aren't well-named, and that may also be fixed.

@awab1433
Copy link

awab1433 commented Sep 5, 2024 via email

@awab1433
Copy link

awab1433 commented Sep 6, 2024

The way I texture the car is set an image texture and make an image for each color. Very inefficient way. Is there an easier way of doing it? If so, please tell me how. Thanks again for your dedication!

@awab1433
Copy link

awab1433 commented Sep 6, 2024

@AmyLillya I think i found the issue! If you use 3.x, you will have the relative file path error. However, using 2.8 solved the issue for me. Lmk if that works.

@RQWorldblender
Copy link
Collaborator

@awab1433 I mentioned that you can use vertex painting to use vertex colors. I think the STK website mentions about this; this is the only other way that you can 'texture' objects besides using image files.
You should also know that if you don't set any properties for your materials, then nothing will be set and everything you use will use 'PBR Solid' by default.
I can send my modified version so you have a better idea of how to do your kart better.

@awab1433
Copy link

awab1433 commented Sep 6, 2024 via email

@awab1433
Copy link

awab1433 commented Sep 8, 2024 via email

@RQWorldblender
Copy link
Collaborator

@awab1433 Sorry I forgot about this, but here's what I worked on so far:
NitroBlade.zip

@awab1433
Copy link

awab1433 commented Sep 9, 2024 via email

@RQWorldblender
Copy link
Collaborator

the file doesnt open? It will not launch.. Anyway, what did you do and how?! Cause i have a lucid air sapphire coming soon and i wanna make it work?

You need at least Blender 4.2 LTS to open the file, I should've mentioned that, but I was on my phone typing this. I made the following changes, but this isn't all of them:

  • Your wheels are set up as the actual objects.
  • You have vertex coloring / color attributes set upon the body and rear headlights.

@awab1433
Copy link

awab1433 commented Sep 9, 2024

you said that some were empty objects? how did you fix that?

@RQWorldblender
Copy link
Collaborator

you said that some were empty objects? how did you fix that?

In Parent -> Clear parent and keep transformation, that's how it can be done, from the object or right click menu. Your empty objects were represented by axises. I kept the one for the car body. The exporter will handle mesh objects better than empty objects unless they are a hat placer or nitro emitter.

@awab1433
Copy link

@RQWorldblender
Audi.zip
I dont underestand what is going on? I did what you said, but it's not happening. It worked with the other nitroblade i made?

@RQWorldblender
Copy link
Collaborator

RQWorldblender commented Sep 18, 2024

I dont underestand what is going on? I did what you said, but it's not happening. It worked with the other nitroblade i made?

I just looked at this model, but I fixed up this model by deleting most of the empty objects as well as deleting the problematic front right wheel and replacing it with a duplicate of the front left wheel. You can look at what I did in this archive.
audi-RQ.zip

@awab1433
Copy link

awab1433 commented Sep 18, 2024

@RQWorldblender
I've benefited a lot from your guidence!! I'm really sorry for taking up time, one last model, the lucid air. The rims as well as other parts of the car don't show up properly even though i did my best (Vertex painted it). Thanks to your guidance, i was able to make the wheels spin and turn! can you please tell me what's going on? I greatly appreciate your time and efforts!
I'll for sure put you in the credits sections on the kart!
https://drive.google.com/drive/folders/1S7QNdQRX3PsKgZJDBJi9eNmci9-QZxMq?usp=sharing

@awab1433
Copy link

@RQWorldblender Have you had a chance to look at the car? Thanks!!

@RQWorldblender
Copy link
Collaborator

@awab1433 Sorry, I was too focused on other real life things that I lost track of it. Though I did download your most recent kart files, I haven't seen much wrong with it, but that's only within Blender, since I haven't actually opened up STK in several months now. I didn't make any changes to what you sent me yet as of this post.

@awab1433
Copy link

awab1433 commented Sep 23, 2024 via email

@awab1433
Copy link

awab1433 commented Oct 2, 2024

@RQWorldblender have you got a chance to look at it. This is how it looks in stk:
image
image

@RQWorldblender
Copy link
Collaborator

@awab1433 I just looked at the screenshots you sent me. The vertex colors are showing up, although the lighting may affect their exact appearance. What are you expecting to appear that isn't showing up in-game?

@awab1433
Copy link

awab1433 commented Oct 2, 2024

@RQWorldblender The rims are not shwing up properly, the glass as well. and also the light bar they are supposed to show up just like how they were in blender

@RQWorldblender
Copy link
Collaborator

@awab1433 Well, this is getting tougher than I thought. Do the problematic meshes show up if you change the colors to something other than what they are now on both the glass and tire rims? You might also consider checking any game logs to see if any errors pertaining to loading your custom karts appear, or run it from a console / terminal program.

@awab1433
Copy link

awab1433 commented Oct 3, 2024 via email

@awab1433
Copy link

awab1433 commented Oct 3, 2024

@RQWorldblender maybe it would help you: When I reassign new materials, it works. Its just really messed up. Is there something in particular you noticed? I've been stuck on this model for over a month. Exports take 5+ mins!

@awab1433
Copy link

awab1433 commented Oct 9, 2024

@RQWorldblender. I have a question for you. I was just making a new car and the colors for the car look dull. Is there a way to make the colors glossy? Thank you so much for your support with my issues!

@RQWorldblender
Copy link
Collaborator

@awab1433 There is a way to make materials in STK look glossy, that being a gloss map. I haven't used gloss maps myself, so I'm not of much help here, but the STK website has documentation on how to make gloss maps. You can configure materials in Blender to look more shiny, but it won't carry over to STK in-game.

@awab1433
Copy link

@RQWorldblender I referred to the tutorial, with no avail. I couldn't at all understand a word said. Do you know a yt tutorial that explains that, because gloss maps go black and white, not rgb?

@RQWorldblender
Copy link
Collaborator

@awab1433 I won't be of much help with your specific issue about making your car models look glossy, since I never used gloss maps myself. You'll have to find someone else who can help you in the meantime.

@awab1433
Copy link

@RQWorldblender I was able to make a gloss map using one of the add-ons. But my puzzle is, how to add a decal to a car in blender. I tried to use images as planes, but it is a black square, so, that didnt help. I have a .png that I want to add. Thank you for your time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants