Disable / Hide Exterior Building
- Macadaynu
- Posts: 264
- Joined: Sun Mar 07, 2021 1:18 pm
Disable / Hide Exterior Building
Does anyone know how to disable or hide an Exterior Building?
Disabling an entire DaggerfallBlock is easy enough, but I need to disable a specific building within that block at runtime. Just being able to resize it to 0 will do, I just need to make it not visible to the player.
I am working on this mod: viewtopic.php?t=4533
And one problem I have found when testing is that not all buildings actually have the same size outside as inside, here is an example:
So the easiest solution I can think of is just disable the current Exterior Building you are inside of at the moment, as you won't be able to see the building you are looking out from anyway.
I think this would be much cleaner than going through and correcting each building that has mismatched sizing somehow.
Is this possible?
Disabling an entire DaggerfallBlock is easy enough, but I need to disable a specific building within that block at runtime. Just being able to resize it to 0 will do, I just need to make it not visible to the player.
I am working on this mod: viewtopic.php?t=4533
And one problem I have found when testing is that not all buildings actually have the same size outside as inside, here is an example:
So the easiest solution I can think of is just disable the current Exterior Building you are inside of at the moment, as you won't be able to see the building you are looking out from anyway.
I think this would be much cleaner than going through and correcting each building that has mismatched sizing somehow.
Is this possible?
- BadLuckBurt
- Posts: 948
- Joined: Sun Nov 05, 2017 8:30 pm
Re: Disable / Hide Exterior Building
For performance reasons, Daggerfall Unity combines all exterior buildings into one because of this setting:
While you can turn that off in the editor to debug stuff, the released builds all have that switched on.
I wonder if you could manually 'clip' the RMB mesh against a cube volume.
If you were to calculate the bounding box of the interior and then use a cube of that size to cull / hide that part of the RMB mesh while in the interior, that should give you the result you're after.
While you can turn that off in the editor to debug stuff, the released builds all have that switched on.
I wonder if you could manually 'clip' the RMB mesh against a cube volume.
If you were to calculate the bounding box of the interior and then use a cube of that size to cull / hide that part of the RMB mesh while in the interior, that should give you the result you're after.
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt
.
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt
.
- Macadaynu
- Posts: 264
- Joined: Sun Mar 07, 2021 1:18 pm
Re: Disable / Hide Exterior Building
Thanks for this suggestion, I have tried many methods to do this but the closest I have got is an example I found here:BadLuckBurt wrote: ↑Sat Jan 01, 2022 9:18 am For performance reasons, Daggerfall Unity combines all exterior buildings into one because of this setting:
While you can turn that off in the editor to debug stuff, the released builds all have that switched on.
I wonder if you could manually 'clip' the RMB mesh against a cube volume.
If you were to calculate the bounding box of the interior and then use a cube of that size to cull / hide that part of the RMB mesh while in the interior, that should give you the result you're after.
https://answers.unity.com/questions/176 ... a-box.html
What this is doing is only rendering textures within the cube's volume, what I need is the opposite (so that textures are only rendered outside of the cube).
I wonder if anyone knows how to achieve this by modifying the below shader script? I think it's just the clip methods that need modifying, but everything I've tried up to now has not worked how I would want it to.
Code: Select all
Shader "Custom/ClipBox" {
Properties{
_MainTex("Albedo (RGB)", 2D) = "white" {}
_Glossiness("Smoothness", Range(0,1)) = 0.5
_Metallic("Metallic", Range(0,1)) = 0.0
}
SubShader{
Tags { "RenderType" = "Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Standard fullforwardshadows addshadow
#pragma target 3.0
sampler2D _MainTex;
half _Glossiness;
half _Metallic;
float4x4 _WorldToBox;
struct Input {
float2 uv_MainTex;
float3 worldPos;
};
void surf(Input IN, inout SurfaceOutputStandard o) {
float3 boxPosition = mul(_WorldToBox, float4(IN.worldPos, 1));
clip(boxPosition + 0.5);
clip(0.5 - boxPosition);
fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
- BadLuckBurt
- Posts: 948
- Joined: Sun Nov 05, 2017 8:30 pm
Re: Disable / Hide Exterior Building
Sadly I've never worked with shaders, they're odd creatures.
I'm thinking it may need some more math to reverse that clipping process, maybe related to the distance of the cube compared to the RMB edges. I really should've paid more attention in math class back then.
I'll report back if I find something useful.
I'm thinking it may need some more math to reverse that clipping process, maybe related to the distance of the cube compared to the RMB edges. I really should've paid more attention in math class back then.
I'll report back if I find something useful.
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt
.
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt
.
- pango
- Posts: 3359
- Joined: Wed Jul 18, 2018 6:14 pm
- Location: France
- Contact:
Re: Disable / Hide Exterior Building
Code: Select all
clip(boxPosition + 0.5);
clip(0.5 - boxPosition);
So to reverse the conditions, you have compute opposite values:
Code: Select all
clip(- boxPosition - 0.5);
clip(boxPosition - 0.5);
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart
- Macadaynu
- Posts: 264
- Joined: Sun Mar 07, 2021 1:18 pm
Re: Disable / Hide Exterior Building
Thanks Pango, I gave that a go but unfortunately the textures don't render inside or outside of the cube (no matter where the cube is)pango wrote: ↑Mon Jan 03, 2022 10:18 pmclipping is based on the sign of the parameter, if a negative value is computed the pixel is not rendered.Code: Select all
clip(boxPosition + 0.5); clip(0.5 - boxPosition);
So to reverse the conditions, you have compute opposite values:Code: Select all
clip(- boxPosition - 0.5); clip(boxPosition - 0.5);
- pango
- Posts: 3359
- Joined: Wed Jul 18, 2018 6:14 pm
- Location: France
- Contact:
Re: Disable / Hide Exterior Building
Thinking a bit more about it, the fact there's 2 clip() in sequence does the same as an OR condition: if either one of the values is negative, the pixel is skipped.Macadaynu wrote: ↑Mon Jan 03, 2022 11:16 pmThanks Pango, I gave that a go but unfortunately the textures don't render inside or outside of the cube (no matter where the cube is)Code: Select all
clip(- boxPosition - 0.5); clip(boxPosition - 0.5);
So, to reverse the overall skipping condition, not only each condition has to be negated, but the resulting conditions ANDed together instead or ORed together (De Morgan's law).
That cannot be expressed with two clip()s in sequence, and I can't think of a simple function of two parameters that's negative if and only if its two parameters are negative, so all I could think of is:
Code: Select all
clip(abs(boxPosition) - 0.5);
Code: Select all
if (all(boxPosition > -0.5 && boxPosition < 0.5))
discard;
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart
- Macadaynu
- Posts: 264
- Joined: Sun Mar 07, 2021 1:18 pm
Re: Disable / Hide Exterior Building
Amazing! That did it, thank you so much Pango and Burtpango wrote: ↑Tue Jan 04, 2022 12:26 am
P.S. In fact clip() on a float3 checks if any of the coordinates is negative (cf clip()); So applying De Morgan's law again, this any() should become an all() when the condition is negated. clip() can't be used to achieve this; Instead you have to use something like
I haven't tested, so I don't even guarantee it compilesCode: Select all
if (all(boxPosition > -0.5 && boxPosition < 0.5)) discard;
- Magicono43
- Posts: 1143
- Joined: Tue Nov 06, 2018 7:06 am
Re: Disable / Hide Exterior Building
Show a screenshot of what it looks like in action now, pretty curious
- BadLuckBurt
- Posts: 948
- Joined: Sun Nov 05, 2017 8:30 pm
Re: Disable / Hide Exterior Building
All credit to Pango, I just threw the idea out there without any idea how to implement it. My brain melted a bit reading Pango's posts but happy to hear that it works. If it all works out, this will be the first TES game that has this feature. Lord knows people ask for this in every TES game
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt
.
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt
.