Files
OpenSpace/data/assets/examples/pointclouds/points.asset
Emma Broman f36868d1c4 Feature/textured points (#3068)
* WIP: Start usign texture arrays instead of just a single texture

Now the texture array is sucessfully created, sent over and sampled on the GPU

* Include information about the texture format alpha channel and do a conversion

* Make one draw wcall per texture array

* Add scale to size mapping and move to a separate component

* WIP: Make single textures work again, with texture array

Although this breaks the polygon cloud..

* Also make the polygon cloud work again

* Refactor rendering code

* handle array layer seprately from texture coordinates

* Make sure use size mapping uniform is always set

Fixes point cloud disappearing when multi-textures points are enabled

* Add has value check to size mapping

* Fix indentation

* Make sure points are rendered even when no texture is used

* Clean up texture handling a bit and add comment about storage creation

* Add comment and temporary asset changes

* Clean up handling of color mode (number of colro channels)

* Make interpolated points work with new rendering code

* Refactor

* Bring back check for valid index for color and size data

* Make sure to check if the provided data file exists

* Fix full path ont showing in error message

* Refactor rendering code a bit

* Change how the multitexture setup is configured in the asset and add documentation

Separating made documentation a lot easier..

* Add a todo comment for future discussion

* Add settings for texture compression

* Preserve aspects ratio of rendered textures

* Restructure input parameters for texture details

* Simplify color mode - we decided to not support grayscale

* Add option to set "useAlpha" from asset

* Enable texture per default and fix aspect ratio problem when no texture is used

* tiny refactor

* Fix polygon rendering that broke when adding texture compression

* Remove color in polygon shader

The color would be applied twice in rendering

* Restructure textures code and prevent loading the same texture twice

* Better handling of extra texture parameter in speck files

That does not lead to limitations in using dashes in texture names

* Add some docs and communicate texture mode to the user

* Fix so that single texture can be changed during runtime

* Allow changing compression and usealpha during runtime

* Update texture storage allocation to something that works in older OpenGL versions

* Add a check that checks if we use more texture layers than allowed

* Even more robust check of texture line in speck file (allow extra whitespaces)

* Update data mapping to include texture information and clean up code a bit

* Error handling and prevent loading non-used textures in texture map

* Update some docs

* Small cleanup

* Add one more error message for fault texture map file format

* Remove test version of tully images dataset

* Small refactor

* Add example asset

* Update Ghoul - for larger uniform cache

* Purge texture from ram when we're done with it

* Cleanup (comments, ugly png check, etc)

* Apply suggestions from code review

Co-authored-by: Alexander Bock <alexander.bock@liu.se>

* Apply suggestions from code review

* Adress some more review comments and fix broken asset

* More code review fixes

* Read provided sizemapping parameter from asset

* Fix warnings from trying to shift 16 bit int 32 bits :)

* simplify datamapping hash string

* Update comment that was not 100% correct. The file names may be specified as relative paths to a folder

* Small update based on previous code review comments

* Fix multi textured points gui path not same as other points

* Update Folder description to reduce some confusion

* Apply suggestions from code review

Co-authored-by: Ylva Selling <ylva.selling@gmail.com>

* Prevent updates to polygon cloud texture during runtime

This lead to rendering problems.

* Add describing comments to data files

* Clarify why speck version is disabled per default

* Update and clarify confusing size mapping parameters

* Apply suggestions from code review

Co-authored-by: Ylva Selling <ylva.selling@gmail.com>

* Apply suggestions from code review

---------

Co-authored-by: Alexander Bock <alexander.bock@liu.se>
Co-authored-by: Ylva Selling <ylva.selling@gmail.com>
2024-03-19 13:17:25 +01:00

246 lines
7.7 KiB
Lua

local earthAsset = asset.require("scene/solarsystem/planets/earth/earth")
local colormaps = asset.require("util/default_colormaps")
-- Color mapped points close to Earth, with some different settings for color and
-- sizing, and a StaticRotation that makes them not overlap
-- Point cloud with fixed color and default size (fixed)
local FixedColor_FixedSize = {
Identifier = "ExamplePoints_FixedSize",
Parent = earthAsset.Earth.Identifier,
Renderable = {
Type = "RenderablePointCloud",
File = asset.resource("data/dummydata.csv"),
Coloring = {
FixedColor = { 0.0, 0.5, 0.0 }
}
},
GUI = {
Name = "Fixed Color / Fixed Size",
Path = "/Example/Point Clouds",
Description = "Point cloud with a fixed color and fixed sizing"
}
}
-- Point cloud with fixed color and size scaling that is limited by a certain size
local FixedColor_MaxSize = {
Identifier = "ExamplePoints_MaxSize",
Parent = earthAsset.Earth.Identifier,
Transform = {
Rotation = {
Type = "StaticRotation",
Rotation = { 0, 0, 0.5 * math.pi }
}
},
Renderable = {
Type = "RenderablePointCloud",
File = asset.resource("data/dummydata.csv"),
Coloring = {
FixedColor = { 0.0, 1.0, 1.0 }
},
SizeSettings = {
MaxSize = 0.7,
EnableMaxSizeControl = true
}
},
GUI = {
Name = "Fixed Color / Max Size",
Path = "/Example/Point Clouds",
Description = "Point cloud with a fixed color and sizing with a given max size"
}
}
-- Point cloud with color mapping and fixed point sizing
local ColorMapped_FixedSize = {
Identifier = "ExamplePoints_ColorMapped",
Parent = earthAsset.Earth.Identifier,
Transform = {
Rotation = {
Type = "StaticRotation",
Rotation = { 0, 0, -0.5 * math.pi }
}
},
Renderable = {
Type = "RenderablePointCloud",
File = asset.resource("data/dummydata.csv"),
Coloring = {
ColorMapping = {
File = colormaps.Uniform.Viridis
}
},
SizeSettings = {
-- Here we set the exponent for the scale explicitly, to a value that
-- gives the points a suitable size based on their world-space coordinates
ScaleExponent = 6.5
}
},
GUI = {
Name = "Color Mapped",
Path = "/Example/Point Clouds",
Description = "Color mapped point cloud with fixed sizing"
}
}
-- Point cloud with fixed color and size scaling from a selected data column
local FixedColor_ScaleBasedOnData = {
Identifier = "ExamplePoints_ScaleFromData",
Parent = earthAsset.Earth.Identifier,
Transform = {
Rotation = {
Type = "StaticRotation",
Rotation = { 0, 0.5 * math.pi, 0 }
}
},
Renderable = {
Type = "RenderablePointCloud",
File = asset.resource("data/dummydata.csv"),
Coloring = {
FixedColor = { 0.5, 0.5, 0.0 }
},
SizeSettings = {
SizeMapping = {
-- The options for the columns that the points can be scaled by. The first
-- alternative in the list is chosen per default
ParameterOptions = { "a", "b" },
-- Specify which option we want to use for size mapping at start up. Here we
-- use the last of the provided options rather than the first one, which is
-- otherwise used by default
Parameter = "b"
},
-- Use a slightly smaller scale than above for the base size of the points
-- (will decide the size of the smallest point). That way, the points don't
-- become too big when scaled by the data parameter
ScaleExponent = 5.0
}
},
GUI = {
Name = "Fixed Color / Size From Data",
Path = "/Example/Point Clouds",
Description = [[Point cloud with a fixed color and sizing that can be set based on a
column in the dataset]]
}
}
-- Point cloud with textures. Textured points can also be color mapped, but here it
-- is disabled per default
local Textured = {
Identifier = "ExamplePoints_Textured",
Parent = earthAsset.Earth.Identifier,
Transform = {
Rotation = {
Type = "StaticRotation",
Rotation = { 0, math.pi, 0 }
}
},
Renderable = {
Type = "RenderablePointCloud",
File = asset.resource("data/dummydata.csv"),
Texture = {
-- The path to the texture file. Here we use openspace.absPath so that we can use
-- the ${DATA} token to get the path to a texture in the "OpenSpace/data" folder,
-- but for a file at a relative location it would also work to use asset.resource,
-- like for the data file above
File = openspace.absPath("${DATA}/test3.jpg"),
},
-- Disable additive blending, so that points will be rendered with their actual color
-- and overlapping points will be sorted by depth. This works best when the points
-- have an opacity of 1
UseAdditiveBlending = false,
Coloring = {
ColorMapping = {
-- Disable color map per default. When enabled, the texture color will be
-- multiplied with the color from the color map
Enabled = false,
File = colormaps.Uniform.Viridis
}
}
},
GUI = {
Name = "Textured",
Path = "/Example/Point Clouds",
Description = "Point cloud with a texture per point"
}
}
-- Point cloud with more advanced color mapping and fixed point sizing.
-- Here we have predefined a couple of parameters to use for the color mapping.
-- Also, missing/NaN values are mapped to a specific color.
-- Finally, no additive blending is used for the color, meaning that the color of
-- overlapping points will not be mixed/added
local ColorMappedAdvanced_NoBlend = {
Identifier = "ExamplePoints_ColorMappedNoBlend",
Parent = earthAsset.Earth.Identifier,
Transform = {
Rotation = {
Type = "StaticRotation",
Rotation = { 0, 0, math.pi }
}
},
Renderable = {
Type = "RenderablePointCloud",
File = asset.resource("data/dummydata.csv"),
UseAdditiveBlending = false, -- Disable additive blending
Coloring = {
ColorMapping = {
File = colormaps.Uniform.Viridis,
ParameterOptions = {
{ Key = "number_withNan" }, -- no range => compute min and max
{ Key = "normaldist_withMissing", Range = { -0.5, 0.5 } }
},
ShowMissingData = true,
NoDataColor = { 0.5, 0.5, 0.5, 1.0 }
}
},
SizeSettings = {
ScaleExponent = 6.5
}
},
GUI = {
Name = "Color Mapped (Advanced) - No blending",
Path = "/Example/Point Clouds",
Description = [[Color mapped point cloud without additive blending, with missing
values shown in grey, and a limited choice of parameter options to use for
the color mapping.]]
}
}
asset.onInitialize(function()
openspace.addSceneGraphNode(FixedColor_FixedSize)
openspace.addSceneGraphNode(FixedColor_MaxSize)
openspace.addSceneGraphNode(FixedColor_ScaleBasedOnData)
openspace.addSceneGraphNode(Textured)
openspace.addSceneGraphNode(ColorMapped_FixedSize)
openspace.addSceneGraphNode(ColorMappedAdvanced_NoBlend)
end)
asset.onDeinitialize(function()
openspace.removeSceneGraphNode(ColorMappedAdvanced_NoBlend)
openspace.removeSceneGraphNode(ColorMapped_FixedSize)
openspace.removeSceneGraphNode(Textured)
openspace.removeSceneGraphNode(FixedColor_ScaleBasedOnData)
openspace.removeSceneGraphNode(FixedColor_MaxSize)
openspace.removeSceneGraphNode(FixedColor_FixedSize)
end)
asset.export(FixedColor_FixedSize)
asset.export(FixedColor_MaxSize)
asset.export(FixedColor_ScaleBasedOnData)
asset.export(Textured)
asset.export(ColorMapped_FixedSize)
asset.export(ColorMappedAdvanced_NoBlend)
asset.meta = {
Name = "Example - Point Clouds",
Version = "1.0",
Description = [[Examples of point clouds with a few different settings for sizing and
coloring]],
Author = "OpenSpace Team",
URL = "http://openspaceproject.com",
License = "MIT license"
}