alternative view model rendering mode with rescaled weapon

This commit is contained in:
2022-05-29 20:37:16 +03:00
parent 6975f92644
commit 5d12548cbc
4 changed files with 45 additions and 21 deletions

View File

@@ -107,7 +107,6 @@
"ID": "56eddcef4698702bd3cb0b8a1fb3396f", "ID": "56eddcef4698702bd3cb0b8a1fb3396f",
"TypeName": "FlaxEngine.EmptyActor", "TypeName": "FlaxEngine.EmptyActor",
"ParentID": "a50f3639419a8306036ecfab7115e772", "ParentID": "a50f3639419a8306036ecfab7115e772",
"IsActive": false,
"Name": "ViewModelHolder", "Name": "ViewModelHolder",
"Transform": { "Transform": {
"Translation": { "Translation": {
@@ -128,17 +127,17 @@
} }
}, },
{ {
"ID": "9ef0c1b8412a19d04d298c840ca4f456", "ID": "99f2289f4f483aba1fcabdba40a2c899",
"PrefabID": "7f0707924e86984317e6a78b55e68245", "PrefabID": "7f0707924e86984317e6a78b55e68245",
"PrefabObjectID": "056a93524632b9e0d83c6fbcbd020680", "PrefabObjectID": "056a93524632b9e0d83c6fbcbd020680",
"ParentID": "56eddcef4698702bd3cb0b8a1fb3396f", "ParentID": "56eddcef4698702bd3cb0b8a1fb3396f",
"StaticFlags": 0 "StaticFlags": 0
}, },
{ {
"ID": "743289494a7bd68f6a28df86ea7a04c8", "ID": "234dca27419c27d758db29953fd9f992",
"PrefabID": "7f0707924e86984317e6a78b55e68245", "PrefabID": "7f0707924e86984317e6a78b55e68245",
"PrefabObjectID": "bb8115cf4fd8d0906b1e928a171763c5", "PrefabObjectID": "bb8115cf4fd8d0906b1e928a171763c5",
"ParentID": "9ef0c1b8412a19d04d298c840ca4f456", "ParentID": "99f2289f4f483aba1fcabdba40a2c899",
"Buffer": { "Buffer": {
"Entries": [ "Entries": [
{} {}
@@ -146,10 +145,10 @@
} }
}, },
{ {
"ID": "002d17944803ee2ca1f3cd88bc76b68e", "ID": "35b52ef2410d20988207d59d3b9c4a1c",
"PrefabID": "7f0707924e86984317e6a78b55e68245", "PrefabID": "7f0707924e86984317e6a78b55e68245",
"PrefabObjectID": "a54aa52147b86b56df27fdaa9ba7ca52", "PrefabObjectID": "a54aa52147b86b56df27fdaa9ba7ca52",
"ParentID": "9ef0c1b8412a19d04d298c840ca4f456", "ParentID": "234dca27419c27d758db29953fd9f992",
"Buffer": { "Buffer": {
"Entries": [ "Entries": [
{} {}

View File

@@ -17,7 +17,7 @@
"Translation": { "Translation": {
"X": 7.394218921661377, "X": 7.394218921661377,
"Y": -11.22248649597168, "Y": -11.22248649597168,
"Z": -3.27702260017395 "Z": -3.2770228385925295
}, },
"Orientation": { "Orientation": {
"X": 0.6691311001777649, "X": 0.6691311001777649,
@@ -27,7 +27,7 @@
}, },
"Scale": { "Scale": {
"X": 0.07999999821186066, "X": 0.07999999821186066,
"Y": 0.431741327047348, "Y": 0.43174129724502566,
"Z": 0.07999999821186066 "Z": 0.07999999821186066
} }
}, },
@@ -48,24 +48,18 @@
{ {
"ID": "a54aa52147b86b56df27fdaa9ba7ca52", "ID": "a54aa52147b86b56df27fdaa9ba7ca52",
"TypeName": "FlaxEngine.StaticModel", "TypeName": "FlaxEngine.StaticModel",
"ParentID": "056a93524632b9e0d83c6fbcbd020680", "ParentID": "bb8115cf4fd8d0906b1e928a171763c5",
"Name": "Cylinder2", "Name": "Cylinder2",
"Transform": { "Transform": {
"Translation": { "Translation": {
"X": 7.35720682144165, "X": -0.46265125274658205,
"Y": -9.197076797485352, "Y": 44.85169982910156,
"Z": 15.981095314025879 "Z": -0.016492605209350587
},
"Orientation": {
"X": 0.6691311001777649,
"Y": 0.0,
"Z": 0.0,
"W": 0.7431443929672241
}, },
"Scale": { "Scale": {
"X": 0.09000000357627869, "X": 1.125,
"Y": 0.05855093151330948, "Y": 0.1356157809495926,
"Z": 0.09000000357627869 "Z": 1.125
} }
}, },
"StaticFlags": 0, "StaticFlags": 0,

View File

@@ -25,6 +25,11 @@ namespace Game
public override int Order => 110; public override int Order => 110;
public override bool CanRender => camera.IsActive; public override bool CanRender => camera.IsActive;
private bool useMainCamera = true;
public bool rescaleModel = true;
private Actor viewModelHolder;
private void CreateTextures(int width, int height) private void CreateTextures(int width, int height)
{ {
GPUTextureDescription textureDesc = GPUTextureDescription.New2D(width, height, PixelFormat.R8G8B8A8_UNorm); GPUTextureDescription textureDesc = GPUTextureDescription.New2D(width, height, PixelFormat.R8G8B8A8_UNorm);
@@ -45,6 +50,20 @@ namespace Game
public override void OnAwake() public override void OnAwake()
{ {
viewModelHolder = Parent.Parent.Parent.Parent.GetChild("ViewModelHolder");
if (useMainCamera)
{
camera.IsActive = false;
void foo(Actor actor)
{
actor.Layer = 0;
foreach (Actor actChild in actor.GetChildren<Actor>())
foo(actChild);
}
foo(viewModelHolder);
}
if (!camera.IsActive) if (!camera.IsActive)
return; return;
@@ -96,6 +115,7 @@ namespace Game
Renderer.DrawPostFxMaterial(context, ref renderContext, materialInstance, output, input.View()); Renderer.DrawPostFxMaterial(context, ref renderContext, materialInstance, output, input.View());
} }
private bool lastRescale = false;
public override void OnUpdate() public override void OnUpdate()
{ {
#if FLAX_EDITOR #if FLAX_EDITOR
@@ -117,6 +137,15 @@ namespace Game
sceneTask2.RenderingPercentage = MainRenderTask.Instance.RenderingPercentage * 0.5f; sceneTask2.RenderingPercentage = MainRenderTask.Instance.RenderingPercentage * 0.5f;
} }
if (useMainCamera && rescaleModel != lastRescale)
{
lastRescale = rescaleModel;
if (rescaleModel)
viewModelHolder.Scale = new Vector3(0.75f);
else
viewModelHolder.Scale = new Vector3(1.0f);
}
if (!camera.IsActive) if (!camera.IsActive)
return; return;
if (texture == null) if (texture == null)

View File

@@ -219,6 +219,8 @@ namespace Game
globals.SetValue("Scene Lighting", boolValue); globals.SetValue("Scene Lighting", boolValue);
// TODO: make sure AO is disabled (it's not)
Light[] lights = Level.GetActors<Light>(); Light[] lights = Level.GetActors<Light>();
foreach (Light light in lights) foreach (Light light in lights)
light.IsActive = boolValue; light.IsActive = boolValue;