[WIP] rFactor2 export scripts for Blender 2.80+

Discussion in 'Third Party Content' started by Traveller, Dec 6, 2020.

  1. Haris1977

    Haris1977 Registered

    Joined:
    Nov 25, 2019
    Messages:
    401
    Likes Received:
    195
    That's good news and really hope for this :)

    I had to use 3dsimed in which my licence expired :(
     
    Last edited: Dec 1, 2022
  2. Haris1977

    Haris1977 Registered

    Joined:
    Nov 25, 2019
    Messages:
    401
    Likes Received:
    195
  3. Traveller

    Traveller Member

    Joined:
    Oct 7, 2010
    Messages:
    862
    Likes Received:
    485
    I'm targeting by Christmas. 2022.
     
  4. frootsnax

    frootsnax Registered

    Joined:
    Dec 4, 2022
    Messages:
    3
    Likes Received:
    2
    I'm slowly working my way through figuring out how to make tracks for rFactor 2 entirely within Blender (For anyone landing here from Google also looking for a singular comprehensive source of information like I was, I plan on doing a fairly detailed write-up on the entire process once I have my first track finished and all the minutia figured out). So far so good, although a roadblock that I'm encountering now that I hadn't thought of at first was smoothing groups on meshes.

    I've been importing some S397 assets and noticing that after exporting and loading them in scene viewer, they look atrocious. Like, rFactor 1 / PlayStation 1 levels of atrocious. I was confused at first, because the meshes in question came straight from scene files of S397's own tracks, and I assume that the 3DSimED3 export does not alter them in any way. But after browsing through this thread and seeing what DiggerHawk has mentioned, I was clued into the "Show Smooth Groups" function of the scripts and then discovered what appears to be this mess, for example:

    [​IMG]

    I assume that ideally, I want all these faces to be either the same color, or at least the same color per side? That being said, is there any somewhat expedient way of remedying this? I suppose I could go through and select individual faces of a certain color, separate them from the object, then re-join them (Assuming that is how you fix the problem. I saw stuff about edge splits and bevel modifiers and marking edges as sharp and my eyes honestly glazed over). But having to do that repeatedly for some of these props that will be duplicated multiple times throughout the scene is time that I would really prefer not to spend (Unless I can do the work once, hit "Add rF2 material" to the resultant object once, and then duplicate that + rename. That's a little better and less tedious).

    EDIT: Found the "Separate by material" part, but even after trying the following:

    1. Adding an "edge split" modifier with "sharp edges" enabled and the angle set to 180
    2. Apply the modifier
    3. Add rFactor 2 material to object
    4. Show smoothing groups
    5. Separate faces by material
    6. Join the separated objects back together
    7. Re-add rFactor 2 material to object, switch back to the material I was using before (It also resets any additional UVs, which is annoying if I'm going to have to do this constantly)

    And still no difference. I also noticed that after doing all this once, if I go to do it again, the "Show smoothing groups" function adds all the smoothing group colors in the materials but doesn't actually assign them to any of the faces. Not sure if that's a bug or that means something is incorrect.

    Am I missing something fundamental here?
     
    Last edited: Dec 4, 2022
    Mauro likes this.
  5. DiggerHawk

    DiggerHawk Registered

    Joined:
    Jul 29, 2020
    Messages:
    249
    Likes Received:
    310
    It looks to me like you have the mesh set to Face output normals instead of Vertex output normals. The setting is at the bottom of the Object Data Properties tab in Blender. Once that is set to Vertex try "show smoothing groups" again and it should look a lot less colourful. With all faces being the same colour, meaning they all belong to the same smoothing group in affect. If you add a Split edge modifier with just Sharp edges ticked, you can then define the boundaries between smoothing groups by marking the edges sharp. You could also use the edge angle (30 deg is about right) option to do it automatically, but the "show smoothing groups" tool won't work until the modifier is applied as it seems to work based on edges being marked sharp or actually split. You also want "Auto smooth" off in the Object Data Properties tab because when it is on it will override the results of the edge split modifier in the display.

    The next step then is to make sure any faces that share an edge that is marked sharp are separated in the UV map to avoid reflection glitches. I think rF2 tries to continue the reflection across the two faces even though they should be two separate reflections. Thats how I understand it anyway.

    Alot of the older posts in this thread by me are now obsolete because I was learning as I went, so It can be very confusing to read with contradictory information.

    I hope this can be helpful, if not I will try to help some more.
     
  6. frootsnax

    frootsnax Registered

    Joined:
    Dec 4, 2022
    Messages:
    3
    Likes Received:
    2

    Thanks for the tip! I had no idea those options were buried that deep within all of the properties that the script adds.


    Did some quick testing with some of S397's own meshes without any extra edge split modifiers added; I just made sure auto-smooth was off and that "vertex normals" were selected after converting the object to an rFactor 2 object. So far, the results are exponentially better and way more in line with what I was expecting:

    [​IMG]

    It kinda seems to me like you would just want everything to use the "vertex" option in the "Output Normals" section, rather than the default of "face" or the "up" option. Am I wrong?

    EDIT: Another thing I've just noticed, is that using "Add rFactor 2 Material" on an object that has multiple UV channels already assigned appears to remove them, leaving just one:

    [​IMG]

    [​IMG]

    In a case where I'm importing meshes that have already been UV mapped on all of the necessary RF2-specific channels, should I not be using the "Add rFactor 2 Material" function? Is the workflow instead supposed to be "Add rFactor 2 Object", update the material name / image, delete the generated cube, then set the parent of the imported mesh to the parent object and then change the material of the imported mesh to the one I just updated?

    Follow Up Edit: I think I've figured out how to maintain any already-present UV maps on imported meshes:

    1. Import your mesh
    2. Change the material on the imported object so the nodes match what get generated when you use the "Add rFactor 2 Material" function:
    [​IMG]
    3. Create a new rFactor 2 parent object using the "Add rFactor 2 Object" function, re-naming it and adjusting the file name as needed
    4. Set the imported object's parent as the newly-added rFactor 2 parent object
    5. You'll now have to manually add a bunch of things that the function normally takes care of for you:

    5a: Add "Diffuse Color", "Diffuse Alpha", "Specular Color" and "Specular Alpha" vertex color layers. I don't think you actually have to put anything in here, they just need to be present
    [​IMG]

    5b: Check the following flags under the "Object Data Properties > rFactor2 Mesh Flags" section:
    [​IMG]

    5c: Check the following flags under the "Material Properties > rFactor2 Material Settings" section:
    [​IMG]

    5d: Set the following under the "Material Properties > rFactor2 Material Settings" section (Use alpha values of 1.00 for each of the colors):
    [​IMG]

    5e: Set the following flags and enter the following fields further down in the "Material Properties > rFactor2 Material Settings" section:
    [​IMG]


    Assuming I didn't forget to mention anything, you should be able to export the imported object and any present UV maps will be maintained and everything will show up in engine as expected:

    [​IMG]

    I may edit the script myself to add a function that adds all the prerequisite properties and values from the steps above without changing the UV maps, unless that's a feature that's coming in the next iteration of the scripts. If not, I'm offering this up as a suggestion for a new feature ;)

    The "Add rFactor 2 Material" works fine for meshes that don't already have a named material and UV maps applied, but a separate function that just adds the flags and properties without changing the material that's been applied to the faces on the object and also retains any UV maps already present would be super helpful and might make working with imported meshes far quicker, I think
     
    Last edited: Dec 4, 2022
    Mauro likes this.
  7. DiggerHawk

    DiggerHawk Registered

    Joined:
    Jul 29, 2020
    Messages:
    249
    Likes Received:
    310
    It seems you have managed to figure it out and I am glad I could point you in the right direction regarding the Vertex output normals. I think the other two output normals options have their uses but not for what I do.

    If you select an object then assign the "Legacy Diffuse Shader, L2DIFFUSET0" preset it should assign the correct properties to the object and keep the first UV map. The other options can be used to configure the object to use two, three or four UV maps. But I think it just duplicates the first UV map again. I only use one UV map anyway as it can be confusing managing multiple UV maps and avoiding accidentally editing the wrong one. All my models use the "L2DIFFUSET0" preset except when I need a bump map, then I use the "L2BUMPT0" preset but the second UV map is just a duplicate of the first.

    What method are you using to import into Blender?
     
  8. Haris1977

    Haris1977 Registered

    Joined:
    Nov 25, 2019
    Messages:
    401
    Likes Received:
    195
    Out of curiosity:

    Downloaded a previous Blender version (2.93.11, just to be safe), installed the addon on 1rst page, but i get nothing in import / export section. Images here:

    [​IMG]

    [​IMG]

    What am i doing wrong?
     
  9. FuNK!

    FuNK! Registered

    Joined:
    May 26, 2013
    Messages:
    626
    Likes Received:
    491
    Just look a little right from the File menu. There is a new menu called "rfactor2" ;)
     
    Haris1977 likes this.
  10. Haris1977

    Haris1977 Registered

    Joined:
    Nov 25, 2019
    Messages:
    401
    Likes Received:
    195
    Yeap :( didn't see it at first..

    But again i am sure i miss smth here.

    Is there any tutorial about how exactly can i use this? A small video of how you export an obj would be handy here for those (like me) who are not familiar either with Blender (i only know the basics) or the addon :)

    (@Traveller i think the best way is to give you my file as a 'sample' for the video, so tell me if y want to pm you in order to keep the forum not overloaded with my issues here:))

    For example: I have loaded an fbx file (with a house mesh). The house has 4 different materials assigned. I then go to rFactor2 tab -> export GMT's but i get an error (i thought it would just work out of the box)

    I am 100% sure i need to adjust more things here..

    [​IMG]
     
    Last edited: Dec 7, 2022
  11. FuNK!

    FuNK! Registered

    Joined:
    May 26, 2013
    Messages:
    626
    Likes Received:
    491
    AFAIK there is no tutorial or manual. But there are some posts at the beginning of this thread, where you should be able to learn how to use this addon.
     
  12. Haris1977

    Haris1977 Registered

    Joined:
    Nov 25, 2019
    Messages:
    401
    Likes Received:
    195
    I tried to follow @dxp_rlong (from page 3):

    So, i selected my obj (blue_house in my scene). This mesh has 4 materials assigned as you see here:

    [​IMG]

    But when i go to rFactor2-> add rfactor2 material, it creates an rFactor_2 PBR mat in the place of my first mat (ramp_mat.001)

    [​IMG]

    giving me this image:

    [​IMG]

    So, what can be wrong?
     
  13. redapg

    redapg Registered

    Joined:
    Jan 16, 2012
    Messages:
    3,958
    Likes Received:
    2,808
    @Haris1977 I still would recommend to not to waste your Time with old Blender and rF2 Export Script Versions.
    Just wait until @Traveller releases his new Ones. ;)
    They probably will be different from the current Ones, due to the Changes in Blender, like he did say already.
     
    Leonardo1962 likes this.
  14. Haris1977

    Haris1977 Registered

    Joined:
    Nov 25, 2019
    Messages:
    401
    Likes Received:
    195
    I know Chris.

    But that doesn't change the fact that (even with the new scripts) i will still not know what i have to do...(unless Traveller writes a simple 'how to use this addon', which i don't know if he will..)
     
  15. frootsnax

    frootsnax Registered

    Joined:
    Dec 4, 2022
    Messages:
    3
    Likes Received:
    2
    From my understanding, you need to break up objects inside the rF2 parent object based on the materials they use. The easiest way to do this is select your object, go into edit mode, go to the 'Mesh' menu, then 'Separate', then 'By Material' (Alternatively, you can hit the 'P' key and select 'By Material' from that shortcut menu)

    From there, you can select each of these sub-objects individually and edit their active materials to give them all the necessary properties. Additionally, make sure the sub-objects are all parented to the rF2 parent object. Your hierarchy in Blender will likely end up looking like the following:

    [​IMG]
     
  16. Haris1977

    Haris1977 Registered

    Joined:
    Nov 25, 2019
    Messages:
    401
    Likes Received:
    195
    Thanks will try it :)
     
  17. Garitt Gibsn

    Garitt Gibsn Registered

    Joined:
    Dec 13, 2017
    Messages:
    149
    Likes Received:
    236
    @Traveller, Is it possible to create animated objects as GMT with ANIM file?
     
  18. Traveller

    Traveller Member

    Joined:
    Oct 7, 2010
    Messages:
    862
    Likes Received:
    485
    That has been a deficiency in the scripts. I can't figure out the rigging. I've come close, importing a car mod with a wiper, but no cigar. Figuring out the rigging is step one. Working ANM files into it would then be next. If anyone has any ideas...
     
  19. Traveller

    Traveller Member

    Joined:
    Oct 7, 2010
    Messages:
    862
    Likes Received:
    485
    I saw a question concerning documentation. There is the documentation for the first release, 0.75, toward the end of the first post here. It is somewhat dated for these scripts, and out of date for what is currently being worked on. However, the foundation info is there.

    There will not be a release by Christmas. A couple of ideas came up within the past two weeks that fit very well with the current direction of the scripts, and position them where I want them at release. Implementing those ideas and getting at least some sanity testing done by Christmas is not possible In addition, the ideas will break backward compatibility with older .blends. Once they are in and working, I'll write a utility routine accessible via the rF2 Menu in Blender to bring those .blends up to the new standard. I have several old .blends that will be perfect test subjects.
     
  20. Emery

    Emery Registered

    Joined:
    Oct 24, 2010
    Messages:
    3,035
    Likes Received:
    1,654
    That's fine by me. For the third time in the past decade or so, I'm trying to learn Blender. After a few days, it seems to finally be taking hold on me now by practicing some drills and I might achieve adequate profiency for simracing purposes by the end of the month.
     

Share This Page