-
Notifications
You must be signed in to change notification settings - Fork 73
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
[F3D] Add material bleeding to FMesh GfxLists #186
Conversation
…global F3D panel settings
…inline material, and use a material name of the mesh plus the offset of the material DL inside the inline mesh Gfx. Also fixed a bug where tile scrolls for tiles not set would still export, resulting in UB behavior
…m fModel for inheritance of inline property, cleaned up and clarified some comments
Ok I understand, there is currently an issue with the geo layout writer not knowing which DLs to use when multiple layers are written. I will fix this in an upcoming commit. |
…h.draw objects interfering with DL referencing
Naming issue has been resolved. Geo layouts should now properly reference the correct bled display list. |
It compiles now, thank you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried testing a map export, which fails to compile. There are a couple other errors as well - I think this should have been tested more before being PR'd. However, the main issue I have is organization. I've mentioned this before, but this PR adds a bunch of to_c_inline
functions which does display list building when it should only be doing c exporting, adding a lot of unnecessary code in the process. In FMesh.bleed()
, instead of saving data to a bleed_gfx
class, the final inlined DL can just be built there and saved over FMesh.draw
. FMesh
can then use FMesh.inline
to determine which data to export in FMesh.to_c()
. This removes the need for to_c_inline
functions, and also the various other inline checks that are done when handling FMesh writing.
The tile scrolling bleed is a bit hacky, although thats more due to the original tile scrolling being inflexible. I have some issue with how that's organized as well, although that's a whole other thing. Instead, bleed() could save an OrderedDict[FMaterial, tileCommandIndices] to FMesh
. FMesh.to_c_vertex_scroll
can then be refactored so that it executes code that processes this dict along side the fully inlined DL if inline is true. This would remove the need to create new FMaterials
.
I've made a couple comments that might not be relevant anymore if to_c_inline
is removed. A couple of the errors here are also irrelevant in this case.
I will address the naming, large mat and cull issues in a commit. Also if possible I would like to know what caused the compilation issue if it was something other than vtx culling. |
I'm not sure, vtx culling was as far as I got. I also forgot to mention, I have a tile scrolling issue: I'm trying to export a mesh with two materials, one with s/t tile scrolling and another with s tile scrolling, but only one of the material's tile scrolling code is being exported. |
… added more consistency with inline checks, made fMesh inline exporting act from FMesh.draw instead of constructing from individual gfx components, vtx culling now works with inline materials
I have fixed the issues with culling exporting and tile scrolling and improved the names for a lot of variables. Now exporting is done by making use of the fMesh.draw object, and it is appended to using the triGroup.bleed data after bleeding for that triGroup is finished. I also use this time to add in the tile scroll indices (or at least where to start searching for them). The theory of operation is still mostly the same, it is just organized differently to take the work out of the I have also written a new tile scrolling method for inline materials. This method is basically the same as the original, but it uses data from the triGroup to select the correct GfxList, and to find the tile indices. I was not able to completely get rid of the As far as the decision to keep |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me it seems like the to_c_inline
can be removed, and instead FMesh.inline
can be used inside to_c
to get the desired result. I'm still not seeing the point in saving bled data intermediately in FTriGroup, as everything can still be done in bleed()
. If you want to add additional functionality that uses that info, then you can add callbacks inside bleed()
that are implemented by game specific classes which pass in the desired display lists.
I can add an onBleedEnd method and store the bleed prop but I use the bleed to hold the tile scroll information, so it needs to be stored somewhere. |
I was thinking of a callback that would be added inside the loop iterating over triGroups, not at the end. I don't see why the bleed data would be needed after bleeding is done, since the final output of bleed is to merge all the bled display lists together. Also, editing that inlined DL would invalidate tile indices. I still disagree with the location of tile scrolling indices (its a property of a specific display list first before being a property of a material), but you can just store that in the triGroup itself. Also, just for future reference I don't think its a good idea to continue using the method of modifying static display lists for dynamic behaviour - we should find a way to use dynamic DLs or pointers in static DLs. |
Im not sure what the issue is with modifying Static data is as its something that's always been done for tile scrolls. It isn't like the DLs are literally labelled as Static in the output file. |
Also more on why store the bled list, it is because I don't want to store set tile scroll indices to the inline DL, but a pointer to the material start. This makes the code more flexible for other dynamic properties added in the future. If desired, there could easily be changes made to add dynamic palettes, or dynamic texture loads using the most of the same code, because the inlined material is easily accessible. Either way I need to store the indices, and the DL to parse, for the tile scroll code to work unless I supercede all of that and do it in bleed, but why would I do tile scrolling inside of the bleed method, instead of give the access to variables so that I can use the (mostly) existing tile scroll code. |
Like I said, you can add a callback inside the triGroup loop in bleed() to do this. Whats the purpose of halfway calculating the index in bleed() and then saving intermediate display lists to finish calculating it again in tileScrollInlineMaterialToC() when you can just calculate it all at once in bleed()? Spreading index management through multiple locations just makes things confusing. |
If I remove the triGroup.bleed property I would have to do the full parsing of tile scroll indices inside the FMesh.bleed function. |
This is just pushing the complexity down to lower levels where it makes things more cluttered. In the future we could change it if we need it, but I'm not seeing in what case you would want to access these DLs after inlining them. The whole idea of inlining implies that it should be done once the higher level abstractions of materials/meshes aren't needed anymore. |
…ized logic throughout code so that it works with those changes
Ok I made the changes. Basically all the inline checks are removed throughout the repo. There are a few misc changes in here besides bleeding, such as annotations or changing some properties in GbiMacros to be more consistent (all tile props are called "tile" instead of some being "tile" and others being "t") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest changes are an improvement. I made a couple more comments about decoupling bleeding from the f3d_gbi classes. I also think that at this point all the bleed code in f3d_gbi.py
should be moved into its own file.
fast64_internal/f3d/f3d_gbi.py
Outdated
if not fModel.inline: | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes for removing inline
. You can actually throw an error here as well if you want to make it easier for developers to know that this is a necessary condition for bleeding.
if not fModel.inline: | |
return | |
if not fModel.matWriteMethod != GfxMatWriteMethod.WriteAll: | |
return |
def __init__(self, f3dType, isHWv1, name, DLFormat): | ||
FModel.__init__(self, f3dType, isHWv1, name, DLFormat, GfxMatWriteMethod.WriteDifferingAndRevert) | ||
def __init__(self, f3dType, isHWv1, name, DLFormat, inline = False): | ||
FModel.__init__(self, f3dType, isHWv1, name, DLFormat, GfxMatWriteMethod.WriteDifferingAndRevert, inline = inline) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like this in order to remove inline
from FModel
:
FModel.__init__(self, f3dType, isHWv1, name, DLFormat, GfxMatWriteMethod.WriteDifferingAndRevert, inline = inline) | |
FModel.__init__(self, f3dType, isHWv1, name, DLFormat, GfxMatWriteMethod.WriteAll if inline else GfxMatWriteMethod.WriteDifferingAndRevert) |
fast64_internal/f3d/f3d_gbi.py
Outdated
name: str, | ||
DLFormat: "DLFormat", | ||
matWriteMethod: GfxMatWriteMethod, | ||
inline=False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inline
should be removed, with the code creating the model being responsible for setting the correct GfxMatWriteMethod
.
if not fModel.inline: | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This happens multiple times, but with inline
removed these checks should be moved outside these classes.
You commented it in several places so Ill just make a general reply. |
Well the overriding is happening either way regardless, the only difference is the location where it happens. Aside from separation of concerns between bleeding and exporting, I wasn't a huge fan of overriding the write method in the init function anyway, its kind of a code gotcha. At least with this change if you pass a write method into init, you know thats what the write method is going to be. |
… is overridden from inside FModel to its initialization calls
Ok I changed the construction of the FModel classes so that the passed mat write method is what gets used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inline
variables/checks should be removed from FModel and any subclasses of it. The inline
checks happening at the beginning of the bleed functions can be moved right outside of those functions. SM64Model
can have the write method passed to it instead of inline
.
…nd subclasses explicit from passed arguments
Ok I removed all uses of inline as a property and made it a bool either passed to a function, or used as a ternary for mat write methods. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The gfx scroll inline arguments can be removed as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, forgot my attached comment.
fast64_internal/f3d/f3d_gbi.py
Outdated
data = CScrollData() | ||
if not self.inline: | ||
if not inline: | ||
for _, (fMaterial, _) in self.materials.items(): | ||
fMaterial: FMaterial | ||
data.append(gfxFormatter.gfxScrollToC(fMaterial.material, self.f3d)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both fMaterial.material
and fMesh.draw
can be handled (works for either bleed on/off) as long as fMaterial.material
is None checked, letting you remove inline
from this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call
Fixed duplicate scroll variable names
I can't replicate this issue. Could you post the exported mesh DL during the F3D export? |
|
Ok I believe I know what is happening. |
|
…t used materials are kept track of during jump nodes
The issue was related to the usage of rooms. I added a boolean to the geo layout bleed function to change how last used materials are bleed in the case where rooms are used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good to me, I'll merge this soon unless there are any other issues that come up.
This commit will allow users to export mesh gfx lists with material bleeding. What this will do is remove unnecessary DL cmds inside the gfxlist, and make all the DL cmds part of one gfx list. This option is added as a checkbox in the global f3d settings.
This commit also adjusts texture scrolls for sm64 so that they work with mat bleeding, and fixes a bug where not setting a texture still exported a tile scroll for that material (which would cause UB in game).
This commit has been tested to successfully export multiple test sm64 levels and has been verified to work on console. No testing has been done for OOT.