From 465c655ed742c3c46d8dbccd4d6e1426e0751278 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Wed, 22 Sep 2021 20:27:12 +0200 Subject: [PATCH] Add a property to control the Metallic Specular of generated materials A value of 0.0 generally suits retro-looking games better, as it prevents most environment reflections from being visible on the materials. --- README.md | 44 ++++++++++++++++------------ addons/gldsrcBSP/src/BSP_Map.gd | 3 ++ addons/gldsrcBSP/src/levelBuilder.gd | 2 ++ 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 7ab7655..7dd6468 100644 --- a/README.md +++ b/README.md @@ -4,31 +4,30 @@ A plugin that allows you to laod GoldSrc BSP files into Godot ## Video Demo [![](https://i.imgur.com/UbihCVB.png)](https://www.youtube.com/watch?v=-gloaTbZxmU) - + ## Installation -Copy the "addons" folder into the root directory of the Godot Project - -Go to Project->Project Settings->Plugins and set the plugins status to "Active" - -## Usage +Copy the "addons" folder into the root directory of the Godot Project + +Go to Project->Project Settings->Plugins and set the plugins status to "Active" + +## Usage **Note that this isn't finished yet and is only here for testing purposes. Currently it only works by linkng the external GoldSrc game directory and as such can't yet be included into your Godot Project Directory** ![](https://i.imgur.com/FINHIjn.png) -Drag the BSP_Map.tscn file from the addons/gldsrcBSP folder into the scene tree. - -Enter thet path to the bsp in "Path" field and Press "Create Map" - -If you want the map to generate on runtime don't press "Create Map" and it will automatically be created on launch. - +Drag the BSP_Map.tscn file from the addons/gldsrcBSP folder into the scene tree. + +Enter thet path to the bsp in "Path" field and Press "Create Map" + +If you want the map to generate on runtime don't press "Create Map" and it will automatically be created on launch. + ## Entities - -This plugin supports various but not all entities. -If you want a body to trigger/interact with the entities add it to the "hlTrigger" group. +This plugin supports various but not all entities. +If you want a body to trigger/interact with the entities add it to the "hlTrigger" group. -## Lightmaps +## Lightmaps You can import lightmaps from the BSP file but you will need to set your enviroment to "Clear Color" and up the ambient light. @@ -49,7 +48,14 @@ manually to act as shadow casters. For global illumination, GIProbe can be used as the resulting MeshInstances are set to be used in baked light. However, BakedLightmap will not work correctly as UV2 isn't generated properly for the generated meshes. -## Media +## Material appearance + +By default, Metallic Specular is set to 0.0 on generated materials to make reflections from the sky +much less visible. This is good for retro-looking games, but the physically correct setting is 0.5 +(which is also the default in SpatialMaterial). If you wish to have a more realistic appearance, +adjust the Materials Metallic Specular property in the BSP_Map scene in the inspector. + +## Media -![](https://i.imgur.com/STAOPjS.jpg) -![](https://i.imgur.com/UtKyFi5.png) \ No newline at end of file +![](https://i.imgur.com/STAOPjS.jpg) +![](https://i.imgur.com/UtKyFi5.png) diff --git a/addons/gldsrcBSP/src/BSP_Map.gd b/addons/gldsrcBSP/src/BSP_Map.gd index ab49f75..2c596de 100644 --- a/addons/gldsrcBSP/src/BSP_Map.gd +++ b/addons/gldsrcBSP/src/BSP_Map.gd @@ -48,6 +48,9 @@ export var enableEntities = true export var disableSound = false export var textureLights = false +# Defaults to 0.0 for a more "retro" appearance with fewer reflections from the environment. +export(float, 0.0, 1.0, 0.01) var materialsMetallicSpecular = 0.0 + var simpleCombine = true var physicsPropsDontRotate = true var playerSpawn = {"position":Vector3.ZERO,"rotation":Vector3.ZERO} diff --git a/addons/gldsrcBSP/src/levelBuilder.gd b/addons/gldsrcBSP/src/levelBuilder.gd index d2fcd6a..01d9865 100644 --- a/addons/gldsrcBSP/src/levelBuilder.gd +++ b/addons/gldsrcBSP/src/levelBuilder.gd @@ -360,6 +360,8 @@ func createMat(texture,textureName,render = null): mat.flags_world_triplanar = true mat.emission_enabled = true + # Allow metallic specular control to avoid issues with the environment being too reflective. + mat.metallic_specular = get_parent().materialsMetallicSpecular #mat.emission_texture = #mat.uv1_triplanar = true get_parent().saveToMaterialCache(matCacheName,mat)