Giter VIP home page Giter VIP logo

vkgkt's Introduction

vkgKt

Release

Kotlin binding for vkg

  • Deferred Shading
  • Cascaded Shadow Mapping
  • Atmospheric Rendering
  • Ray tracing on NVIDIA RTX graphics card
  • Load glTF models.
  • Update vertices/transforms/materials/lights per frame.

sample

Usage

Requirements:

  • Graphics driver that supports Vulkan 1.2.0
  • RayTracing Feature requires RTX 20 series graphics card.

gradle:

  • Add jitpack.io in your root build.gradle.kts at the end of repositories:
repositories {
    mavenCentral()
    maven(url = "https://jitpack.io")
}
  • Add the dependency
implementation("com.github.wumo:vkgKt:0.0.6")

Sample code:

import com.github.wumo.vkg.graphics.*
import com.github.wumo.vkg.math.vector.*
import com.github.wumo.vkg.graphics.model.MaterialType
import com.github.wumo.vkg.graphics.util.PanningCamera

fun main() {
  // window and renderer setting
  val app = Renderer.newRenderer(
    WindowConfig("Sample", 1080, 720),
    FeatureConfig(numFrames = 2, rayTrace = true)
  )
  // scene setting
  val scene = app.addScene(
    SceneConfig(
      maxNumTransforms = 100_0000,
      maxNumPrimitives = 100_000,
      maxNumMeshInstances = 100_0000
    )
  )
  // atmosphere setting
  val sky = scene.atmosphere
  sky.enabled = true
  sky.sunIntensity = 1f
  sky.sunDirection = Vec3(-1f, -0.1f, 0f)

  // primitive
  val primitives = scene.newPrimitives {
    sphere(Vec3(), 1f)
    newPrimitive()
  }
  // material
  val mat = scene.newMaterial(MaterialType.BRDF)
  mat.colorFactor = Vec4(0f, 1f, 0f, 1f)
  mat.pbrFactor = Vec4(0f, 0.3f, 0.4f, 0f)
  // primitive + material => mesh
  val mesh = scene.newMesh(primitives[0], mat)
  // mesh => node
  val node = scene.newNode()
  node.addMeshes(mesh)
  // node => model
  val model = scene.newModel(node)
  // model => instance
  val sphere = scene.newModelInstance(model)

  // scene camera setting
  val camera = scene.camera
  camera.location = Vec3(-5.610391f, 0.049703f, 16.386591f)
  camera.direction = Vec3(5.610391f, -0.049703f, -16.386591f)

  // using builtin panning camera to change view
  val panningCamera = PanningCamera(camera)
  // capture input
  val input = app.window.input

  //render loop
  app.loop { frameIdx, elapsedMs ->
    // update camera from input
    panningCamera.update(input)

    // apply transform per frame
    val t = sphere.transform.translation
    t.x -= elapsedMs.toFloat() * 0.001f
    sphere.transform.translation = t
  }
}

vkgkt's People

Contributors

wumo avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.