commit bca439438f14b751f723dcf5e4de51c00ebe4660 parent bda5dd55a9203a05e210fc13c66fafd4bcbea24b Author: Vincent Forest <vincent.forest@meso-star.com> Date: Mon, 30 Oct 2023 15:34:30 +0100 Merge branch 'feature_posix_make' into develop Diffstat:
| M | .gitignore | | | 13 | +++++++------ |
| A | Makefile | | | 153 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| M | README.md | | | 37 | +++++++++++++++++-------------------- |
| D | cmake/CMakeLists.txt | | | 123 | ------------------------------------------------------------------------------- |
| A | config.mk | | | 77 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| D | doc/mrumtl | | | 28 | ---------------------------- |
| D | doc/mrumtl.5.scd | | | 108 | ------------------------------------------------------------------------------- |
| A | make.sh | | | 71 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | mrumtl.5 | | | 104 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | mrumtl.pc.in | | | 10 | ++++++++++ |
10 files changed, 439 insertions(+), 285 deletions(-)
diff --git a/.gitignore b/.gitignore @@ -1,11 +1,12 @@ .gitignore -CMakeCache.txt -CMakeFiles -Makefile -tmp [Bb]uild* *.sw[po] -*.[ao] -*.orig +*.[aod] +*.so *~ +test* +!test*.[ch] +.config +.test tags +*.pc diff --git a/Makefile b/Makefile @@ -0,0 +1,153 @@ +# Copyright (C) 2020, 2023 |Méso|Star> (contact@meso-star.com) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +.POSIX: +.SUFFIXES: # Clean up default inference rules + +include config.mk + +LIBNAME_STATIC = libmrumtl.a +LIBNAME_SHARED = libmrumtl.so +LIBNAME = $(LIBNAME_$(LIB_TYPE)) + +################################################################################ +# Library building +################################################################################ +SRC = src/mrumtl.c src/mrumtl_log.c src/mrumtl_fetch.c +OBJ = $(SRC:.c=.o) +DEP = $(SRC:.c=.d) + +build_library: .config $(DEP) + @$(MAKE) -fMakefile $$(for i in $(DEP); do echo -f $${i}; done) \ + $$(if [ -n "$(LIBNAME)" ]; then \ + echo "$(LIBNAME)"; \ + else \ + echo "$(LIBNAME_SHARED)"; \ + fi) + +$(DEP) $(OBJ): config.mk + +$(LIBNAME_SHARED): $(OBJ) + $(CC) $(CFLAGS_SO) $(RSYS_CFLAGS) -o $@ $(OBJ) $(LDFLAGS_SO) $(RSYS_LIBS) + +$(LIBNAME_STATIC): libmrumtl.o + $(AR) -rc $@ $? + $(RANLIB) $@ + +libmrumtl.o: $(OBJ) + $(LD) -r $(OBJ) -o $@ + $(OBJCOPY) $(OCPFLAGS) $@ + +.config: config.mk + @if ! $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys; then \ + echo "rsys $(RSYS_VERSION) not found" >&2; exit 1; fi + @echo "config done" > $@ + +.SUFFIXES: .c .d .o +.c.d: + @$(CC) $(CFLAGS_SO) $(RSYS_CFLAGS) -MM -MT "$(@:.d=.o) $@" $< -MF $@ + +.c.o: + $(CC) $(CFLAGS_SO) $(RSYS_CFLAGS) -DMRUMTL_SHARED_BUILD -c $< -o $@ + +################################################################################ +# Installation +################################################################################ +pkg: + sed -e 's#@PREFIX@#$(PREFIX)#g'\ + -e 's#@VERSION@#$(VERSION)#g'\ + -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\ + mrumtl.pc.in > mrumtl.pc + +mrumtl-local.pc: mrumtl.pc.in + sed -e '1d'\ + -e 's#^includedir=.*#includedir=./src/#'\ + -e 's#^libdir=.*#libdir=./#'\ + -e 's#@VERSION@#$(VERSION)#g'\ + -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\ + mrumtl.pc.in > $@ + +install: build_library pkg + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib" $(LIBNAME) + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib/pkgconfig" mrumtl.pc + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/include" src/mrumtl.h + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/doc/mrumtl" COPYING README.md + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/man/man5" mrumtl.5 + +uninstall: + rm -f "$(DESTDIR)$(PREFIX)/lib/$(LIBNAME)" + rm -f "$(DESTDIR)$(PREFIX)/lib/pkgconfig/mrumtl.pc" + rm -f "$(DESTDIR)$(PREFIX)/share/doc/mrumtl/COPYING" + rm -f "$(DESTDIR)$(PREFIX)/share/doc/mrumtl/README.md" + rm -f "$(DESTDIR)$(PREFIX)/include/mrumtl.h" + rm -f "$(DESTDIR)$(PREFIX)/share/man/man5/mrumtl.5" + +################################################################################ +# Miscellaneous targets +################################################################################ +all: build_library build_tests + +clean: clean_test + rm -f $(OBJ) $(TEST_OBJ) $(LIBNAME) + rm -f .config .test libmrumtl.o mrumtl.pc mrumtl-local.pc + +distclean: clean + rm -f $(DEP) $(TEST_DEP) + +lint: + shellcheck -o all make.sh + mandoc -Tlint -Wall mrumtl.5 + +################################################################################ +# Tests +################################################################################ +TEST_SRC =\ + src/test_mrumtl.c\ + src/test_mrumtl_bands.c\ + src/test_mrumtl_wlens.c\ + src/test_mrumtl_load.c +TEST_OBJ = $(TEST_SRC:.c=.o) +TEST_DEP = $(TEST_SRC:.c=.d) + +PKG_CONFIG_LOCAL = PKG_CONFIG_PATH="./:$${PKG_CONFIG_PATH}" $(PKG_CONFIG) +MRUMTL_CFLAGS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags mrumtl-local.pc) +MRUMTL_LIBS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs mrumtl-local.pc) + +build_tests: build_library $(TEST_DEP) .test + @$(MAKE) -fMakefile -f.test $$(for i in $(TEST_DEP); do echo -f"$${i}"; done) test_bin + +test: build_tests + @$(SHELL) make.sh run_test $(TEST_SRC) + +.test: Makefile + @$(SHELL) make.sh config_test $(TEST_SRC) > $@ + +clean_test: + $(SHELL) make.sh clean_test $(TEST_SRC) + rm -f test_file_band.mrumtl + +$(TEST_DEP): config.mk mrumtl-local.pc + @$(CC) $(CFLAGS_EXE) $(MRUMTL_CFLAGS) $(RSYS_CFLAGS) \ + -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@ + +$(TEST_OBJ): config.mk mrumtl-local.pc + $(CC) $(CFLAGS_EXE) $(MRUMTL_CFLAGS) $(RSYS_CFLAGS) -c $(@:.o=.c) -o $@ + +test_mrumtl \ +test_mrumtl_bands \ +test_mrumtl_wlens \ +test_mrumtl_load \ +: config.mk mrumtl-local.pc $(LIBNAME) + $(CC) $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS_EXE) $(MRUMTL_LIBS) $(RSYS_LIBS) diff --git a/README.md b/README.md @@ -1,25 +1,21 @@ # ModRadUrb: MaTeriaL -This project defines the fileformat used to describe the spectral of a material -and provide a library to load these data. +This C library loads spectrally variable materials saved in mrumtl format. See +`mrumtl.5` for the format specification. -## How to build +## Requirements -The `mrumtl` library is compatible GNU/Linux 64-bits. It relies on the -[CMake](http://www.cmake.org) and the -[RCMake](https://gitlab.com/vaplv/rcmake/) packages to build. They also depend -on the [RSys](https://gitlab.com/vaplv/rsys/) library. It optionally depends -on [scdoc](https://sr.ht/~sircmpwn/scdoc/) which, if available, is used to -generate the man page of the file format. +- C compiler +- POSIX make +- pkg-config +- [RSys](https://gitlab.com/vaplv/rsys) +- [mandoc](https://mandoc.bsd.lv) -To build the library, first ensure that CMake is installed on your system. Then -install the RCMake package as well as the aforementioned prerequisites. Finally -generate the project from the `cmake/CMakeLists.txt` file by appending to the -`CMAKE_PREFIX_PATH` variable the install directories of its dependencies. The -resulting project can be edited, built, tested and installed as any CMake -project. Refer to the [CMake documentation](https://cmake.org/documentation) -for further informations on CMake. +## Installation +Edit config.mk as needed, then run: + + make clean install ## Release notes @@ -44,7 +40,8 @@ for further informations on CMake. ## Licenses -Copyright (C) 2020-2023 [|Méso|Star>](http://www.meso-star.com) -<contact@meso-star.com>. MruMtl is free software released under the GPL v3+ -license: GNU GPL version 3 or later. You are welcome to redistribute them under -certain conditions; refer to the COPYING file for details. +Copyright (C) 2020-2023 |Méso|Star> (contact@meso-star.com) + +MruMtl is free software released under the GPL v3+ license: GNU GPL version 3 +or later. You are welcome to redistribute them under certain conditions; refer +to the COPYING file for details. diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -1,123 +0,0 @@ -# Copyright (C) 2020-2023 |Méso|Star> (contact@meso-star.com) -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -cmake_minimum_required(VERSION 3.1) -project(mrumtl C) -enable_testing() - -set(MRUMTL_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../src) -option(NO_TEST "Do not build tests" OFF) - -################################################################################ -# Check dependencies -################################################################################ -find_package(RCMake 0.4 REQUIRED) -find_package(RSys 0.9 REQUIRED) - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${RCMAKE_SOURCE_DIR}) -include(rcmake) -include(rcmake_runtime) - -include_directories(${RSys_INCLUDE_DIR}) - -################################################################################ -# Configure and define targets -################################################################################ -set(VERSION_MAJOR 0) -set(VERSION_MINOR 1) -set(VERSION_PATCH 0) -set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) - -set(MRUMTL_FILES_SRC - mrumtl.c - mrumtl_log.c - mrumtl_fetch.c) -set(MRUMTL_FILES_INC - mrumtl_brdf.h - mrumtl_c.h - mrumtl_log.h) -set(MRUMTL_FILES_INC_API mrumtl.h) -set(MRUMTL_FILES_DOC COPYING README.md) - -# Prepend each file in the `MRUMTL_FILES_<SRC|INC>' list by `MRUMTL_SOURCE_DIR' -rcmake_prepend_path(MRUMTL_FILES_SRC ${MRUMTL_SOURCE_DIR}) -rcmake_prepend_path(MRUMTL_FILES_INC ${MRUMTL_SOURCE_DIR}) -rcmake_prepend_path(MRUMTL_FILES_INC_API ${MRUMTL_SOURCE_DIR}) -rcmake_prepend_path(MRUMTL_FILES_DOC ${PROJECT_SOURCE_DIR}/../) - -add_library(mrumtl SHARED ${MRUMTL_FILES_SRC} ${MRUMTL_FILES_INC} ${MRUMTL_FILES_INC_API}) -target_link_libraries(mrumtl RSys) - -set_target_properties(mrumtl PROPERTIES - DEFINE_SYMBOL MRUMTL_SHARED_BUILD - VERSION ${VERSION} - SOVERSION ${VERSION_MAJOR}) - -rcmake_setup_devel(mrumtl MruMtl ${VERSION} modradurb/mrumtl_version.h) - -################################################################################ -# Add tests -################################################################################ -if(NOT NO_TEST) - function(build_test _name) - add_executable(${_name} - ${MRUMTL_SOURCE_DIR}/${_name}.c) - target_link_libraries(${_name} mrumtl RSys) - endfunction() - - function(new_test _name) - build_test(${_name}) - add_test(${_name} ${_name}) - endfunction() - - new_test(test_mrumtl) - new_test(test_mrumtl_wlens) - new_test(test_mrumtl_bands) - - build_test(test_mrumtl_load) -endif() - -################################################################################ -# Man pages -############################################################################### -find_program(SCDOC NAMES scdoc) -if(NOT SCDOC) - message(WARNING - "The `scdoc' program is missing. " - "The mrumtl man page cannot be generated.") -else() - set(_src ${PROJECT_SOURCE_DIR}/../doc/mrumtl.5.scd) - add_custom_command( - OUTPUT mrumtl.5 - COMMAND ${SCDOC} < ${_src} > mrumtl.5 - DEPENDS ${_src} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Buid ROFF man page mrumtl.5" - VERBATIM) - add_custom_target(man-roff ALL DEPENDS mrumtl.5) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/mrumtl.5 DESTINATION share/man/man5) -endif() - - -################################################################################ -# Define output & install directories -################################################################################ -install(TARGETS mrumtl - ARCHIVE DESTINATION bin - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) -install(FILES ${MRUMTL_FILES_INC_API} DESTINATION include/modradurb) -install(FILES ${MRUMTL_FILES_DOC} DESTINATION share/doc/mrumtl) - diff --git a/config.mk b/config.mk @@ -0,0 +1,77 @@ +VERSION = 0.1.0 +PREFIX = /usr/local + +LIB_TYPE = SHARED +#LIB_TYPE = STATIC + +BUILD_TYPE = RELEASE +#BUILD_TYPE = DEBUG + +################################################################################ +# Tools +################################################################################ +AR = ar +CC = cc +LD = ld +OBJCOPY = objcopy +PKG_CONFIG = pkg-config +RANLIB = ranlib + +################################################################################ +# Dependencies +################################################################################ +PCFLAGS_SHARED = +PCFLAGS_STATIC = --static +PCFLAGS = $(PCFLAGS_$(LIB_TYPE)) + +RSYS_VERSION = 0.14 +RSYS_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags rsys) +RSYS_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs rsys) + +################################################################################ +# Compilation options +################################################################################ +WFLAGS =\ + -Wall\ + -Wcast-align\ + -Wconversion\ + -Wextra\ + -Wmissing-declarations\ + -Wmissing-prototypes\ + -Wshadow + +CFLAGS_HARDENED =\ + -D_FORTIFY_SOURCES=2\ + -fcf-protection=full\ + -fstack-clash-protection\ + -fstack-protector-strong + +CFLAGS_COMMON =\ + -std=c89\ + -pedantic\ + -fvisibility=hidden\ + -fstrict-aliasing\ + $(CFLAGS_HARDENED)\ + $(WFLAGS) + +CFLAGS_DEBUG = -g $(CFLAGS_COMMON) +CFLAGS_RELEASE = -O2 -DNDEBUG $(CFLAGS_COMMON) +CFLAGS = $(CFLAGS_$(BUILD_TYPE)) + +CFLAGS_SO = $(CFLAGS) -fPIC +CFLAGS_EXE = $(CFLAGS) -fPIE + +################################################################################ +# Linker options +################################################################################ +LDFLAGS_HARDENED = -Wl,-z,relro,-z,now +LDFLAGS_DEBUG = $(LDFLAGS_HARDENED) +LDFLAGS_RELEASE = -s $(LDFLAGS_HARDENED) +LDFLAGS = $(LDFLAGS_$(BUILD_TYPE)) + +LDFLAGS_SO = $(LDFLAGS) -shared -Wl,--no-undefined +LDFLAGS_EXE = $(LDFLAGS) -pie + +OCPFLAGS_DEBUG = --localize-hidden +OCPFLAGS_RELEASE = --localize-hidden --strip-unneeded +OCPFLAGS = $(OCPFLAGS_$(BUILD_TYPE)) diff --git a/doc/mrumtl b/doc/mrumtl @@ -1,28 +0,0 @@ -<mrumtl> ::= <BRDF-list-wlen> - | <BRDF-list-band> - -<BRDF-list-wlen> ::= wavelengths <wavelengths-count> - <BRDF-wlen> - [ <BRDF-wlen> ... ] - -<BRDF-list-band> ::= bands <bands-count> - <BRDF-band> - [ <BRDF-band> ... ] - -<wavelengths-count> ::= INTEGER -<bands-count> ::= INTEGER - -<BRDF-wlen> ::= <wavelength> <BRDF> - -<BRDF-band> ::= <band-bound-min> <band-bound-max> <BRDF> -<bound-bound-min> ::= <wavelength> -<bound-bound-max> ::= <wavelength> - -<wavelength> ::= DOUBLE # in nanometer - -<BRDF> ::= <BRDF-lambertian> - | <BRDF-specular> - -<BRDF-lambertian> ::= lambertian <reflectivity> -<BRDF-specular> ::= specular <reflectivity> -<reflectivity> ::= DOUBLE diff --git a/doc/mrumtl.5.scd b/doc/mrumtl.5.scd @@ -1,108 +0,0 @@ -mrumtl(5) - -; Copyright (C) 2020-2023 |Méso|Star> (contact@meso-star.com) -; -; This program is free software: you can redistribute it and/or modify -; it under the terms of the GNU General Public License as published by -; the Free Software Foundation, either version 3 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program. If not, see <http://www.gnu.org/licenses/>. - -# NAME - -mrumtl - ModRadUrb MaTeriaL file format - -# DESCRIPTION - -*mrumtl* is a text file format that describes a Bidirectional Reflectance -Distribution Function (BRDF) whose type and parameters can vary spectrally. Its -data are described for a set of wavelengths or spectral bands that must be -listed in ascending order. - -Characters behind the hash mark (#) are considered comments and are therefore -ignored, as well as empty lines, i.e. lines without any characters or composed -only of spaces and tabs. - -# GRAMMAR - -``` -<mrumtl> ::= <per-wlen-BRDF> - | <per-band-BRDF> - ---- - -<per-wlen-BRDF> ::= wavelengths <wavelengths-count> - <wlen-BRDF> - [ <wlen-BRDF> ... ] - -<wlen-BRDF> ::= <wavelength> <BRDF> -<wavelengths-count> ::= INTEGER -<wavelength> ::= REAL # in nanometer - ---- - -<per-band-BRDF> ::= bands <bands-count> - <band-BRDF> - [ <band-BRDF> ... ] - -<band-BRDF> ::= <wavelength-min> <wavelength-max> <BRDF> - -<bands-count> ::= INTEGER -<wavelength-min> ::= REAL # Inclusive bound in nanometers -<wavelength-max> ::= REAL # Inclusive bound in nanometers - ---- - -<BRDF> ::= <BRDF-lambertian> - | <BRDF-specular> - -<BRDF-lambertian> ::= lambertian <reflectivity> -<BRDF-specular> ::= specular <reflectivity> -<reflectivity> ::= REAL # In [0, 1] -``` - -# EXAMPLES - -Describe a material with only two bands: one for the visible part of the -spectrum and one for the long waves. In both cases use a diffuse reflectivity: - -``` -bands 2 -380 780 lambertian 0.9 # Visible part -1000 100000 lambertian 0.1 # Infrared -``` - -Setup a material for a list of 17 wavelengths. This material is diffuse in -short waves and specular in long waves: - -``` -wavelengths 17 - -# Short waves -430 lambertian 5.2e-2 -450 lambertian 6.2e-2 -500 lambertian 6.5e-002 -600 lambertian 0.165 -750 lambertian 0.175 - -# Long waves -1100 specular 0.1 -1300 specular 0.17 -1400 specular 0.1 -2000 specular 0.1 -2100 specular 0.4 -2300 specular 0.18 -2500 specular 0.9 -2600 specular 0.95 -2900 specular 0.4 -3000 specular 0.3 -4000 specular 0.0 -100000 specular 0.0 -``` diff --git a/make.sh b/make.sh @@ -0,0 +1,71 @@ +#!/bin/sh + +# Copyright (C) 2020, 2023 |Méso|Star> (contact@meso-star.com) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +set -e + +config_test() +{ + for i in "$@"; do + test=$(basename "${i}" ".c") + test_list="${test_list} ${test}" + printf "%s: %s\n" "${test}" "src/${test}.o" + done + printf "test_bin: %s\n" "${test_list}" +} + +run_test() +{ + for i in "$@"; do + test=$(basename "${i}" ".c") + + printf "%s " "${test}" + if "./${test}" > /dev/null 2>&1; then + printf "\033[1;32mOK\033[m\n" + else + printf "\033[1;31mError\033[m\n" + fi + done 2> /dev/null +} + + +clean_test() +{ + for i in "$@"; do + rm -f "$(basename "${i}" ".c")" + done +} + +install() +{ + prefix=$1 + shift 1 + + mkdir -p "${prefix}" + + for i in "$@"; do + dst="${prefix}/${i##*/}" + + if cmp -s "${i}" "${dst}"; then + printf "Up to date %s\n" "${dst}" + else + printf "Installing %s\n" "${dst}" + cp "${i}" "${prefix}" + fi + done +} + +"$@" diff --git a/mrumtl.5 b/mrumtl.5 @@ -0,0 +1,104 @@ +.\" Copyright (C) 2020, 2023 |Méso|Star> (contact@meso-star.com) +.\" +.\" This program is free software: you can redistribute it and/or modify +.\" it under the terms of the GNU General Public License as published by +.\" the Free Software Foundation, either version 3 of the License, or +.\" (at your option) any later version. +.\" +.\" This program is distributed in the hope that it will be useful, +.\" but WITHOUT ANY WARRANTY; without even the implied warranty of +.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +.\" GNU General Public License for more details. +.\" +.\" You should have received a copy of the GNU General Public License +.\" along with this program. If not, see <http://www.gnu.org/licenses/>. +.Dd October 4, 2023 +.Dt MRUMTL 5 +.Os +.Sh NAME +.Nm mrumtl +.Nd ModRadUrb MaTeriaL file format +.Sh DESCRIPTION +.Nm +is a text file format that describes a Bidirectional Reflectance +Distribution Function +.Pq BRDF +whose type and parameters can vary spectrally. +Its data are described for a set of wavelengths or spectral bands that must be +listed in ascending order. +.Pp +Characters behind the hash mark +.Pq Li # +are considered comments and are therefore ignored, as well as empty lines, +i.e. lines without any characters or composed only of spaces and tabs. +.Pp +The file format is as follows: +.Bl -column (per-band-BRDF) (::=) () +.It Ao Va mrumtl Ac Ta ::= Ta Ao Va per-wlen-BRDF Ac | Ao Va per-band-BRDF Ac +.It \ Ta Ta +.It Ao Va per-wlen-BRDF Ac Ta ::= Ta Li wavelength Ao Va #wavelengths Ac +.It Ta Ta Ao Va wlen-BRDF Ac +.It Ta Ta Va ... +.It Ao Va wlen-BRDF Ac Ta ::= Ta Ao Va wavelength Ac Ao Va BRDF Ac +.It Ao Va #wavelength Ac Ta ::= Ta Va integer +.It Ao Va wavelength Ac Ta ::= Ta Va real +# In nanometer +.It \ Ta Ta +.It Ao Va per-band-BRDF Ac Ta ::= Ta Li bands Ao Va #bands Ac +.It Ta Ta Ao Va band-BRDF Ac +.It Ta Ta Va ... +.It Ao Va #bands Ac Ta ::= Ta Va integer +.It Ao Va band-BRDF Ac Ta ::= Ta +.Aq Va wavelength-min +.Aq Va wavelength-max +.Aq Va BRDF +.It Ao Va wavelength-min Ac Ta ::= Ta Va real +# Inclusive bound in nm +.It Ao Va wavelength-max Ac Ta ::= Ta Va real +# Inclusive bound in nm +.It \ Ta Ta +.It Ao Va BRDF Ac Ta ::= Ta +.Aq Va BRDF-lambertian +| +.Aq Va BRDF-specular +.It Ao Va BRDF-lambertian Ac Ta ::= Ta Li lambertian Ao Va reflectivity Ac +.It Ao Va BRDF-specular Ac Ta ::= Ta Li specular Ao Va reflectivity Ac +.It Ao Va reflectivity Ac Ta ::= Ta Va real +# In [0, 1] +.El +.Sh EXAMPLES +Describe a material with only two bands: one for the visible part of the +spectrum and one for the long waves. +In both cases use a diffuse reflectivity: +.Bd -literal -offset indent +bands 2 +380 780 lambertian 0.9 # Visible part +1000 100000 lambertian 0.1 # Infrared +.Ed +.Pp +Setup a material for a list of 17 wavelengths. +This material is diffuse in short waves and specular in long waves: +.Bd -literal -offset indent +wavelengths 17 + +# Short waves +430 lambertian 5.2e-2 +450 lambertian 6.2e-2 +500 lambertian 6.5e-002 +600 lambertian 0.165 +750 lambertian 0.175 + +# Long waves +1100 specular 0.1 +1300 specular 0.17 +1400 specular 0.1 +2000 specular 0.1 +2100 specular 0.4 +2300 specular 0.18 +2500 specular 0.9 +2600 specular 0.95 +2900 specular 0.4 +3000 specular 0.3 +4000 specular 0.0 +100000 specular 0.0 +.Ed diff --git a/mrumtl.pc.in b/mrumtl.pc.in @@ -0,0 +1,10 @@ +prefix=@PREFIX@ +includedir=${prefix}/include +libdir=${prefix}/lib + +Requires: rsys >= @RSYS_VERSION@ +Name: mrumtl +Description: ModRadUrb MaTeriaL library +Version: @VERSION@ +Libs: -L${libdir} -lmrumtl +CFlags: -I${includedir}