Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ endif()
add_subdirectory(nosReflect)
add_subdirectory(nosStrings)
add_subdirectory(nosAnimation)
add_subdirectory(nosGraphics)

nos_get_targets(PLUGINS_COMMON_EXTERNAL_TARGETS "./External")
nos_group_targets("${PLUGINS_COMMON_EXTERNAL_TARGETS}" "External")
26 changes: 26 additions & 0 deletions Plugins/nosGraphics/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
set(NOS_VULKAN_NAME "nos.sys.vulkan")
set(NOS_VULKAN_VERSION "6.0")

set(NOS_TRACK_NAME "nos.track")
set(NOS_TRACK_VERSION "1.9")

set(MODULE_DEPENDENCIES "${NOS_VULKAN_NAME}-${NOS_VULKAN_VERSION}" "${NOS_TRACK_NAME}-${NOS_TRACK_VERSION}")
set(dep_idx 0)
foreach(module_name_version ${MODULE_DEPENDENCIES})
# module_name_version: <MODULE_NAME>-<MODULE_VERSION>
string(REPLACE "-" ";" module_name_version ${module_name_version})
list(GET module_name_version 0 module_name)
list(GET module_name_version 1 module_version)
nos_get_module("${module_name}" "${module_version}" DEP_${dep_idx})
list(APPEND MODULE_DEPENDENCIES_TARGETS ${DEP_${dep_idx}})
endforeach()
list(APPEND MODULE_DEPENDENCIES_TARGETS ${NOS_PLUGIN_SDK_TARGET})

nos_find_module_path(${NOS_VULKAN_NAME} ${NOS_VULKAN_VERSION} NOS_VULKAN_PATH)

set(GENERATED_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/Generated")
nos_generate_flatbuffers("${CMAKE_CURRENT_SOURCE_DIR}/Config" "${GENERATED_OUTPUT_DIR}" "cpp" "${NOS_SDK_DIR}/Types;${NOS_VULKAN_PATH}" nosGraphics_generated)

list(APPEND MODULE_DEPENDENCIES_TARGETS nosGraphics_generated)
set(INCLUDE_FOLDERS "${GENERATED_OUTPUT_DIR}")
nos_add_plugin("nosGraphics" "${MODULE_DEPENDENCIES_TARGETS}" "${INCLUDE_FOLDERS}")
63 changes: 63 additions & 0 deletions Plugins/nosGraphics/Config/BillboardMask.nosdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"nodes": [
{
"class_name": "BillboardMask",
"menu_info": {
"category": "Rendering",
"display_name": "Billboard Mask"
},
"node": {
"contents_type": "Job",
"pins": [
{
"name": "Position",
"type_name": "nos.fb.vec3",
"show_as": "INPUT_PIN",
"can_show_as": "INPUT_PIN_OR_PROPERTY"
},
{
"name": "Size",
"type_name": "nos.fb.vec2",
"show_as": "INPUT_PIN",
"can_show_as": "INPUT_PIN_OR_PROPERTY",
"data": {
"x": 100.0,
"y": 100.0
}
},
{
"name": "RenderView",
"type_name": "nos.graphics.RenderView",
"show_as": "INPUT_PIN",
"can_show_as": "INPUT_PIN_OR_PROPERTY"
},
{
"name": "Resolution",
"type_name": "nos.fb.vec2u",
"show_as": "PROPERTY",
"can_show_as": "INPUT_PIN_OR_PROPERTY",
"data": {
"x": 1920,
"y": 1080
}
},
{
"name": "OutRenderTarget",
"type_name": "nos.sys.vulkan.Texture",
"show_as": "OUTPUT_PIN",
"can_show_as": "OUTPUT_PIN_OR_PROPERTY"
},
{
"name": "OutDepth",
"type_name": "nos.sys.vulkan.Texture",
"show_as": "OUTPUT_PIN",
"can_show_as": "OUTPUT_PIN_OR_PROPERTY",
"data": {
"format": "D32_SFLOAT"
}
}
]
}
}
]
}
46 changes: 46 additions & 0 deletions Plugins/nosGraphics/Config/Graphics.fbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
include "Common.fbs";

namespace nos.graphics;

table PerspectiveProjection
{
aspect_ratio: float;
fov_x: float;
}

table OrthographicProjection
{
width: float;
height: float;
}

enum ProjectionType : ubyte
{
Perspective,
Orthographic
}

table Projection
{
clip_planes: nos.fb.vec2 (native_inline);
center_shift: nos.fb.vec2 (native_inline);
projection_type: ProjectionType;
perspective: PerspectiveProjection;
orthographic: OrthographicProjection;
}

table RenderView
{
view: nos.fb.mat4(native_inline);
left_handed_projection_matrix: nos.fb.mat4(native_inline);
projection: Projection;
}

struct Transform
{
position: nos.fb.vec3d;
rotation: nos.fb.vec3d;
scale: nos.fb.vec3d;
}

// TODO: Move nos.fb.Transform here too
35 changes: 35 additions & 0 deletions Plugins/nosGraphics/Config/TrackToView.nosdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"nodes": [
{
"class_name": "TrackToView",
"menu_info": {
"category": "Rendering",
"display_name": "Track To View"
},
"node": {
"contents_type": "Job",
"pins": [
{
"name": "Track",
"type_name": "nos.track.Track",
"show_as": "INPUT_PIN",
"can_show_as": "INPUT_PIN_OR_PROPERTY"
},
{
"name": "Clip",
"type_name": "nos.fb.vec2",
"show_as": "INPUT_PIN",
"can_show_as": "INPUT_PIN_OR_PROPERTY",
"data": {"x": 0.1, "y": 10000.0}
},
{
"name": "View",
"type_name": "nos.graphics.RenderView",
"show_as": "OUTPUT_PIN",
"can_show_as": "OUTPUT_PIN_ONLY"
}
]
}
}
]
}
28 changes: 28 additions & 0 deletions Plugins/nosGraphics/Graphics.noscfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"info": {
"id": {
"name": "nos.graphics",
"version": "0.1.0"
},
"description": "Types & Nodes for graphics operations.",
"display_name": "Graphics",
"category": "Graphics",
"dependencies": [
{
"name": "nos.sys.vulkan",
"version": "6.0"
},
{
"name": "nos.track",
"version": "1.9"
}
]
},
"custom_types": [ "Config/Graphics.fbs" ],
"node_definitions": [
"Config/BillboardMask.nosdef",
"Config/TrackToView.nosdef"
],
"binary_path": "Binaries/nosGraphics",
"associated_nodes": []
}
9 changes: 9 additions & 0 deletions Plugins/nosGraphics/Shaders/BillboardMask.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#version 450
#extension GL_EXT_scalar_block_layout : enable

layout(location = 0) out vec4 rt;

void main()
{
rt = vec4(1.0);
}
23 changes: 23 additions & 0 deletions Plugins/nosGraphics/Shaders/BillboardMask.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#version 450
#extension GL_EXT_scalar_block_layout : enable

layout (binding = 0, std430) uniform UBO
{
mat4 MVP;
} ubo;

const vec2 pos[6] =
vec2[6](
vec2(+0.5, +1.0),
vec2(-0.5, +1.0),
vec2(+0.5, 0.0),
vec2(+0.5, 0.0),
vec2(-0.5, +1.0),
vec2(-0.5, 0.0));

void main()
{
vec4 vertPos = vec4(pos[gl_VertexIndex].x, 0.0, pos[gl_VertexIndex].y, 1.0);
vec4 clipPos = ubo.MVP * vertPos;
gl_Position = clipPos;
}
Loading