Skip to content

Commit

Permalink
Merge branch 'master' into vulkan
Browse files Browse the repository at this point in the history
  • Loading branch information
kaffeewolf authored Jan 27, 2025
2 parents d0604a1 + d8e45fb commit 8d0aa5f
Show file tree
Hide file tree
Showing 132 changed files with 4,574 additions and 1,074 deletions.
36 changes: 22 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,21 @@ Check out the documentation (WIP) here: https://gscept.github.io/nebula-doc/
3. Added to PATH
4. Installed with debugging symbols and binaries

#### Other useful references and tools
* [Vulkan SDK](https://vulkan.lunarg.com/) and [Vulkan Documentation](https://docs.vulkan.org/) for render pipeline debugging
* [What is Fips](https://floooh.github.io/fips/)

## Quick Start

The fastest way to setup and test nebula is to clone the [Nebula-demo](https://github.com/gscept/nebula-demo) instead. It contains a setup.bat which will setup dependencies and configure a
solution for you to run. If you add a `-editor` commandline argument it will start with the editor ui enabled.
solution for you to run via `fips open`.
Alternatively you can build and run the project manually with `fips build`, `fips run assetbatcher` and `fips run nebula-demo --`. If you add a `-editor` commandline argument it will start with the editor ui enabled.
Apart from that there are a few simple projects in the test folder.
Fips will take care of getting the relevant dependencies (including the actual engine in case you are setting up a external project)

## Normal setup
If you want to proceed with the normal setup you can follow the instructions below.
Proceed to the project iteration section afterwards.

#### Setup config

Expand All @@ -40,36 +46,38 @@ If you want to proceed with the normal setup you can follow the instructions bel
Run `fips nebula` verb to set work and toolkit directory registry variables:

* `fips nebula set work {PATH}` (If you are building an external project, this would be the current path)
* `fips nebula set toolkit {PATH}` (this is the path to where the nebula checkout resides, if an external project that would be ../nebula)
* `fips nebula set toolkit {PATH}` (this is the path to where the nebula checkout resides, if an external project that would be `../nebula`)

#### Build project
#### Build project dependencies

In your project directory:

1. `fips physx build vc17 debug` (if you are running VS 2022, use `vc16` or `vc15` for vs 2019/2017 instead)
2. `fips anyfx setup`
3. `fips gen` to generate the required build system files, e.g. a visual studio solution
4. `fips build` to directly compile the project
or
`fips open` to open the generated solution in your selected environment

## Iterating on the project
Once the project is setup and working there are some common operations that you may have to perform.
Once the project is set up and working there are some common operations that you may have to perform.
Most of the steps and operations are required to be completed at least once to be able to run the project.

### Adding files
### Adding files`fips gen`
If you are adding new files, either source or templates or other flatbuffer things that you add to cmake or a cmake subfolder will typically picked up by running `fips gen`. This will regenerate your solution via cmake, in case you are using visual studio it will normally
notice and prompt reloading. Generally calling `fips gen` is a safe operation you can do if dependencies change etc.

### Updating dependencies
#### Location of build files
Fips will place the solution and makefiles and the like in the `../fips-build/{PROJECT-NAME}/{CONFIG}/` folder. Easiest is to just use `fips open` to start your editor

### Updating dependencies – `fips update`
The project you are working in is commonly synced with e.g. git or some other version control, if you have other fips dependencies that changed, you can do a `fips update` to perform a git pull on the depencies used.

### Dealing with content
### Compiling the project – `fips build`
(Re-)Building the project is possible either via the generated solution (`fips open` to open it quickly) or manually with `fips build`.

### Dealing with content – `fips run assetbatcher --`
Content is usually batched using the `assetbatcher` contained in the nebula repository which is built by default by projects as well. Running it will incrementally convert or cook content in your `work` folder to an export folder in the project location. It has a number of options to force or only batch specific folders, as well as
the option to be run in parallel. Running it with `-help` will print some of the options available.

### Location of build files
Fips will place the solution and makefiles and the like in the ../fips-build/projectname/projectconfig/ folder. Easiest is to just use `fips open` to start your editor

## Running the project
To run the debug project without editor tools, use `fips run {PROJECT-NAME}` or run a debug session in your solution opened with `fips open`. Use `fips run {PROJECT-NAME} -- -editor` to run the project with editor ui enabled.

## Features
Nebula is being developed continuously, which means that features keep getting added all the time. Currently, we support this:
Expand Down
3 changes: 2 additions & 1 deletion code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ add_subdirectory(physics)
add_subdirectory(application)
add_subdirectory(addons)
add_subdirectory(audio)
add_subdirectory(input)
add_subdirectory(input)
add_subdirectory(options)
47 changes: 38 additions & 9 deletions code/addons/dynui/imgui/shaders/imgui.fx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
#include "lib/shared.fxh"
#include "lib/defaultsamplers.fxh"


// put variables in push-constant block
push constant ImGUI [ string Visibility = "PS|VS"; ]
{
mat4 TextProjectionModel;
uint ColorMask;
uint PackedTextureInfo;
float RangeMin;
float RangeMax;
};

group(BATCH_GROUP) sampler_state TextureSampler
Expand All @@ -37,13 +41,31 @@ render_state TextState
//------------------------------------------------------------------------------
/**
*/
void UnpackTexture(uint val, out uint id, out uint type, out uint mip, out uint layer, out uint useAlpha)
void
UnpackTexture(uint val, out uint id, out uint type, out uint mip, out uint layer, out uint useRange, out uint useAlpha)
{
const uint TEXTURE_TYPE_MASK = 0xF;
const uint TEXTURE_LAYER_MASK = 0xFF;
const uint TEXTURE_MIP_MASK = 0xF;
const uint TEXTURE_USE_RANGE_MASK = 0x1;
const uint TEXTURE_USE_ALPHA_MASK = 0x1;
const uint TEXTURE_ID_MASK = 0xFFF;

type = val & TEXTURE_TYPE_MASK;
layer = (val >> 4) & TEXTURE_LAYER_MASK;
mip = (val >> 12) & TEXTURE_MIP_MASK;
useRange = (val >> 16) & TEXTURE_USE_RANGE_MASK;
useAlpha = (val >> 17) & TEXTURE_USE_ALPHA_MASK;
id = (val >> 18) & TEXTURE_ID_MASK;
}

//------------------------------------------------------------------------------
/**
*/
vec4
UnpackMask(uint val)
{
type = val & 0xF;
layer = (val >> 4) & 0xFF;
mip = (val >> 12) & 0xFF;
useAlpha = (val >> 20) & 0x1;
id = (val >> 21) & 0xFFF;
return vec4(val & 0x1, (val >> 1) & 0x1, (val >> 2) & 0x1, (val >> 3) & 0x1);
}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -75,8 +97,8 @@ psMain(
[color0] out vec4 FinalColor)
{
vec4 texColor;
uint id, type, layer, mip, useAlpha;
UnpackTexture(ImGUI.PackedTextureInfo, id, type, mip, layer, useAlpha);
uint id, type, layer, mip, useAlpha, useRange;
UnpackTexture(ImGUI.PackedTextureInfo, id, type, mip, layer, useRange, useAlpha);
if (type == 0)
texColor = sample2DLod(id, TextureSampler, UV, mip);
else if (type == 1)
Expand All @@ -86,12 +108,19 @@ psMain(
ivec3 size = textureSize(make_sampler3D(id, TextureSampler), int(mip));
texColor = sample3DLod(id, TextureSampler, vec3(UV, layer / float(size.z)), mip);
}

if (useRange != 0)
{
texColor.rgb = (texColor.rgb - ImGUI.RangeMin) / (ImGUI.RangeMax - ImGUI.RangeMin);
}

if (useAlpha == 0)
texColor.a = 1;

vec4 mask = UnpackMask(ImGUI.ColorMask);

// Since we are using sRGB output, remember to degamma
FinalColor = Color * texColor;
FinalColor = Color * texColor * mask;
}


Expand Down
59 changes: 53 additions & 6 deletions code/addons/dynui/imguicontext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,24 @@ ImguiDrawFunction(const CoreGraphics::CmdBufferId cmdBuf, const Math::rectangle<

struct TextureInfo
{
uint32 type : 4;
uint32 layer : 8;
uint32 mip : 8;
uint32 useAlpha : 1;
uint32 id : 11;
uint type : 4;
uint layer : 8;
uint mip : 4;
uint useRange : 1;
uint useAlpha : 1;
uint id : 11;
};

union ColorMask
{
struct
{
uint red: 1;
uint green: 1;
uint blue: 1;
uint alpha: 1;
};
uint bits = 0xF;
};

IndexT vertexOffset = 0;
Expand Down Expand Up @@ -175,6 +188,7 @@ ImguiDrawFunction(const CoreGraphics::CmdBufferId cmdBuf, const Math::rectangle<

TextureInfo texInfo;
texInfo.type = 0;
texInfo.useRange = tex.useRange;
texInfo.useAlpha = tex.useAlpha;

// set texture in shader, we shouldn't have to put it into ImGui
Expand All @@ -199,7 +213,19 @@ ImguiDrawFunction(const CoreGraphics::CmdBufferId cmdBuf, const Math::rectangle<
texInfo.mip = tex.mip;
texInfo.id = CoreGraphics::TextureGetBindlessHandle(texture);

ColorMask colorMask;
colorMask.red = tex.red;
colorMask.green = tex.green;
colorMask.blue = tex.blue;
colorMask.alpha = tex.alpha;

CoreGraphics::CmdPushConstants(cmdBuf, CoreGraphics::GraphicsPipeline, ImguiContext::state.packedTextureInfo, sizeof(TextureInfo), (byte*)& texInfo);
CoreGraphics::CmdPushConstants(cmdBuf, CoreGraphics::GraphicsPipeline, ImguiContext::state.colorMaskConstant, sizeof(ColorMask), (byte*)&colorMask);
if (texInfo.useRange)
{
CoreGraphics::CmdPushConstants(cmdBuf, CoreGraphics::GraphicsPipeline, ImguiContext::state.rangeMinConstant, sizeof(float), &tex.rangeMin);
CoreGraphics::CmdPushConstants(cmdBuf, CoreGraphics::GraphicsPipeline, ImguiContext::state.rangeMaxConstant, sizeof(float), &tex.rangeMax);
}

// setup primitive
CoreGraphics::PrimitiveGroup primitive;
Expand Down Expand Up @@ -343,6 +369,9 @@ ImguiContext::Create()

state.textProjectionConstant = CoreGraphics::ShaderGetConstantBinding(state.uiShader, "TextProjectionModel");
state.packedTextureInfo = CoreGraphics::ShaderGetConstantBinding(state.uiShader, "PackedTextureInfo");
state.rangeMinConstant = CoreGraphics::ShaderGetConstantBinding(state.uiShader, "RangeMin");
state.rangeMaxConstant = CoreGraphics::ShaderGetConstantBinding(state.uiShader, "RangeMax");
state.colorMaskConstant = CoreGraphics::ShaderGetConstantBinding(state.uiShader, "ColorMask");

state.inputHandler = ImguiInputHandler::Create();
Input::InputServer::Instance()->AttachInputHandler(Input::InputPriority::DynUi, state.inputHandler.upcast<Input::InputHandler>());
Expand All @@ -353,7 +382,7 @@ ImguiContext::Create()
components.Append(VertexComponent(1, VertexComponent::Float2, 0));
components.Append(VertexComponent(2, VertexComponent::UByte4N, 0));
state.vlo = CoreGraphics::CreateVertexLayout({ .name = "ImGui"_atm, .comps = components });

#if WITH_NEBULA_EDITOR
if (App::GameApplication::IsEditorEnabled())
{
Expand Down Expand Up @@ -394,6 +423,24 @@ ImguiContext::Create()
});
}

FrameScript_default::RegisterSubgraphPipelines_ImGUI_Pass([](const CoreGraphics::PassId pass, uint subpass)
{
CoreGraphics::InputAssemblyKey inputAssembly{ CoreGraphics::PrimitiveTopology::TriangleList, false };
if (state.editorPipeline != CoreGraphics::InvalidPipelineId)
CoreGraphics::DestroyGraphicsPipeline(state.editorPipeline);
state.pipeline = CoreGraphics::CreateGraphicsPipeline({ state.prog, pass, subpass, inputAssembly });
});

FrameScript_default::RegisterSubgraph_ImGUI_Pass([](const CoreGraphics::CmdBufferId cmdBuf, const Math::rectangle<int>& viewport, const IndexT frame, const IndexT bufferIndex)
{
#ifdef NEBULA_NO_DYNUI_ASSERTS
ImguiContext::RecoverImGuiContextErrors();
#endif
//ImGui::Render();
//ImguiDrawFunction(cmdBuf, viewport, false);
});


SizeT numBuffers = CoreGraphics::GetNumBufferedFrames();

CoreGraphics::BufferCreateInfo vboInfo;
Expand Down
10 changes: 10 additions & 0 deletions code/addons/dynui/imguicontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ struct ImguiTextureId
uint layer : 8 = 0;
uint mip : 4 = 0;
uint useAlpha : 1 = 0;
uint useRange : 1 = 0;
float rangeMin, rangeMax;
uint red : 1 = 1;
uint green : 1 = 1;
uint blue : 1 = 1;
uint alpha : 1 = 1;

};

class ImguiContext : public Graphics::GraphicsContext
Expand Down Expand Up @@ -79,6 +86,9 @@ class ImguiContext : public Graphics::GraphicsContext

IndexT textProjectionConstant;
IndexT packedTextureInfo;
IndexT rangeMinConstant;
IndexT rangeMaxConstant;
IndexT colorMaskConstant;
CoreGraphics::ResourceTableId resourceTable;
//Ptr<CoreGraphics::BufferLock> vboBufferLock;
//Ptr<CoreGraphics::BufferLock> iboBufferLock;
Expand Down
2 changes: 1 addition & 1 deletion code/addons/graphicsfeature/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
nebula_begin_module(graphicsfeature)
nebula_flatc(SYSTEM graphicsfeature/graphicsfeatureschema.fbs graphicsfeature/terrainschema.fbs graphicsfeature/vegetationschema.fbs)
fips_deps(render application dynui tbui nflatbuffer)
target_precompile_headers(graphicsfeature PRIVATE <application/stdneb.h>)
fips_ide_group(features)
Expand All @@ -20,6 +19,7 @@ fips_dir(components)
decal.json
lighting.json
model.json
gi.json
)
nebula_end_module()

81 changes: 81 additions & 0 deletions code/addons/graphicsfeature/components/gi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"namespace": "GraphicsFeature",
"components": {
"DDGIVolume": {
"graphicsEntityId": {
"type": "uint",
"default": -1,
"hideInInspector": true
},
"numProbesX": {
"type": "uint",
"default": 8
},
"numProbesY": {
"type": "uint",
"default": 8
},
"numProbesZ": {
"type": "uint",
"default": 8
},
"numRaysPerProbe": {
"type": "uint",
"default": 188
},
"relocate": {
"type": "bool",
"default": false,
"description": "Relocate probes if they are inside geometry"
},
"scrolling": {
"type": "bool",
"default": false,
"description": "Scroll probes infinitely based on camera position"
},
"updateBudget": {
"type": "float",
"default": 1.0,
"description": "Percentage of probes to update per frame, 1.0 means 100%"
},
"classify": {
"type": "bool",
"default": false,
"description": "Automatically disable probes that hit no geometry. This is to save performance. Said probes shoot a minimal set of rays to check if they should invalidate their status"
},
"irradianceScale": {
"type": "float",
"default": 1,
"description": "Energy of output irradiance"
},
"normalBias": {
"type": "float",
"default": 0.1,
"description": "Adds distance on surface along normal direction to avoid aliasing"
},
"viewBias": {
"type": "float",
"default": 0.1,
"description": "Adds distance on surface along camera view direction to avoid aliasing"
},
"distanceExponent": {
"type": "float",
"default": 50
},
"hysteresis": {
"type": "float",
"default": 0.97
},
"borderBlendCutoff": {
"type": "float",
"default": 0.0,
"description": "Percentage distance from the volume edge where blending should start"
},
"borderBlend": {
"type": "float",
"default": 0.0,
"description": "Blend gradient factor based on cutoff point and outer edge of volume"
}
}
}
}
Loading

0 comments on commit 8d0aa5f

Please sign in to comment.