### Handling Touch Events with onClick Helper (Korender Script) Source: https://zakgof.github.io/projects/korender/wiki/gui Illustrates how to implement touch event handling for GUI elements, specifically using the `onClick` helper function. This allows for reacting to click events within a widget's screen area. The example shows a placeholder for click handling logic. ```Korender Script Image( .... onTouch = { onClick(it) { // Handle click here } } ) ``` -------------------------------- ### Use Sky Material as IBL Source (Korender) Source: https://zakgof.github.io/projects/korender/wiki/env This example demonstrates an alternative way to use environment-based lighting for a `Renderable` in Korender, by specifying a sky material (e.g., `fastCloudSky()`) as the source for the `ibl` modifier. ```kotlin Frame { Renderable( base(...), ibl(fastCloudSky()) ) ``` -------------------------------- ### Korender GUI Layout with Containers and Fillers (Korender Script) Source: https://zakgof.github.io/projects/korender/wiki/gui Demonstrates how to structure GUI elements using containers (Row, Column) and fillers to manage layout and spacing. Elements like Text and Image can be positioned and styled. This script defines a basic layout with text and an image. ```Korender Script Frame { Gui { Row { Text(text = "LEFT TOP", id = "lt", fontResource = "/ubuntu.ttf", height = 30, color = ColorRBGA(0xFFFF8888)) Filler Text(text = "RIGHT TOP", id = "rt", fontResource = "/ubuntu.ttf", height = 30, color = ColorRBGA(0xFFFF8888)) } Filler Row { Filler Image(imageResource = "/bottom.png", width = 100, height = 100) Filler } } } ``` -------------------------------- ### Declare Lights in Korender Frame Context Source: https://zakgof.github.io/projects/korender/wiki/light Demonstrates how to dynamically declare ambient, point, and directional lights within the Frame context in Korender. This setup is fundamental for scene lighting. ```korender Frame { AmbientLight(white(0.25f)) PointLight(Vec3(100f, 20f, 100f), ColorRGB.Green) DirectionalLight(Vec3(1f, -1f, 2f), white(1.0f)) } ``` -------------------------------- ### Korender Plugin Integration Source: https://zakgof.github.io/projects/korender/wiki/plugins Demonstrates how to integrate a custom shader plugin into a Korender renderable object. This involves using the `plugin()` function to specify the shader file and `uniform()` to set shader parameters. The example shows a wave texturing shader being applied. ```python Renderable( base(), plugin("texturing", "shaders/texturing.wave.frag"), uniform("wavescale", 10f), mesh = .... ) ``` -------------------------------- ### Configure Korender with Resource Loader Source: https://zakgof.github.io/projects/korender/wiki/assets This snippet shows how to configure Korender to access application assets by providing an `appResourceLoader`. The example uses `Res.readBytes` from Kotlin Multiplatform resources and demonstrates rendering a texture. Assets are expected in the `commonMain/composeResources/files` directory. ```kotlin @Composable fun App() = Korender(appResourceLoader = { Res.readBytes(it) }) { // ... Frame { Renderable( base(colorTexture = texture("texture/asphalt.jpg")), ``` -------------------------------- ### Add Decals in Deferred Shading Pipeline Source: https://zakgof.github.io/projects/korender/wiki/deferred This example demonstrates how to add decals to a scene using the deferred rendering pipeline in Korender. It involves specifying a base material with a color texture and defining the decal's position, orientation, and size. ```korender Frame { val cubeMap = ... DeferredShading { Decal( base( colorTexture = texture("texture/decal.png"), metallicFactor = 0.2f ), position = pos, look = look, up = up, size = 1.6f ) } ``` -------------------------------- ### Procedural Fast Cloud Sky Rendering in Korender Source: https://zakgof.github.io/projects/korender/wiki/sky Generates a procedural sky with clouds using the `fastCloudSky` preset. Allows customization of cloud density, thickness, scale, ripple effects, and colors. ```korender Frame { Sky(fastCloudSky(thickness = 12.0f, rippleAmount = 0.4f)) } ``` -------------------------------- ### Cubemap Sky Rendering in Korender Source: https://zakgof.github.io/projects/korender/wiki/sky Renders a skybox using six textures to form a cube map. Requires six image files for each face of the cube (NX, NY, NZ, PX, PY, PZ). ```korender Frame { Sky(cubeSky(cubeTexture("sky", mapOf( NX to "textures/skybox-nx.jpg", NY to "textures/skybox-ny.jpg", NZ to "textures/skybox-nz.jpg", PX to "textures/skybox-px.jpg", PY to "textures/skybox-py.jpg", PZ to "textures/skybox-pz.jpg" )))) } ``` -------------------------------- ### Set Perspective Projection in Korender Source: https://zakgof.github.io/projects/korender/wiki/projection Configures the perspective projection for the Korender rendering context. This example sets up a frustum projection, taking the viewport's aspect ratio into account. It requires specifying field of view, aspect ratio, near clipping plane, and far clipping plane. ```Korender Frame { projection = projection(4f * width / height, 4f, 4f, 10000f, ortho()) } ``` -------------------------------- ### Single-Texture Sky Rendering in Korender Source: https://zakgof.github.io/projects/korender/wiki/sky Projects a single texture onto the sky dome. This method accounts for projection distortion to display the texture correctly on a spherical sky. ```korender Frame { Sky(textureSky("textures/sky.jpg")) } ``` -------------------------------- ### Procedural Starry Sky Rendering in Korender Source: https://zakgof.github.io/projects/korender/wiki/sky Generates a procedural night sky with stars using the `starrySky` preset. Parameters control star color intensity, density, motion speed, and size. ```korender Frame { Sky(starrySky(colorness = 0.8f, density = 20.0f, speed = 1.0f, size = 15.0f)) } ``` -------------------------------- ### Set Camera Transform in Korender Source: https://zakgof.github.io/projects/korender/wiki/projection Defines the camera's position and orientation within the Korender scene. This example sets the camera's position to `Vec3(-2.0f, 5f, 30f)` and specifies its 'look-at' direction using `-1.z` and `1.y` vectors for orientation. ```Korender Frame { camera = camera(Vec3(-2.0f, 5f, 30f), -1.z, 1.y) } ``` -------------------------------- ### Set Logarithmic Depth Buffer Projection in Korender Source: https://zakgof.github.io/projects/korender/wiki/projection Enables the logarithmic depth buffer for enhanced depth precision in large-scale scenes. This projection method is particularly useful for rendering vast environments like planetary terrain or open-world games where linear depth precision can be insufficient. It uses the `log()` function within the projection setup. ```Korender Frame { projection = projection(4f * width / height, 4f, 4f, 10000f, log()) } ``` -------------------------------- ### Override Korender Retention Policy Source: https://zakgof.github.io/projects/korender/wiki/assets This snippet demonstrates how to override the default asset retention policy in Korender. By setting the `retentionPolicy` variable within the `Korender` composable, you can control how long assets are kept in memory after they are no longer used. The example sets the policy to `keepForever()`. ```kotlin @Composable Korender(appResourceLoader = { Res.readBytes(it) }) { retentionPolicy = keepForever() ``` -------------------------------- ### Apply Image-Based Lighting (IBL) in Deferred Shading Source: https://zakgof.github.io/projects/korender/wiki/deferred Demonstrates how to apply Image-Based Lighting (IBL) globally in screen space using a shading material modifier within the deferred rendering pipeline. It requires a cube map texture for environment mapping. ```korender Frame { val cubeMap = ... DeferredShading { Shading(ibl(cubeMap)) } ``` -------------------------------- ### Initialize Korender and Define Frame Logic (Kotlin) Source: https://zakgof.github.io/projects/korender/wiki/context Shows how to add initialization code within the `Korender` context and per-frame code, along with renderable objects, within the `Frame` context. The `Korender` block runs once on initialization, while the `Frame` block executes on every frame. ```kotlin Korender { // Code here will run once on Korender viewport initialization Frame { // Code here will run on every frame // Place your renderable declaration functions here } } ``` -------------------------------- ### Create Cube Map from Scene Capture (Korender) Source: https://zakgof.github.io/projects/korender/wiki/env This snippet shows how to create a cube map in Korender by capturing a scene using `CaptureEnv`. The captured probe can then be used to generate a cube map via `cubeTextureProbe`. ```kotlin Frame { CaptureEnv("probe1", 1024) { // Render capture scene here } val cubeMap = cubeTextureProbe("probe1") } ``` -------------------------------- ### GLTF Instancing for Multiple Model Renderings in Korender Source: https://zakgof.github.io/projects/korender/wiki/gltf Illustrates how to use instancing to render multiple instances of a GLTF model efficiently. This includes defining the instancing parameters and specifying dynamic positions for each instance. ```korender Frame { Gltf( resource = "model.glb", instancing = gltfInstancing("crowd", 10, true) { repeat(10) { i -> Instance( transform = ... // i-th instance dynamic position ) } } ) } ``` -------------------------------- ### Render Environment to Cube Images with Korender Source: https://zakgof.github.io/projects/korender/wiki/offscreen Captures the environment from a given world-space position and generates six images corresponding to the standard cubemap faces. It returns a Deferred for further processing. This is ideal for creating skyboxes or reflection probes. ```kotlin Korender { val deferredCubeImages = captureEnv(1024, 1f, 1000f) { Renderable(...) } ... Frame { if (deferredCubeImages.isCompleted) { val cubeImages = deferredCubeImages.getCompleted() val negativeXSide = cubeImages[CubeTextureSide.NX] // Use the captured images ``` -------------------------------- ### Load and Render GLTF/GLB Model in Korender Source: https://zakgof.github.io/projects/korender/wiki/gltf Demonstrates how to load and render a GLTF/GLB file within a Korender Frame context. This is the basic usage for displaying a 3D model. ```korender Frame { Gltf(resource = "model.glb") } ``` -------------------------------- ### Korender Base Material Configuration Source: https://zakgof.github.io/projects/korender/wiki/materials Demonstrates the configuration of the base material in Korender, including color, color texture, metallic factor, and roughness factor. It also shows how to apply the triplanar modifier for enhanced texturing. ```korender base( color = ColorRGBA(0x203040FF), colorTexture = texture("textures/texture.png"), metallicFactor = 0.5f, roughnessFactor = 0.3f ), triplanar( scale = 0.5f ) ``` -------------------------------- ### Access Bundled Korender Resources Source: https://zakgof.github.io/projects/korender/wiki/assets This snippet illustrates how to access bundled resources within Korender. By prefixing the asset path with an exclamation mark (!), you can load resources like fonts that are included with Korender itself. ```kotlin texture("!font/anta.ttf") ``` -------------------------------- ### Configure Directional Light Shadows in Korender Source: https://zakgof.github.io/projects/korender/wiki/light Shows how to configure shadows for directional lights in Korender, including setting up multiple shadow map cascades with different algorithms like software PCF and VSM. This allows for advanced shadow rendering. ```korender Frame { DirectionalLight(Vec3(1f, -1f, 0.3f), white(5.0f)) { Cascade(mapSize = 1024, near = 4f, far = 12f, algorithm = softwarePcf(samples = 16, blurRadius = 0.01f)) Cascade(mapSize = 1024, near = 10f, far = 30f, algorithm = vsm(blurRadius = 0.01f)) Cascade(mapSize = 1024, near = 25f, far = 100f, algorithm = vsm(blurRadius = 0.02f)) } } ``` -------------------------------- ### Create Cube Map from 6 Textures (Korender) Source: https://zakgof.github.io/projects/korender/wiki/env This code snippet demonstrates how to create a cube map in Korender by providing six texture images for each face of the cube (NX, NY, NZ, PX, PY, PZ). It utilizes the `cubeTexture` function within a `Frame` block. ```kotlin Frame { val cubeMap = cubeTexture("env", mapOf( NX to "textures/env-nx.jpg", NY to "textures/env-ny.jpg", NZ to "textures/env-nz.jpg", PX to "textures/env-px.jpg", PY to "textures/env-py.jpg", PZ to "textures/env-pz.jpg" )) } ``` -------------------------------- ### Enable Deferred Shading in Korender Source: https://zakgof.github.io/projects/korender/wiki/deferred This snippet shows how to enable the deferred shading pipeline by adding the `DeferredShading()` declaration within the `Frame` context. This is the primary step to activate the experimental deferred rendering feature in Korender. ```korender Frame { DeferredShading() ``` -------------------------------- ### Instancing Billboards in Korender Source: https://zakgof.github.io/projects/korender/wiki/instancing Enables instancing for billboards, allowing multiple billboards to be rendered efficiently. Configured with an 'id', 'count', and 'dynamic' flag. Each instance requires 'pos', 'scale', and optionally 'rotation'. The 'transparent' flag should be enabled for billboards with transparency. ```korender Billboard( base(colorTexture = texture("texture/splat.png")), transparent = true, instancing = billboardInstancing( id = "particles", count = 3, dynamic = false ) { Instance(pos = 1.x, scale = Vec2(2f, 2f)) Instance(pos = 2.x, scale = Vec2(3f, 2f)) Instance(pos = 3.x, scale = Vec2(2f, 3f)) } ) ``` -------------------------------- ### Instancing Renderables in Korender Source: https://zakgof.github.io/projects/korender/wiki/instancing Renders multiple Renderables in a batch by adding an 'instancing' parameter to a Renderable declaration within a Frame. Requires a unique 'id', 'count' for instances, and a 'dynamic' flag. Instances are defined with transformations like translation. ```korender Frame { Renderable( base(color = Red), mesh = cube(0.3f), instancing = instancing( id = "cubes", count = 3, dynamic = true ) { Instance.translate(1.x) Instance.translate(2.x) Instance.translate(3.x) } ) } ``` -------------------------------- ### Render Frame to Image with Korender Source: https://zakgof.github.io/projects/korender/wiki/offscreen Renders a scene from a virtual camera and projection into an image. It returns a Deferred which can be accessed once completed. This is useful for capturing a single frame for processing or display. ```kotlin Korender { val camera = camera(...) val projection = projection(...) val deferredImage = captureFrame(1024, 1024, camera, projection) { Renderable(...) } ... Frame { if (deferredImage.isCompleted) { val capturedImage = deferredImage.getCompleted() // Use the captured image ``` -------------------------------- ### Apply Environment Mapping to Renderable (Korender) Source: https://zakgof.github.io/projects/korender/wiki/env This code illustrates how to apply environment mapping to a `Renderable` object in Korender by adding the `ibl` material modifier, using a pre-defined `cubeMap`. ```kotlin Frame { val cubeMap = ... Renderable( base(...), ibl(cubeMap) ) ``` -------------------------------- ### Configure Screen-Space Reflections (SSR) in Deferred Shading Source: https://zakgof.github.io/projects/korender/wiki/deferred This code illustrates how to implement screen-space reflections (SSR) as a post-shading effect in Korender's deferred rendering. It allows for reflections based on surface properties and includes parameters for resolution, anti-aliasing, ray travel, and environment texture. ```korender Frame { val cubeMap = ... DeferredShading { PostShading( ssr( width = width / 4, height = height / 4, fxaa = true, maxRayTravel = 12f, linearSteps = 120, binarySteps = 4, envTexture = cubeMap ) ) } ``` -------------------------------- ### Implement Screen-Space Bloom Effect in Deferred Shading Source: https://zakgof.github.io/projects/korender/wiki/deferred Shows the configuration for applying a screen-space bloom (glow) effect as a post-shading effect within Korender's deferred rendering pipeline. Parameters control the resolution of the effect. ```korender Frame { val cubeMap = ... DeferredShading { PostShading( bloom( width = width / 2, height = height / 2 ) ) } ``` -------------------------------- ### Render Environment to Cube Texture within Korender Frame Source: https://zakgof.github.io/projects/korender/wiki/offscreen Captures the environment and renders it directly into a GPU cube texture within a Frame context. The cube texture is stored in a named probe and can be used for environment mapping, such as in Sky components. This optimizes performance by keeping data on the GPU. ```kotlin Frame { CaptureEnv("capturedEnv", 256, position = ..., near = ..., far = ... ) { Renderable(...) } ``` ```kotlin Sky(cubeTextureProbe("capturedEnv")) ``` -------------------------------- ### Vertex Shader Extension - vposition Source: https://zakgof.github.io/projects/korender/wiki/plugins Extends the vertex shader to provide custom world-space vertex positions. This function signature is `vec4 pluginVPosition()`, and it returns a `vec4` representing the vertex world space position. It has access to global variables like `pos`, `normal`, `tex`, and `model`. ```glsl vec4 pluginVPosition() { // Custom vertex world space position logic return vec4(pos, 1.0); } ``` -------------------------------- ### Define and Render Terrain Prefab in Korender (Kotlin) Source: https://zakgof.github.io/projects/korender/wiki/terrain This snippet demonstrates how to define a terrain prefab using `clipmapTerrainPrefab` and then render it within a `Frame` context using the `terrain` material modifier. It includes parameters for height texture, scale, and placement. ```kotlin Korender { val terrain = clipmapTerrainPrefab(id = "terrain", cellSize = 2.0f, hg = 10, rings = 6) ... Frame { Renderable( base(...), terrain( heightTexture = texture("terrain/heightmap.png"), heightTextureSize = 1024, heightScale = 200.0f, outsideHeight = 0.0f, terrainCenter = Vec3(0f, 300f, 0f) ), prefab = terrain ) } } ``` -------------------------------- ### Fragment Shader Extension - specular_glossiness Source: https://zakgof.github.io/projects/korender/wiki/plugins Switches the material model to specular/glossiness and provides the corresponding factors in the fragment shader. The function signature is `vec2 pluginSpecularGlossiness()`, returning a `vec2` with specular and glossiness values. It can utilize global variables like `vpos`, `vnormal`, `vtex`, `position`, `albedo`, `normal`, `emission`, `metallic`, `roughness`, and `look`. ```glsl vec2 pluginSpecularGlossiness() { // Custom specular and glossiness logic return vec2(0.5, 0.5); // Example values } ``` -------------------------------- ### Fragment Shader Extension - emission Source: https://zakgof.github.io/projects/korender/wiki/plugins Defines the light emission color for the fragment in the fragment shader. The function signature is `vec3 pluginEmission()`, returning a `vec3` representing the emission color. It can use global variables such as `vpos`, `vnormal`, `vtex`, `position`, `albedo`, `normal`, `emission`, `metallic`, `roughness`, and `look`. ```glsl vec3 pluginEmission() { // Custom emission logic return emission; } ``` -------------------------------- ### Declare a Renderable Object in Korender Frame Source: https://zakgof.github.io/projects/korender/wiki/renderables This snippet demonstrates how to declare a renderable object within the Frame context in Korender. It specifies material properties, mesh geometry, transformation, and transparency. The 'base' function is used for initial material properties. ```korender Frame { Renderable( base(color = ColorRGBA.Red, metallicFactor = 0f, roughnessFactor = 0.2f), mesh = sphere(), transform = translate(-2f, -1f, -5f), transparent = false ) } ``` -------------------------------- ### Fragment Shader Extension - texturing Source: https://zakgof.github.io/projects/korender/wiki/plugins Modifies the texture color multiplier in the fragment shader. The function signature is `vec4 pluginTexturing()`, returning a `vec4` that acts as a multiplier for the texture color. It can use global variables like `vpos`, `vnormal`, `vtex`, `position`, `albedo`, `normal`, `emission`, `metallic`, `roughness`, and `look`. ```glsl #uniform float wavescale; vec4 pluginTexturing() { float wave = 0.5 + 0.5 * sin(vtex.x * wavescale) * sin(vtex.y * wavescale); return vec4(wave, 0., 0., 1.); } ``` -------------------------------- ### Predefined Mesh Shapes in Korender Source: https://zakgof.github.io/projects/korender/wiki/meshes Korender provides helper functions to quickly generate common geometric shapes. These functions take parameters to define dimensions such as side lengths, radii, and heights. ```Korender Script quad(1.0f, 2.0f) cube(0.5f) sphere(1.0f) disk(1.0f) coneTop(1.0f, 2.0f) cylinderSide(1.0f, 2.0f) obj("models/file.obj") ``` -------------------------------- ### Render Frame to Texture within Korender Frame Source: https://zakgof.github.io/projects/korender/wiki/offscreen Renders a scene directly into a GPU texture within a Frame context, avoiding data transfer to the CPU. The rendered texture is stored in a named probe and can be reused in subsequent rendering operations. This is efficient for multi-pass rendering. ```kotlin Frame { CaptureFrame("capturedFrame", 256, 256, camera = ..., projection = ...)) { Renderable(...) } ``` ```kotlin Renderable( base(colorTexture = textureProbe("capturedFrame"), ... ``` -------------------------------- ### Water Effect as Post-Process Filter (Korender) Source: https://zakgof.github.io/projects/korender/wiki/effects Demonstrates applying the Water effect as a post-process filter in Korender. This creates a wavy water surface with reflections. Parameters include 'waterColor', 'transparency', and 'waveScale'. ```Korender Frame{ ... // Render the scene PostProcess(water(waveScale = 0.05f), fastCloudSky()) } ``` -------------------------------- ### Control GLTF Animation and Time in Korender Source: https://zakgof.github.io/projects/korender/wiki/gltf Shows how to select a specific animation index from a GLTF file and override the animation time. This is useful for GLTF files with multiple embedded animations. ```korender Frame { Gltf(resource = "model.glb", time = ..., animation = ...) } ``` -------------------------------- ### Fragment Shader Extension - occlusion Source: https://zakgof.github.io/projects/korender/wiki/plugins Overrides the occlusion value at the fragment in the fragment shader. The function signature is `float pluginOcclusion()`, returning a `float` for the occlusion value. It has access to global variables such as `vpos`, `vnormal`, `vtex`, `position`, `albedo`, `normal`, `emission`, `metallic`, `roughness`, and `look`. ```glsl float pluginOcclusion() { // Custom occlusion logic return 1.0; } ``` -------------------------------- ### Insert Korender Viewport in Compose UI (Kotlin) Source: https://zakgof.github.io/projects/korender/wiki/context Demonstrates how to insert a Korender rendering viewport into a Compose Multiplatform UI by calling the `Korender` function from a parent `@Composable` function. This sets up the basic structure for integrating the viewport. ```kotlin @Composable fun App() { Column { Text("Korender Viewport below !!!") Korender { } } } ``` -------------------------------- ### Fragment Shader Extension - metallic_roughness Source: https://zakgof.github.io/projects/korender/wiki/plugins Overrides the material's metallic and roughness factors in the fragment shader. The function signature is `vec2 pluginMetallicRoughness()`, returning a `vec2` where x is metallic and y is roughness. It has access to global variables including `vpos`, `vnormal`, `vtex`, `position`, `albedo`, `normal`, `emission`, `metallic`, `roughness`, and `look`. ```glsl vec2 pluginMetallicRoughness() { // Custom metallic and roughness logic return vec2(metallic, roughness); } ``` -------------------------------- ### Fragment Shader Extension - normal Source: https://zakgof.github.io/projects/korender/wiki/plugins Overrides the world-space normal in the fragment shader. The function signature is `vec3 pluginNormal()`, returning a `vec3` for the overridden world-space normal. It has access to global variables such as `vpos`, `vnormal`, `vtex`, `position`, `albedo`, `normal`, `emission`, `metallic`, `roughness`, and `look`. ```glsl vec3 pluginNormal() { // Custom normal logic return normal; } ``` -------------------------------- ### Fragment Shader Extension - position Source: https://zakgof.github.io/projects/korender/wiki/plugins Overrides the world-space fragment position in the fragment shader. The function signature is `vec3 pluginPosition()`, and it returns a `vec3` representing the modified world-space fragment position. It has access to global variables like `vpos`, `vnormal`, `vtex`, `albedo`, `normal`, `emission`, `metallic`, `roughness`, and `look`. ```glsl vec3 pluginPosition() { // Custom fragment world position logic return position; } ``` -------------------------------- ### Custom Mesh Generation in Korender Source: https://zakgof.github.io/projects/korender/wiki/meshes Allows for the creation of custom meshes by defining vertices, normals, texture coordinates, and indices. The `dynamic` attribute can be set to `true` for per-frame GPU updates. ```Korender Script customMesh("road", 4, 6) { pos(-0.5f, 0f, 0f).normal(1.y).tex(0f, 0f) pos(-0.5f, 0f, 32f).normal(1.y).tex(0f, 32f) pos(0.5f, 0f, 32f).normal(1.y).tex(1f, 32f) pos(0.5f, 0f, 0f).normal(1.y).tex(1f, 0f) index(0, 1, 2, 0, 2, 3) } ``` -------------------------------- ### Vertex Shader Extension - vnormal Source: https://zakgof.github.io/projects/korender/wiki/plugins Extends the vertex shader to provide custom world-space vertex normals. The function signature is `vec3 pluginVNormal()`, returning a `vec3` for the vertex world space normal. It can utilize global variables such as `pos`, `normal`, `tex`, and `model`. ```glsl vec3 pluginVNormal() { // Custom vertex world space normal logic return normal; } ``` -------------------------------- ### Fragment Shader Extension - albedo Source: https://zakgof.github.io/projects/korender/wiki/plugins Overrides the fragment's albedo (unlit color) in the fragment shader. The function signature is `vec4 pluginAlbedo()`, returning a `vec4` for the overridden albedo. It can utilize global variables including `vpos`, `vnormal`, `vtex`, `position`, `albedo`, `normal`, `emission`, `metallic`, `roughness`, and `look`. ```glsl vec4 pluginAlbedo() { // Custom albedo logic return albedo; } ``` -------------------------------- ### Smoke Effect on Batched Billboard (Korender) Source: https://zakgof.github.io/projects/korender/wiki/effects Illustrates the use of the Smoke effect on batched Billboard objects, typically for rendering smoke particles. Transparency should be enabled. Parameters include 'density' and a 'seed' for variation. -------------------------------- ### Fragment Shader Extension - discard Source: https://zakgof.github.io/projects/korender/wiki/plugins Overrides the fragment discard test in the fragment shader. The function signature is `bool pluginDiscard()`, returning a `bool` that determines if the fragment should be discarded. It has access to global variables like `vpos`, `vnormal`, `vtex`, `position`, `albedo`, `normal`, `emission`, `metallic`, `roughness`, and `look`. ```glsl bool pluginDiscard() { // Custom discard logic return false; } ``` -------------------------------- ### Render Billboard with Korender Functional Declaration Source: https://zakgof.github.io/projects/korender/wiki/billboards This code snippet demonstrates how to add a billboard to a Korender Frame context. It utilizes the 'Billboard' functional declaration and applies a 'billboard' material with specified position, scale, and rotation. Transparency is also enabled. ```korender Billboard ( base(colorTexture = texture("textures/sprite.png")), billboard( position = Vec3(3f, 5f, 7f), scale = Vec2(2f, 2f), rotation = 0.3f ), transparent = true ) ``` -------------------------------- ### Define Post-processing Effects in Korender Frame Source: https://zakgof.github.io/projects/korender/wiki/filters Demonstrates how to define post-processing effects within a Korender frame using the `PostProcess` function. This function takes material modifiers to specify the desired effect, such as horizontal and vertical blur. ```korender Frame { PostProcess(blurHorz(radius = 3.0f)) PostProcess(blurVert(radius = 3.0f)) } ``` -------------------------------- ### Fireball Effect on Billboard (Korender) Source: https://zakgof.github.io/projects/korender/wiki/effects Shows how to implement a Fireball effect, suitable for explosions, on a Billboard. Transparency must be enabled. The 'power' parameter animates the fireball's expansion from 0.0 to 1.0. ```Korender Billboard( billboard(scale = Vec2(radius * phase, radius * phase)), fireball(power = phase), transparent = true ) ``` -------------------------------- ### Fire Effect on Billboard (Korender) Source: https://zakgof.github.io/projects/korender/wiki/effects Demonstrates the usage of the Fire effect on a Billboard object in Korender. Requires transparency to be enabled. The 'strength' parameter controls the flame's ripple appearance. ```Korender Billboard( billboard(scale = Vec2(2f, 10f)), fire(strength = 4f), transparent = true ) ``` -------------------------------- ### Water Effect Source: https://zakgof.github.io/projects/korender/wiki/effects Applies a wavy water surface with sky reflections as a post-process filter. ```APIDOC ## Water Effect ### Description Wavy water surface with sky reflections. Water is implemented as a post-process filter. ### Method N/A (Shader Effect) ### Endpoint N/A (Shader Effect) ### Parameters #### Uniform Parameters - **waterColor** (ColorRGB) - Default: `ColorRGB(0x00182A)` - Water own color - **transparency** (Float) - Default: `0.1f` - Water transparency ratio - **waveScale** (Float) - Default: `0.04f` - Waves scale ratio ### Request Example ``` Frame{ ... // Render the scene PostProcess(water(waveScale = 0.05f), fastCloudSky()) } ``` ### Response #### Success Response (N/A) N/A #### Response Example N/A ``` -------------------------------- ### Fire Effect Source: https://zakgof.github.io/projects/korender/wiki/effects Implements animated flames, typically used on a Billboard with transparency. ```APIDOC ## Fire Effect ### Description Implements animated flames. Normally, it's used on a `Billboard` with transparency enabled. ### Method N/A (Shader Effect) ### Endpoint N/A (Shader Effect) ### Parameters #### Uniform Parameters - **strength** (Float) - Default: `3.0f` - Controls how rippled the flame appears, 1-5 ### Request Example ``` Billboard( billboard(scale = Vec2(2f, 10f)), fire(strength = 4f), transparent = true ) ``` ### Response #### Success Response (N/A) N/A #### Response Example N/A ``` -------------------------------- ### Smoke Effect Source: https://zakgof.github.io/projects/korender/wiki/effects Renders a single spherical smoke particle, typically used with batched `Billboard` objects and transparency. ```APIDOC ## Smoke Effect ### Description Single spherical smoke particle effect. Normally, it's used on a batched `Billboard` with transparency enabled. ### Method N/A (Shader Effect) ### Endpoint N/A (Shader Effect) ### Parameters #### Uniform Parameters - **density** (Float) - Default: `0.5f` - Smoke density, 0-1 - **seed** (Float) - Default: `0.0f` - Randomness seed - provide unique values for uniquely looking smoke particles 0-1 ### Request Example ``` // Example usage with batched billboards Batch( billboard(smoke(density = 0.8f, seed = 0.1f)), billboard(smoke(density = 0.7f, seed = 0.2f)) ) ``` ### Response #### Success Response (N/A) N/A #### Response Example N/A ``` -------------------------------- ### Fireball Effect Source: https://zakgof.github.io/projects/korender/wiki/effects A spherical fire-like effect for rendering explosions, usually applied to a Billboard with transparency. ```APIDOC ## Fireball Effect ### Description A spherical fire-like effect that can be used for rendering explosions. Normally, it's used on a `Billboard` with transparency enabled. ### Method N/A (Shader Effect) ### Endpoint N/A (Shader Effect) ### Parameters #### Uniform Parameters - **power** (Float) - Default: `0.5f` - Controls the fireball expansion: 0.0 for explosion initiation moment, 1.0 for the fully exploded fireball. Animate 0.0 to 1.0 for explosion effect ### Request Example ``` Billboard( billboard(scale = Vec2(radius * phase, radius * phase)), fireball(power = phase), transparent = true ) ``` ### Response #### Success Response (N/A) N/A #### Response Example N/A ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.