### Build and Install cmftStudio from Source Source: https://context7.com/dariomanesku/cmftstudio/llms.txt These shell commands guide the user through cloning the repository, generating project files, building for specific platforms like Linux and macOS, and installing the binary. ```bash git clone --recurse-submodules http://github.com/dariomanesku/cmftStudio.git cd cmftStudio make make linux-release64 make osx-release64 cd runtime ../_build/linux64_gcc/bin/cmftStudioRelease sudo make linux-install sudo make linux-uninstall ``` -------------------------------- ### cmftstudio.conf Configuration File Source: https://context7.com/dariomanesku/cmftstudio/llms.txt Example configuration file for cmftStudio, detailing settings for renderer selection, window size, memory allocation, and default file paths. ```ini # cmftstudio.conf - Application configuration file # Renderer selection (Windows only) # Options: dx9, directx9, dx11, directx11, ogl, opengl Renderer = ogl # Window dimensions at startup WindowSize = 1920x1027 # Memory allocation (recommended 2.0GB+ on 64-bit systems) # Range: 1.0GB - 7.0GB Memory = 2.0GB # Auto-load project on startup StartupProject = "MyProject.csp" # Default file browser paths DefaultLoadPath = "/home/user/envmaps" DefaultSavePath = "/home/user/output" ``` -------------------------------- ### Environment Map Transformations in C++ Source: https://context7.com/dariomanesku/cmftstudio/llms.txt Provides C++ examples for transforming environment maps, including rotating/flipping faces, resizing, converting texture formats, applying tonemapping, and restoring the original skybox. ```cpp #include "context.h" cs::EnvHandle env; // Existing environment handle // Transform cubemap face with rotation/flip operations // Arguments: handle, which map, face | operation envTransform(env, cs::Environment::Skybox, cmft::IMAGE_FACE_POSITIVEX | cmft::IMAGE_OP_ROT_90); // Resize environment map to new face size cs::envResize(env, cs::Environment::Skybox, 512); // 512x512 per face // Convert environment to different texture format cs::envConvert(env, cs::Environment::Pmrem, cmft::TextureFormat::RGBA16F); // Apply tonemapping to skybox cs::envTonemap(env, 2.2f, // gamma 0.0f, // minimum luminance 1.0f // luminance range ); // Restore original skybox (undo tonemapping) cs::envRestoreSkybox(env); ``` -------------------------------- ### Create and Manage PBR Materials Source: https://context7.com/dariomanesku/cmftstudio/llms.txt Demonstrates creating default, preset, and custom PBR materials. It covers initializing materials from scratch, cloning existing ones, and assigning various texture maps. ```cpp #include "context.h" cs::MaterialHandle mat = cs::materialCreate(); cs::MaterialHandle plain = cs::materialCreatePlain(); cs::MaterialHandle shiny = cs::materialCreateShiny(); cs::MaterialHandle stripes = cs::materialCreateStripes(); cs::MaterialHandle bricks = cs::materialCreateBricks(); float matData[cs::Material::Size] = { }; cs::MaterialHandle customMat = cs::materialCreate(matData, albedoTex, normalTex, surfaceTex, reflectivityTex, aoTex, emissiveTex); cs::MaterialHandle copy = cs::materialCreateFrom(existingMat); ``` -------------------------------- ### Creating and Loading Environments in C++ Source: https://context7.com/dariomanesku/cmftstudio/llms.txt Demonstrates how to create and load environment maps (cubemaps) using the cs::envCreate and cs::envLoad functions. Supports creating from default colors, existing files, or the cmftStudio logo, and includes GPU buffer creation. ```cpp #include "context.h" // Create environment with default gray color cs::EnvHandle env = cs::envCreate(0x303030ff); // Create environment from existing cubemap files cs::EnvHandle env = cs::envCreate( "skybox.dds", // Skybox path "pmrem.dds", // Radiance map path "iem.dds" // Irradiance map path ); // Create the default cmftStudio logo environment cs::EnvHandle logoEnv = cs::envCreateCmftStudioLogo(); // Load environment map from file into specific slot cs::EnvHandle env = cs::envCreate(); bool success = cs::envLoad(env, cs::Environment::Skybox, "environment.hdr"); if (success) { // Create GPU buffers for rendering cs::createGpuBuffers(env); } ``` -------------------------------- ### Initialize and Configure Render Pipeline Source: https://context7.com/dariomanesku/cmftstudio/llms.txt Initializes the rendering pipeline with resolution and flags, handles window resizing, and sets up frame rendering options like bloom and FXAA. It also manages camera matrix updates for the active view. ```cpp #include "renderpipeline.h" renderPipelineInit(1920, 1080, BGFX_RESET_VSYNC); renderPipelineUpdateSize(newWidth, newHeight, resetFlags); renderPipelineSetupFrame(true, true, true); float viewMtx[16], projMtx[16]; renderPipelineSetActiveCamera(viewMtx, projMtx); ``` -------------------------------- ### Configure Rendering and Post-Processing Settings in C++ Source: https://context7.com/dariomanesku/cmftstudio/llms.txt This snippet demonstrates how to initialize and modify the Settings object to control lighting models, tone mapping, post-processing effects, and IBL parameters. It provides a template for adjusting visual output in the cmftStudio environment. ```cpp #include "settings.h" Settings settings; // Lighting model selection settings.m_selectedLightingModel = cmft::LightingModel::BlinnBrdf; // Tone mapping selection settings.m_selectedToneMapping = ToneMapping::Uncharted2; // Post-processing parameters settings.m_brightness = 0.0f; settings.m_contrast = 1.0f; settings.m_saturation = 1.0f; settings.m_exposure = 0.0f; settings.m_gamma = 1.0f; settings.m_vignette = 3.0f; // HDR settings settings.m_doBloom = true; settings.m_doLightAdapt = true; settings.m_middleGray = 0.18f; settings.m_white = 1.1f; settings.m_treshold = 0.9f; settings.m_gaussStdDev = 0.8f; settings.m_blurCoeff = 0.8f; // IBL settings settings.m_diffuseIbl = true; settings.m_specularIbl = true; settings.m_ambientLightStrenght = 1.0f; // Camera settings.m_fovDest = 90.0f; ``` -------------------------------- ### Iterate through a directory using sorted access Source: https://github.com/dariomanesku/cmftstudio/blob/master/dependency/tinydir/README.md This snippet demonstrates how to open a directory with sorted file access and iterate through the files using a for loop based on the total file count. It provides an alternative to sequential iteration for ordered processing. ```C tinydir_dir dir; int i; tinydir_open_sorted(&dir, "/path/to/dir"); for (i = 0; i < dir.n_files; i++) { tinydir_file file; tinydir_readfile_n(&dir, &file, i); printf("%s", file.name); if (file.is_dir) { printf("/"); } printf("\n"); } tinydir_close(&dir); ``` -------------------------------- ### Configure Material Properties and Textures Source: https://context7.com/dariomanesku/cmftstudio/llms.txt Shows how to modify material properties like albedo, specular, and roughness, and how to bind textures to specific material slots. ```cpp #include "context.h" cs::MaterialHandle mat = cs::materialCreate(); cs::Material& material = cs::getObj(mat); material.m_albedo.r = 0.8f; material.m_albedo.g = 0.2f; material.m_albedo.b = 0.1f; material.m_albedo.sample = 0.0f; material.m_reflectivity = 0.5f; material.m_metalOrSpec = 1.0f; material.m_fresnel = 0.04f; material.m_invGloss = 0.3f; cs::TextureHandle albedoTex = cs::textureLoad("albedo.dds"); material.set(cs::Material::Albedo, albedoTex); if (material.has(cs::Material::Normal)) { cs::TextureHandle tex = material.get(cs::Material::Normal); } ``` -------------------------------- ### Iterate through a directory sequentially using TinyDir Source: https://github.com/dariomanesku/cmftstudio/blob/master/dependency/tinydir/README.md This snippet demonstrates how to open a directory, iterate through its contents using a while loop, and close the directory handle. It checks if each entry is a directory and prints the name accordingly. ```C tinydir_dir dir; tinydir_open(&dir, "/path/to/dir"); while (dir.has_next) { tinydir_file file; tinydir_readfile(&dir, &file); printf("%s", file.name); if (file.is_dir) { printf("/"); } printf("\n"); tinydir_next(&dir); } tinydir_close(&dir); ``` -------------------------------- ### Save and Load Projects Source: https://context7.com/dariomanesku/cmftstudio/llms.txt Provides mechanisms to persist project state to disk using background threads or direct function calls. Loading involves checking thread status and initializing GPU buffers for loaded resources. ```cpp #include "project.h" // Saving ProjectSaveThreadParams saveParams; saveParams.init(); projectSave("/path/to/project.csp", materialList, envList, meshInstList, settings, 6); // Loading ProjectLoadThreadParams loadParams; loadParams.init(); projectLoadFunc(&loadParams); if (loadParams.m_threadStatus & ThreadStatus::ExitSuccess) { cs::createGpuBuffers(loadParams.m_textureList[0]); } ``` -------------------------------- ### PMREM Filtering Configuration and Execution in C++ Source: https://context7.com/dariomanesku/cmftstudio/llms.txt Details the configuration of PMREM (Prefiltered Mipmapped Radiance Environment Map) filter parameters and launching the filtering process as a background job. Includes options for CPU/GPU acceleration and various filtering settings. ```cpp #include "backgroundjobs.h" // Configure PMREM filter parameters CmftFilterThreadParams params; params.m_envHandle = env; // Source environment params.m_filterType = cs::Environment::Pmrem; // Output to radiance slot params.m_srcSize = 256; // Source face size params.m_dstSize = 256; // Destination face size params.m_inputGamma = 2.2f; // Input gamma correction params.m_outputGamma = 1.0f / 2.2f; // Output gamma (1/2.2 for linear) params.m_mipCount = 7; // Number of mip levels params.m_glossScale = 10; // Gloss scale factor params.m_glossBias = 3; // Gloss bias params.m_numCpuThreads = 4; // CPU thread count params.m_lightingModel = cmft::LightingModel::BlinnBrdf; // BRDF model params.m_edgeFixup = cmft::EdgeFixup::Warp; // Cubemap edge fixup params.m_excludeBase = false; // Include base level params.m_useOpenCL = true; // Enable GPU acceleration // Launch filter in background thread params.m_threadStatus = ThreadStatus::Started; int32_t result = cmftFilterFunc(¶ms); // Check completion status if (params.m_threadStatus & ThreadStatus::Completed) { if (params.m_threadStatus & ThreadStatus::ExitSuccess) { // Filter completed successfully cs::createGpuBuffers(env); } } ``` -------------------------------- ### Configure CMake Build and Targets for tinydir Source: https://github.com/dariomanesku/cmftstudio/blob/master/dependency/tinydir/samples/CMakeLists.txt This CMake script sets the minimum version, includes parent directories, and applies compiler-specific warning flags. It also defines four sample executable targets for testing the library functionality. ```cmake cmake_minimum_required(VERSION 2.6 FATAL_ERROR) cmake_policy(VERSION 2.6) project(tinydir C) INCLUDE_DIRECTORIES(..) if(MSVC) add_definitions(-W4 -WX) else() add_definitions(-fsigned-char -Wall -W -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Winline -Werror) endif() add_executable(file_open_sample file_open_sample.c) add_executable(iterate_sample iterate_sample.c) add_executable(random_access_sample random_access_sample.c) add_executable(interactive_sample interactive_sample.c) ``` -------------------------------- ### Configure Uniforms and Lighting Source: https://context7.com/dariomanesku/cmftstudio/llms.txt Accesses and modifies global rendering uniforms, including directional light properties and IBL settings. Changes must be submitted via cs::submitUniforms before draw calls. ```cpp #include "context.h" cs::Uniforms& uniforms = cs::getUniforms(); uniforms.m_directionalLights[0].m_color[0] = 1.0f; uniforms.m_directionalLights[0].m_strenght = 2.0f; uniforms.m_diffuseIbl = 1.0f; cs::submitUniforms(); ``` -------------------------------- ### Load and Save 3D Meshes Source: https://context7.com/dariomanesku/cmftstudio/llms.txt Handles loading 3D geometry from files or memory buffers, retrieving built-in primitives, and saving meshes to binary formats. ```cpp #include "context.h" cs::MeshHandle mesh = cs::meshLoad("model.obj"); cs::MeshHandle sphere = cs::meshSphere(); uint32_t groupCount = cs::meshNumGroups(mesh); cs::meshSave(mesh, "output.bin"); ``` -------------------------------- ### Manage Mesh Instances and Transforms Source: https://context7.com/dariomanesku/cmftstudio/llms.txt Configures mesh instances within a scene, including setting transformation properties and assigning materials to specific mesh groups. ```cpp #include "context.h" cs::MeshInstance instance; instance.set(mesh); instance.m_scale = 1.0f; instance.set(material, 0); float* mtx = instance.computeMtx(); ``` -------------------------------- ### Load and Retrieve Textures Source: https://context7.com/dariomanesku/cmftstudio/llms.txt Loads texture data from files or memory and provides access to built-in textures and underlying bgfx handles for rendering. ```cpp #include "context.h" cs::TextureHandle tex = cs::textureLoad("texture.dds"); cs::TextureHandle stripes = cs::textureStripes(); bgfx::TextureHandle bgfxTex = cs::textureGetBgfxHandle(tex); ``` -------------------------------- ### Environment Management API Source: https://context7.com/dariomanesku/cmftstudio/llms.txt Endpoints for creating, loading, and transforming environment maps within the cmftStudio context. ```APIDOC ## POST /env/create ### Description Creates a new environment handle, either from a solid color, existing files, or the default cmftStudio logo. ### Method POST ### Endpoint /env/create ### Parameters #### Request Body - **color** (uint32) - Optional - Hex color for default environment - **skyboxPath** (string) - Optional - Path to skybox texture - **pmremPath** (string) - Optional - Path to radiance map - **iemPath** (string) - Optional - Path to irradiance map ### Response #### Success Response (200) - **handle** (cs::EnvHandle) - Unique identifier for the created environment ## POST /env/transform ### Description Applies transformations such as rotation, flipping, resizing, or tonemapping to specific environment map slots. ### Method POST ### Endpoint /env/transform ### Parameters #### Request Body - **handle** (cs::EnvHandle) - Required - The environment handle to modify - **slot** (enum) - Required - Target slot (Skybox, Pmrem, Iem) - **operation** (string) - Required - Transformation type (e.g., ROT_90, RESIZE, TONEMAP) ``` -------------------------------- ### Configure and Execute IEM Filtering Source: https://context7.com/dariomanesku/cmftstudio/llms.txt Configures the Irradiance Map (IEM) filter parameters using CmftFilterThreadParams and executes the filtering process. This is essential for generating diffuse irradiance maps from environment maps. ```cpp #include "backgroundjobs.h" CmftFilterThreadParams iemParams; iemParams.m_envHandle = env; iemParams.m_filterType = cs::Environment::Iem; iemParams.m_srcSize = 256; iemParams.m_dstSize = 128; iemParams.m_inputGamma = 2.2f; iemParams.m_outputGamma = 1.0f / 2.2f; iemParams.m_numCpuThreads = 4; iemParams.m_useOpenCL = true; iemParams.m_threadStatus = ThreadStatus::Started; cmftFilterFunc(&iemParams); ``` -------------------------------- ### Submit Geometry and Manage Frame Rendering Source: https://context7.com/dariomanesku/cmftstudio/llms.txt Submits mesh instances and skyboxes to the render pipeline using specific view IDs and shader programs. It supports environment transitions for skyboxes and finalizes the frame rendering process. ```cpp #include "context.h" cs::submit(RenderPipeline::ViewIdMesh, meshInstance, cs::Program::MeshPbr, env, CS_DEFAULT_DRAW_STATE); renderPipelineSubmitSkybox(env, cs::Environment::Skybox, 0.0f); renderPipelineSubmitSkybox(nextEnv, currentEnv, 0.5f, cs::Environment::Skybox, cs::Environment::Skybox, 0.0f, 0.0f); renderPipelineSubmitFrame(0.8f); renderPipelineFlush(); ``` -------------------------------- ### CMFT Filtering API Source: https://context7.com/dariomanesku/cmftstudio/llms.txt Endpoints for executing background filtering jobs to generate PMREM (Radiance) and IEM (Irradiance) maps. ```APIDOC ## POST /filter/pmrem ### Description Configures and launches a background job to generate a PMREM (Radiance) map using multi-threaded CPU or OpenCL GPU acceleration. ### Method POST ### Endpoint /filter/pmrem ### Parameters #### Request Body - **envHandle** (cs::EnvHandle) - Required - Source environment - **filterType** (enum) - Required - Target slot - **mipCount** (int) - Required - Number of mip levels to generate - **useOpenCL** (bool) - Required - Enable GPU acceleration - **lightingModel** (enum) - Required - BRDF model (e.g., BlinnBrdf) ### Response #### Success Response (200) - **status** (int) - Job status code (Started, Completed, ExitSuccess) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.