zhishenguoke 5 éve
commit
6de0287b75
90 módosított fájl, 44009 hozzáadás és 0 törlés
  1. 21 0
      .gitignore
  2. 19 0
      README.md
  3. 5 0
      babel.config.js
  4. 11318 0
      package-lock.json
  5. 32 0
      package.json
  6. BIN
      public/favicon.ico
  7. 17 0
      public/index.html
  8. 6869 0
      public/jslib/marmoset.js
  9. BIN
      public/static/image/uv_grid_directx.jpg
  10. BIN
      public/static/model/henrique/henrique.mview
  11. BIN
      public/static/model/metal/metal.mview
  12. 13 0
      public/static/model/vivfox/vivfox.html
  13. BIN
      public/static/model/vivfox/vivfox.mview
  14. 20439 0
      public/static/sky/compress/test.sky
  15. BIN
      public/static/sky/depressed/sky.png
  16. BIN
      public/static/sky/example/negx.jpg
  17. BIN
      public/static/sky/example/negy.jpg
  18. BIN
      public/static/sky/example/negz.jpg
  19. BIN
      public/static/sky/example/posx.jpg
  20. BIN
      public/static/sky/example/posy.jpg
  21. BIN
      public/static/sky/example/posz.jpg
  22. 20 0
      public/static/sky/example/readme.txt
  23. 35 0
      src/App.vue
  24. BIN
      src/assets/logo.png
  25. 13 0
      src/main.ts
  26. 51 0
      src/router/index.ts
  27. 13 0
      src/shims-tsx.d.ts
  28. 4 0
      src/shims-vue.d.ts
  29. 138 0
      src/views/Home.vue
  30. 54 0
      src/views/MaterialViewer.vue
  31. 65 0
      src/views/PostEffectViewer.vue
  32. 321 0
      src/views/RTTest.vue
  33. 200 0
      src/views/Test.vue
  34. 88 0
      src/views/TextureViewer.vue
  35. 175 0
      src/webgl/Viewer.ts
  36. 140 0
      src/webgl/assets/marmosets/MarmosetAssetsManager.ts
  37. 32 0
      src/webgl/assets/marmosets/MviewFiles/Camera.ts
  38. 23 0
      src/webgl/assets/marmosets/MviewFiles/Light.ts
  39. 50 0
      src/webgl/assets/marmosets/MviewFiles/Material.ts
  40. 41 0
      src/webgl/assets/marmosets/MviewFiles/Mesh.ts
  41. 15 0
      src/webgl/assets/marmosets/MviewFiles/MviewAsset.ts
  42. 49 0
      src/webgl/assets/marmosets/MviewFiles/PostEffect.ts
  43. 37 0
      src/webgl/assets/marmosets/MviewFiles/Scene.ts
  44. 15 0
      src/webgl/assets/marmosets/MviewFiles/Sky.ts
  45. 22 0
      src/webgl/assets/marmosets/MviewFiles/index.ts
  46. 140 0
      src/webgl/assets/marmosets/parser/BufferReader.ts
  47. 132 0
      src/webgl/assets/marmosets/parser/index.ts
  48. 11 0
      src/webgl/assets/marmosets/shaders/ShaderCache.ts
  49. 83 0
      src/webgl/assets/marmosets/shaders/alphaprepass.ts
  50. 83 0
      src/webgl/assets/marmosets/shaders/bloom.ts
  51. 19 0
      src/webgl/assets/marmosets/shaders/chunks/alphaprepassfrag.glsl
  52. 21 0
      src/webgl/assets/marmosets/shaders/chunks/alphaprepassvert.glsl
  53. 26 0
      src/webgl/assets/marmosets/shaders/chunks/blit.glsl
  54. 23 0
      src/webgl/assets/marmosets/shaders/chunks/bloom.glsl
  55. 17 0
      src/webgl/assets/marmosets/shaders/chunks/bloomshrink.glsl
  56. 244 0
      src/webgl/assets/marmosets/shaders/chunks/fogfrag.glsl
  57. 12 0
      src/webgl/assets/marmosets/shaders/chunks/fogvert.glsl
  58. 5 0
      src/webgl/assets/marmosets/shaders/chunks/matdither.glsl
  59. 352 0
      src/webgl/assets/marmosets/shaders/chunks/matfrag.glsl
  60. 146 0
      src/webgl/assets/marmosets/shaders/chunks/matlighting.glsl
  61. 60 0
      src/webgl/assets/marmosets/shaders/chunks/matmicrofiber.glsl
  62. 61 0
      src/webgl/assets/marmosets/shaders/chunks/matsampling.glsl
  63. 200 0
      src/webgl/assets/marmosets/shaders/chunks/matshadows.glsl
  64. 218 0
      src/webgl/assets/marmosets/shaders/chunks/matskin.glsl
  65. 34 0
      src/webgl/assets/marmosets/shaders/chunks/matstrips.glsl
  66. 72 0
      src/webgl/assets/marmosets/shaders/chunks/matvert.glsl
  67. 10 0
      src/webgl/assets/marmosets/shaders/chunks/postaa.glsl
  68. 108 0
      src/webgl/assets/marmosets/shaders/chunks/postfrag.glsl
  69. 12 0
      src/webgl/assets/marmosets/shaders/chunks/postvert.glsl
  70. 52 0
      src/webgl/assets/marmosets/shaders/chunks/shadowfloorfrag.glsl
  71. 24 0
      src/webgl/assets/marmosets/shaders/chunks/shadowfloorvert.glsl
  72. 35 0
      src/webgl/assets/marmosets/shaders/chunks/shadowfrag.glsl
  73. 28 0
      src/webgl/assets/marmosets/shaders/chunks/shadowvert.glsl
  74. 13 0
      src/webgl/assets/marmosets/shaders/chunks/sky.glsl
  75. 28 0
      src/webgl/assets/marmosets/shaders/chunks/skyBake.glsl
  76. 28 0
      src/webgl/assets/marmosets/shaders/chunks/skySH.glsl
  77. 37 0
      src/webgl/assets/marmosets/shaders/chunks/skyvert.glsl
  78. 14 0
      src/webgl/assets/marmosets/shaders/chunks/wirefrag.glsl
  79. 16 0
      src/webgl/assets/marmosets/shaders/chunks/wirevert.glsl
  80. 156 0
      src/webgl/assets/marmosets/shaders/posteffect.ts
  81. 13 0
      src/webgl/materials/marmoset/BasicMaterial.ts
  82. 19 0
      src/webgl/materials/marmoset/ComplexMaterial.ts
  83. 157 0
      src/webgl/materials/marmoset/MeshMaterial.ts
  84. 12 0
      src/webgl/materials/marmoset/index.ts
  85. 205 0
      src/webgl/objects/MarmosetModel.ts
  86. 339 0
      src/webgl/posts/TestPass.ts
  87. 7 0
      src/webgl/posts/index.ts
  88. 320 0
      src/webgl/sky/MarmosetSky.ts
  89. 44 0
      src/webgl/textures/MarmosetTexture.ts
  90. 39 0
      tsconfig.json

+ 21 - 0
.gitignore

@@ -0,0 +1,21 @@
+.DS_Store
+node_modules
+/dist
+
+# local env files
+.env.local
+.env.*.local
+
+# Log files
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+
+# Editor directories and files
+.idea
+.vscode
+*.suo
+*.ntvs*
+*.njsproj
+*.sln
+*.sw?

+ 19 - 0
README.md

@@ -0,0 +1,19 @@
+# renderer
+
+## Project setup
+```
+npm install
+```
+
+### Compiles and hot-reloads for development
+```
+npm run serve
+```
+
+### Compiles and minifies for production
+```
+npm run build
+```
+
+### Customize configuration
+See [Configuration Reference](https://cli.vuejs.org/config/).

+ 5 - 0
babel.config.js

@@ -0,0 +1,5 @@
+module.exports = {
+  presets: [
+    '@vue/cli-plugin-babel/preset'
+  ]
+}

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 11318 - 0
package-lock.json


+ 32 - 0
package.json

@@ -0,0 +1,32 @@
+{
+  "name": "renderer",
+  "version": "0.1.0",
+  "private": true,
+  "scripts": {
+    "serve": "vue-cli-service serve",
+    "build": "vue-cli-service build"
+  },
+  "dependencies": {
+    "core-js": "^3.6.4",
+    "element-ui": "^2.13.0",
+    "three": "^0.113.2",
+    "vue": "^2.6.11",
+    "vue-class-component": "^7.2.2",
+    "vue-property-decorator": "^8.3.0",
+    "vue-router": "^3.1.5"
+  },
+  "devDependencies": {
+    "@vue/cli-plugin-babel": "~4.2.0",
+    "@vue/cli-plugin-router": "~4.2.0",
+    "@vue/cli-plugin-typescript": "~4.2.0",
+    "@vue/cli-service": "~4.2.0",
+    "less": "^3.0.4",
+    "less-loader": "^5.0.0",
+    "typescript": "~3.7.5",
+    "vue-template-compiler": "^2.6.11"
+  },
+  "browserslist": [
+    "> 1%",
+    "last 2 versions"
+  ]
+}

BIN
public/favicon.ico


+ 17 - 0
public/index.html

@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width,initial-scale=1.0">
+    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
+    <title><%= htmlWebpackPlugin.options.title %></title>
+  </head>
+  <body>
+    <noscript>
+      <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
+    </noscript>
+    <div id="app"></div>
+    <!-- built files will be auto injected -->
+  </body>
+</html>

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 6869 - 0
public/jslib/marmoset.js


BIN
public/static/image/uv_grid_directx.jpg


BIN
public/static/model/henrique/henrique.mview


BIN
public/static/model/metal/metal.mview


+ 13 - 0
public/static/model/vivfox/vivfox.html

@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<meta name="viewport" content="user-scalable=0"/>
+<html>
+<head>
+    <title></title>
+    <script src="https://viewer.marmoset.co/main/marmoset.js"></script>
+</head>
+<body>
+    <script>
+        marmoset.embed( 'vivfox.mview', { width: 800, height: 600, autoStart: true, fullFrame: false, pagePreset: false } );
+    </script>
+</body>
+</html>

BIN
public/static/model/vivfox/vivfox.mview


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 20439 - 0
public/static/sky/compress/test.sky


BIN
public/static/sky/depressed/sky.png


BIN
public/static/sky/example/negx.jpg


BIN
public/static/sky/example/negy.jpg


BIN
public/static/sky/example/negz.jpg


BIN
public/static/sky/example/posx.jpg


BIN
public/static/sky/example/posy.jpg


BIN
public/static/sky/example/posz.jpg


+ 20 - 0
public/static/sky/example/readme.txt

@@ -0,0 +1,20 @@
+Author
+======
+
+This is the work of Emil Persson, aka Humus.
+http://www.humus.name
+humus@comhem.se
+
+
+
+Legal stuff
+===========
+
+This work is free and may be used by anyone for any purpose
+and may be distributed freely to anyone using any distribution
+media or distribution method as long as this file is included.
+Distribution without this file is allowed if it's distributed
+with free non-commercial software; however, fair credit of the
+original author is expected.
+Any commercial distribution of this software requires the written
+approval of Emil Persson.

+ 35 - 0
src/App.vue

@@ -0,0 +1,35 @@
+<template>
+  <div id="app">
+    <router-view/>
+  </div>
+</template>
+
+<style lang="less">
+#app {
+  font-family: Avenir, Helvetica, Arial, sans-serif;
+  -webkit-font-smoothing: antialiased;
+  -moz-osx-font-smoothing: grayscale;
+  text-align: center;
+  color: #2c3e50;
+}
+
+#nav {
+  padding: 30px;
+
+  a {
+    font-weight: bold;
+    color: #2c3e50;
+
+    &.router-link-exact-active {
+      color: #42b983;
+    }
+  }
+}
+
+body, html {
+
+  padding: 0;
+  margin: 0;
+  
+}
+</style>

BIN
src/assets/logo.png


+ 13 - 0
src/main.ts

@@ -0,0 +1,13 @@
+import Vue from 'vue'
+import App from './App.vue'
+import router from './router'
+import ElementUI from 'element-ui'
+import 'element-ui/lib/theme-chalk/index.css'
+
+Vue.config.productionTip = false
+Vue.use(ElementUI)
+
+new Vue({
+  router,
+  render: h => h(App)
+}).$mount('#app')

+ 51 - 0
src/router/index.ts

@@ -0,0 +1,51 @@
+import Vue from 'vue'
+import VueRouter from 'vue-router'
+import Home from '../views/Home.vue'
+import Test from '../views/Test.vue'
+import TextureViewer from '../views/TextureViewer.vue'
+import MaterialViewer from '../views/MaterialViewer.vue'
+import PostEffectViewer from '../views/PostEffectViewer.vue'
+import RTTest from '../views/RTTest.vue'
+
+Vue.use(VueRouter)
+
+const routes = [
+  {
+    path: '/',
+    name: 'Home',
+    component: Home
+  },
+  {
+    path: '/test',
+    name: 'Test',
+    component: Test
+  },
+  {
+    path: '/textures',
+    name: 'TextureViewer',
+    component: TextureViewer
+  },
+  {
+    path: '/materials',
+    name: 'MaterialViewer',
+    component: MaterialViewer
+  },
+  {
+    path: '/posts',
+    name: 'PostEffectViewer',
+    component: PostEffectViewer
+  },
+  {
+    path:'/rttest',
+    name:'RTTest',
+    component: RTTest
+  }
+]
+
+const router = new VueRouter({
+  mode: 'history',
+  base: process.env.BASE_URL,
+  routes
+})
+
+export default router

+ 13 - 0
src/shims-tsx.d.ts

@@ -0,0 +1,13 @@
+import Vue, { VNode } from 'vue'
+
+declare global {
+  namespace JSX {
+    // tslint:disable no-empty-interface
+    interface Element extends VNode {}
+    // tslint:disable no-empty-interface
+    interface ElementClass extends Vue {}
+    interface IntrinsicElements {
+      [elem: string]: any
+    }
+  }
+}

+ 4 - 0
src/shims-vue.d.ts

@@ -0,0 +1,4 @@
+declare module '*.vue' {
+  import Vue from 'vue'
+  export default Vue
+}

+ 138 - 0
src/views/Home.vue

@@ -0,0 +1,138 @@
+<template>
+    <div class="home">
+      <div class="header">
+
+      </div>
+      <div class="content">
+        <div id="left">
+          <a @click="showAssetsList(0)" href=""> 材质 </a>
+          <a @click="showAssetsList(1)" href=""> 贴图 </a>
+        </div>
+        <div id="middle">
+            <div id="viewerContainner">
+              
+            </div>
+            <div id="assetsList">
+
+            </div>
+        </div>
+        <div id="right"></div>
+      </div>
+    </div>
+</template>
+
+<script lang="ts">
+import { Component, Vue } from 'vue-property-decorator';
+import Viewer from '../webgl/Viewer'
+import MarmosetAssetsManager from '../webgl/assets/marmosets/MarmosetAssetsManager'
+import * as THREE from 'three'
+import { MeshMaterial } from '../webgl/materials/marmoset';
+
+const examples = [
+  "static/model/henrique/henrique.mview",
+  "static/model/vivfox/vivfox.mview",
+  "static/model/metal/metal.mview",
+]
+
+
+@Component
+export default class Home extends Vue {
+
+  materials: MeshMaterial[] = []
+
+  mounted() {
+
+    let containner = this.$el.querySelector("#viewerContainner") as HTMLDivElement;
+    let viewer = new Viewer();
+    viewer.start(containner)
+    
+    let loader = new MarmosetAssetsManager()
+
+    let index = Number(this.$route.query['index']) || 0
+
+    loader.load(examples[index]).then( model => {
+
+      model && viewer.add(model);
+      
+      let ms = loader.getMaterials();
+      ms.forEach( item => this.materials.push(item));
+
+    })
+    window.THREE = THREE
+
+  }
+
+  showAssetsList( flag: number ) {
+
+    
+
+  }
+}
+</script>
+<style lang="less" scoped>
+
+  .home {
+
+
+    display: flex;
+    flex-direction: column;
+    justify-content: space-between;
+
+    position: fixed;
+    width: 100%;
+    height: 100%;
+
+    .header {
+
+      height: 3rem;
+
+    }
+
+    .content {
+
+      flex: 1;
+      border: 1px solid red;
+      height: 100%;
+
+      display: flex;
+      justify-content: space-between;
+
+    }
+
+    
+    #left {
+
+      width: 3rem
+
+    }
+
+    #middle {
+
+      flex: 1;
+
+      display: flex;
+      flex-direction: column;
+
+      
+
+    }
+  
+    #right {
+
+      width: 200px;
+    }
+
+    #assetsList {
+
+      height: 200px;
+    }
+
+    #viewerContainner {
+
+      flex: 1;
+
+    }
+
+  }
+
+</style>

+ 54 - 0
src/views/MaterialViewer.vue

@@ -0,0 +1,54 @@
+<template>
+  <div class="test">
+    <div id="containner"></div>
+  </div>
+</template>
+
+<script lang="ts">
+import { Component, Vue } from 'vue-property-decorator';
+import Viewer from '../webgl/Viewer'
+import MarmosetAssetsManager from '../webgl/assets/marmosets/MarmosetAssetsManager'
+import * as THREE from 'three'
+import { MeshMaterial as MarmosetMaterial } from '../webgl/materials/marmoset'
+
+const examples = [
+  "static/model/henrique/henrique.mview",
+  "static/model/vivfox/vivfox.mview",
+]
+
+
+@Component
+export default class MaterialViewer extends Vue {
+
+
+  mounted() {
+
+    let containner = this.$el.querySelector("#containner") as HTMLDivElement;
+    let viewer = new Viewer();
+    viewer.start(containner)
+    
+
+    let box = new THREE.Mesh(
+        new THREE.SphereBufferGeometry(10,30,30),
+        //new THREE.MeshNormalMaterial({})
+        new MarmosetMaterial()
+    )
+
+    viewer.add(box)
+
+  }
+}
+</script>
+<style lang="less" scoped>
+
+  #containner {
+
+    position: fixed;
+    left: 0;
+    top:0;
+    width: 100%;
+    height: 100%;
+
+  }
+
+</style>

+ 65 - 0
src/views/PostEffectViewer.vue

@@ -0,0 +1,65 @@
+<template>
+  <div class="test">
+    <div id="containner"></div>
+  </div>
+</template>
+
+<script lang="ts">
+import { Component, Vue } from 'vue-property-decorator';
+import Viewer from '../webgl/Viewer'
+import MarmosetAssetsManager from '../webgl/assets/marmosets/MarmosetAssetsManager'
+import * as THREE from 'three'
+import { MeshMaterial as MarmosetMaterial } from '../webgl/materials/marmoset'
+import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass';
+import { TestPass } from '../webgl/posts'
+
+const examples = [
+  "static/model/henrique/henrique.mview",
+  "static/model/vivfox/vivfox.mview",
+]
+
+
+@Component
+export default class PostEffectViewer extends Vue {
+
+
+  mounted() {
+
+    window['THREE'] = THREE
+
+
+    let containner = this.$el.querySelector("#containner") as HTMLDivElement;
+    let viewer = new Viewer();
+   
+    let testPE = new TestPass();
+    viewer.start(containner)
+    viewer.addPostEffectPass(testPE)
+
+
+    
+    let loader = new MarmosetAssetsManager()
+
+    let index = Number(this.$route.query['index']) || 0
+
+    loader.load(examples[index]).then( model => {
+
+      model && viewer.add(model);
+   
+    })
+
+  }
+}
+</script>
+<style lang="less" scoped>
+
+  #containner {
+
+    position: fixed;
+    left: 0;
+    top:0;
+    width: 100%;
+    height: 100%;
+
+  }
+
+</style>

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 321 - 0
src/views/RTTest.vue


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 200 - 0
src/views/Test.vue


+ 88 - 0
src/views/TextureViewer.vue

@@ -0,0 +1,88 @@
+<template>
+  <div class="test">
+    <ul class="album">
+        <li v-for="(item, index) in imgUrl" :key="index">
+            {{ item.name }}
+            <img :src = item.url />
+        </li>
+    </ul>
+  </div>
+</template>
+
+<script lang="ts">
+import { Component, Vue } from 'vue-property-decorator';
+import MarmosetAssetsManager from '../webgl/assets/marmosets/MarmosetAssetsManager'
+import MarmosetModel from '../webgl/objects/MarmosetModel';
+
+
+const examples = [
+  "static/model/henrique/henrique.mview",
+  "static/model/vivfox/vivfox.mview",
+  "static/model/metal/metal.mview",
+]
+
+
+@Component
+export default class TextureViewer extends Vue {
+
+  imgUrl: { name: string, url: string } [] = []
+
+  mounted() {
+
+    let assetsMgr = new MarmosetAssetsManager();
+
+    let model = new MarmosetModel();
+
+    let index = Number(this.$route.query['index'])
+
+    assetsMgr.load(examples[index]).then( model => {
+
+      let textures = assetsMgr.getTextures();
+
+      textures.forEach( item => {
+
+        let file = assetsMgr.files.get(item.name)
+
+        if(file ) {
+            this.imgUrl.push({
+              name: item.name,
+              url: URL.createObjectURL(new Blob([new Uint8Array(file.data)], { type: file.type }))
+            })
+        }
+
+        
+      })
+
+    })
+
+  }
+}
+</script>
+<style lang="less" scoped>
+
+    .album {
+
+        list-style: none;
+
+        background: #ccc;
+
+        display: flex;
+        justify-content:space-around;
+        flex-wrap: wrap;
+
+        li {
+
+          display: flex;
+          justify-content:center;
+          flex-direction: column;
+          align-items: center;
+
+          border-bottom: 1px solid white; 
+        }
+
+        img {
+          height: 300px;
+        }
+
+    }
+</style>

+ 175 - 0
src/webgl/Viewer.ts

@@ -0,0 +1,175 @@
+
+import * as THREE from 'three';
+import { OrbitControls } from '../../node_modules/three/examples/jsm/controls/OrbitControls'
+import Stats from '../../node_modules/three/examples/jsm/libs/stats.module'
+import { EffectComposer } from '../../node_modules/three/examples/jsm/postprocessing/EffectComposer'
+import { RenderPass } from '../../node_modules/three/examples/jsm/postprocessing/RenderPass'
+import { Pass } from 'three/examples/jsm/postprocessing/Pass';
+import { TestPass } from './posts';
+
+class Viewer {
+
+    private clock: THREE.Clock;
+    private viewSize: THREE.Vector2;
+    private container: HTMLDivElement | null;
+
+      renderer: THREE.WebGLRenderer;
+    private composer: EffectComposer
+
+    private scene: THREE.Scene
+    private camera: THREE.PerspectiveCamera
+    private controls: OrbitControls;
+    private stats: Stats
+
+    constructor() {
+
+        this.clock = new THREE.Clock(false);
+        this.container = null;
+        this.viewSize = new THREE.Vector2();
+
+        this.renderer = new THREE.WebGLRenderer({ antialias: true });
+        this.composer = new EffectComposer(this.renderer);
+        
+        this.scene = new THREE.Scene();
+        this.camera = new THREE.PerspectiveCamera();
+        this.controls = new OrbitControls(this.camera, this.renderer.domElement);
+        
+        this.stats = Stats();
+        
+    }
+
+    init() {
+
+        this.clock.start();
+
+        this.renderer.setPixelRatio(window.devicePixelRatio);
+        this.renderer.domElement.style.width = '100%';
+        this.renderer.domElement.style.height = '100%';
+        
+        this.composer.addPass(new RenderPass(this.scene, this.camera));
+        //this.composer.addPass(new TestPass())
+
+        this.camera.aspect = window.innerWidth / window.innerHeight;
+        this.camera.position.set(0, 20.51227126407633, 50.3253462213248);
+        this.camera.updateProjectionMatrix();
+
+        this.scene.add(new THREE.GridHelper(1000, 50));
+        this.scene.add(new THREE.AxesHelper(30));
+    
+        
+        let pointLight = new THREE.PointLight(0xffffff, 20, 300)
+        pointLight.position.set(0, 15, 0);
+        pointLight.updateMatrixWorld()
+        this.scene.add(pointLight);
+        this.scene.add(new THREE.PointLightHelper(pointLight))
+
+        let directionLight = new THREE.DirectionalLight(0xffffff, 1)
+        directionLight.position.set(10,10,10)
+        this.scene.add(directionLight)
+        this.scene.add(new THREE.DirectionalLightHelper(directionLight))
+
+        this.scene.add(new THREE.AmbientLight(0xffffff, 1))
+
+        this.renderer.physicallyCorrectLights = true
+        
+
+        this.controls.enableDamping = true;
+        this.controls.dampingFactor = 0.5;
+        this.controls.update()
+        this.update(0.016)
+        this.render();
+    }
+
+    add(object: THREE.Object3D) {
+        this.scene.add(object);
+    }
+
+    remove(object: THREE.Object3D) {
+        this.scene.remove(object)
+    }
+
+    addPostEffectPass( pass: Pass) {
+
+        this.composer.addPass(pass);
+
+    }
+
+    start( container : HTMLDivElement) {
+
+        this.container = container;
+        (this.container || document.body).appendChild(this.renderer.domElement);
+        this.init();
+        this.animate();
+
+    }
+
+    private animate() {
+
+        this.update(this.clock.getDelta());
+        this.render();
+        this.stats.update()
+        window.requestAnimationFrame(this.animate.bind(this));
+    }
+
+    private update(deltaTime: number) {
+
+        this.updateSize();
+    }
+
+    private updateSize() {
+
+        let width = this.container && this.container.clientWidth || window.innerWidth;
+        let height = this.container && this.container.clientHeight || window.innerHeight;
+
+        this.renderer.setSize(width, height, false);
+        this.camera.aspect = width / height;
+        this.camera.updateProjectionMatrix();
+
+        // let width = Math.floor(this.renderer.domElement.clientWidth);
+        // let height = Math.floor(this.renderer.domElement.clientHeight);
+
+        
+        // if( width != this.renderer.domElement.width || height != this.renderer.domElement.height ) {
+
+        //     this.renderer.setSize(width, height, false);
+        //     this.renderer.getSize(this.viewSize);
+
+        //     this.camera.aspect = width / height;
+        //     this.camera.updateProjectionMatrix();
+
+        // }
+
+
+        
+    }
+
+    private render() {
+        
+        this.composer.render();
+
+    }
+
+
+    bakeTexture( width: number, height: number, ) {
+
+        let renderTarget = new THREE.WebGLRenderTarget(width, height);
+
+        let geometry = new THREE.BufferGeometry();
+            geometry.setAttribute("", new THREE.Float32BufferAttribute([], 4))
+            geometry.setIndex([0,1,2])
+
+        
+        //this.renderer.renderBufferDirect();
+
+    }
+
+}
+
+const RTUtil = {
+
+    camera: new THREE.OrthographicCamera(-1, 1, 1, -1, 0.1, 1),
+    scene: new THREE.Scene(),
+
+}
+
+export default Viewer;

+ 140 - 0
src/webgl/assets/marmosets/MarmosetAssetsManager.ts

@@ -0,0 +1,140 @@
+import * as THREE from 'three'
+
+import { MviewAsset, Scene } from './MviewFiles'
+import { Parser } from './parser' 
+
+import { MeshMaterial } from '../../materials/marmoset'
+import MarmosetModel from '../../objects/MarmosetModel'
+import MarmosetTexture from '@/webgl/textures/MarmosetTexture'
+import MarmosetSky from '@/webgl/sky/MarmosetSky'
+
+export default class MarmosetAssetsManager {
+
+    parser: Parser
+
+    files: Map <string, MviewAsset>
+
+    private materials: Map<string, MeshMaterial>
+
+    private textures: Map<string, MarmosetTexture>
+
+    sky: THREE.CubeTexture;
+
+    private sceneInfo: Scene | null;
+
+    constructor() {
+
+        this.parser = new Parser();
+
+        this.files = new Map();
+
+        this.materials = new Map();
+
+        this.textures = new Map();
+
+        this.sky = new THREE.CubeTexture()
+
+        this.sceneInfo = null;
+    }
+
+    getTextures() { return this.textures }
+    getMaterials() { return this.materials }
+
+    private loadBuffer( url: string ) {
+
+       return fetch(new Request(url)).then( response => response.arrayBuffer())
+
+    }
+
+    async loadAssets( url: string ) {
+
+        return this.loadBuffer( url ).then( buffer => {
+
+            let files = this.parser.parse(buffer);
+            let sceneInfoData = files.get("scene.json");
+
+            if(!sceneInfoData) {
+
+                throw("文件没有场景数据")
+            }
+
+            let sceneInfo = this.parser.parseSceneInfo(sceneInfoData)
+
+            return [ files, sceneInfo ]
+        })
+    }
+
+    async load( url: string ) {
+ 
+        return this.loadBuffer(url).then( buffer => {
+
+            this.files = this.parser.parse(buffer)
+
+            let sceneInfoData = this.files.get("scene.json");
+                
+            if(!sceneInfoData) {
+
+                throw("文件没有场景数据")
+            }
+
+            this.sceneInfo = this.parser.parseSceneInfo( sceneInfoData );
+            console.log(this.sceneInfo)
+            console.log(this.files)
+
+            if(this.sceneInfo ) {
+
+                return this.parseScene( this.sceneInfo, this.files );
+            }
+            
+        }) 
+        
+    }
+
+    private parseScene( sceneInfo: Scene, assets: Map<string, MviewAsset> ) {
+
+        //贴图
+        assets.forEach( item => {
+
+            if(item.type == "image/jpeg") {
+
+                let texture = new MarmosetTexture()
+                texture.build(item);
+                this.textures.set(item.name, texture);
+
+            }
+
+        })
+
+        
+
+        //建立材质
+        sceneInfo.materials.forEach( item => {
+
+            //console.log(item)
+            let material = new MeshMaterial();
+            material.build( item, this.textures, this.sky );
+
+            this.materials.set(item.name, material)
+        })
+
+
+        //建立模型
+        let model = new MarmosetModel();
+        model.buildMeshes(sceneInfo.meshes, this.files, this.materials);
+
+    
+        //建立背景
+        let background = new MarmosetSky();
+            background.build(sceneInfo.sky, this.files); 
+
+
+        let group = new THREE.Group()
+            group.add(model);
+            group.add(background);
+
+        return group;
+    }
+ 
+
+
+}

+ 32 - 0
src/webgl/assets/marmosets/MviewFiles/Camera.ts

@@ -0,0 +1,32 @@
+
+import PostEffect from './PostEffect'
+
+interface Camera {
+
+    view: CameraView
+
+    post: PostEffect
+
+}
+
+interface CameraView {
+
+    angles: number[]
+
+    orbitRadius: number;
+
+    pivot: number[]
+
+    fov: number
+
+    limits: {
+
+        angles: { x: { min: number, max: number, offset: number } }
+
+        orbitRadius: { min: number, max: number }
+
+    }
+}
+
+
+export default Camera

+ 23 - 0
src/webgl/assets/marmosets/MviewFiles/Light.ts

@@ -0,0 +1,23 @@
+interface LightCollection {
+
+    count: number
+
+    shadowCount: number
+
+    rotation: number
+
+    positions: number[]
+
+    directions: number[]
+
+    colors: number[]
+
+    parameters: number[]
+
+    spot: number[]
+
+    matrixWeights: number[]
+}
+
+
+export default LightCollection

+ 50 - 0
src/webgl/assets/marmosets/MviewFiles/Material.ts

@@ -0,0 +1,50 @@
+interface Material {
+
+    name: string
+
+    albedoTex: string
+
+    reflectivityTex: string
+
+    normalTex: string
+
+    glossTex: string
+
+    extrasTex: string
+
+    alphaTex: string
+
+    blend: string
+
+    alphaTest: 0
+
+    fresnel: [number, number, number]
+
+    horizonOcclude: number
+
+    horizonSmoothing: number
+
+    aoSecondaryUV: number
+
+    tangentOrthogonalize: number
+
+    tangentNormalize: number
+
+    tangentGenerateBitangent: number
+
+    useSkin: boolean
+
+    aniso: number
+
+    microfiber: boolean
+
+    extrasTexCoordRanges?: {
+
+        aoTex: {
+
+            scaleBias: [number, number, number, number]
+
+        }
+    }
+}
+export default Material

+ 41 - 0
src/webgl/assets/marmosets/MviewFiles/Mesh.ts

@@ -0,0 +1,41 @@
+interface Mesh {
+
+    name: string
+
+    indexCount: number
+
+    indexTypeSize: number   // 2 | 4 对应 short | int
+
+    wireCount: number
+
+    vertexCount: number
+
+    cullBackFaces: 1
+
+    castShadows: 1
+
+    minBound: [number, number, number]
+
+    maxBound: [number, number, number]
+
+    subMeshes: SubMesh[]
+
+    transform: [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number]
+
+    file: string
+}
+
+
+interface SubMesh {
+
+    material: string
+
+    firstIndex: number
+
+    indexCount: number
+
+    firstWireIndex: number
+
+    wireIndexCount: number
+}
+export default Mesh 

+ 15 - 0
src/webgl/assets/marmosets/MviewFiles/MviewAsset.ts

@@ -0,0 +1,15 @@
+
+interface MviewAsset {
+
+    flag: number
+
+    name: string
+
+    type: 'sky.dat'|'image/jpeg'|'image/derp'|'model/mset'|'image/jpeg'|'application/json'
+
+    data: ArrayBuffer
+
+}
+
+
+export default MviewAsset

+ 49 - 0
src/webgl/assets/marmosets/MviewFiles/PostEffect.ts

@@ -0,0 +1,49 @@
+interface PostEffect {
+
+
+    //Tone Mapping
+
+    toneMap: number         // 0 - Linear  1 - Reinhard  2 - Filmic(Hejl)
+
+    brightness: [number, number, number, number]
+
+    contrast: [number, number, number, number]
+
+    bias: [number, number, number, number]
+
+    saturation: [number, number, number, number]
+
+
+    //Sharpen 
+
+    sharpen: number
+
+    sharpenLimit: number
+
+
+    //Bloom
+
+    bloomColor: [number, number, number, number]
+
+    bloomSize: number
+
+
+    //Vignette
+
+    vignette: [number, number, number, number]
+
+    vignetteCurve: number
+
+
+    //Grain
+
+    grain: number
+
+    grainSharpness: number
+
+    
+
+    colorLUT: []
+}
+
+export default PostEffect

+ 37 - 0
src/webgl/assets/marmosets/MviewFiles/Scene.ts

@@ -0,0 +1,37 @@
+
+import Camera from './Camera'
+import Mesh from './Mesh'
+import Sky from './Sky'
+import LightCollection from './Light'
+import Material from './Material'
+
+interface Scene {
+
+    metaData: MetaData
+
+    mainCamera: Camera
+
+    Cameras: Camera[],
+
+    lights: LightCollection
+
+    sky: Sky
+
+    meshes: Mesh[]
+
+    materials: Material[]
+}
+
+interface MetaData {
+
+    title: string
+
+    authot:string
+
+    link:string
+
+    tbVersion:number
+
+}
+
+export default Scene

+ 15 - 0
src/webgl/assets/marmosets/MviewFiles/Sky.ts

@@ -0,0 +1,15 @@
+interface Sky {
+
+    imageUrl: string
+
+    diffuseCoefficients: number[]
+
+    backgroundMode: number  // 0 - Color | 1 - Image | 2 -  | 3 - 球协镜面光照
+
+    backgroundBrightness: number
+    
+    backgroundColor: [number, number, number, number]      
+
+}
+
+export default Sky

+ 22 - 0
src/webgl/assets/marmosets/MviewFiles/index.ts

@@ -0,0 +1,22 @@
+import MviewAsset from './MviewAsset'
+import Scene from './Scene'
+import PostEffect from './PostEffect'
+import Sky from './Sky'
+import Mesh from './Mesh'
+import Material from './Material'
+
+export {
+
+    MviewAsset,
+
+    Scene,
+
+    PostEffect,
+
+    Sky,
+
+    Mesh,
+
+    Material
+
+}

+ 140 - 0
src/webgl/assets/marmosets/parser/BufferReader.ts

@@ -0,0 +1,140 @@
+export default class BufferReader {
+
+
+    private buffer: ArrayBuffer;
+    private index: number;
+    private dataView: DataView;
+
+    constructor(buffer: ArrayBuffer) {
+
+        this.buffer = buffer;
+        this.index = 0;
+        this.dataView = new DataView(this.buffer);
+    }
+
+    seek(position: number) {
+
+        this.index = position;
+    }
+
+    getIndex() {
+
+        return this.index;
+    }
+
+    getSize() {
+
+        return this.buffer.byteLength;
+    }
+
+    skip(length: number) {
+
+        this.index += length;
+    }
+
+    readBytes(length: number) {
+
+        return this.dataView.buffer.slice(this.index, this.index += length);
+
+    }
+
+    readInt32() {
+
+        let value = this.dataView.getInt32(this.index, true);
+        this.index += 4;
+        return value;
+    }
+
+    readInt16() {
+
+        let value = this.dataView.getInt16(this.index, true);
+        this.index += 2;
+        return value;
+    }
+
+    readFloat32() {
+
+        let value = this.dataView.getFloat32(this.index, true);
+        this.index += 4;
+        return value;
+    }
+
+    readUint8() {
+
+
+        let value = this.dataView.getUint8(this.index);
+        this.index += 1;
+        return value;
+    }
+
+    readInt8() {
+
+
+        let value = this.dataView.getInt8(this.index);
+        this.index += 1;
+        return value;
+    }
+
+    readUint32() {
+
+        let value = this.dataView.getUint32(this.index, true);
+        this.index += 4;
+        return value;
+    }
+
+    readUint16() {
+
+        let value = this.dataView.getUint16(this.index, true);
+        this.index += 2;
+        return value;
+    }
+
+    readChar() {
+
+        if (this.index > this.buffer.byteLength - 1) return "-";
+        let value = String.fromCharCode(this.dataView.getUint8(this.index));
+        this.index += 1;
+        return value;
+    }
+
+    readString(length: number) {
+
+        let str = ""
+        for (let i = 0; i < length; i++) {
+            str += this.readChar()
+        }
+        return str;
+    }
+
+    readZeroTerminatedString() {
+
+        let returnString = "";
+
+        while (true)
+        {
+            let char = this.readChar();
+
+            if (char == "\0")
+            {
+                break;
+            }
+
+            returnString += char;
+        }
+
+        return returnString;
+
+    }
+
+    asString() {
+
+        let str = '';
+        for(let i = 0; i < this.buffer.byteLength; i++) {
+
+            str += this.readChar()
+
+        }
+
+        return str
+    }
+}

+ 132 - 0
src/webgl/assets/marmosets/parser/index.ts

@@ -0,0 +1,132 @@
+import BufferReader from './BufferReader'
+import { MviewAsset } from '../MviewFiles';
+
+
+class Parser {
+
+    constructor() {
+
+
+    }
+
+
+    parse( buffer: ArrayBuffer ) {
+
+        let br = new BufferReader(buffer);
+
+        let assets: Map<string, MviewAsset> = new Map(); 
+
+
+        for( ; br.getIndex() < br.getSize(); )
+        {
+
+            let name = br.readZeroTerminatedString();
+            let type  = br.readZeroTerminatedString();
+            
+            let flag = br.readUint32();
+            let comprressedSize = br.readUint32();
+            let size = br.readUint32();
+
+            let data = br.readBytes(comprressedSize)
+            let decompressData ;
+            if( flag & 1) {
+
+                decompressData = this.decompress(new Uint8Array(data), size);
+                
+            }
+           
+            assets.set(name, {name: name,
+                type : type as a,
+                flag: flag,
+                data: decompressData || data
+            })
+
+        }
+ 
+        return assets
+
+    }
+
+
+    parseSceneInfo( sceneData: MviewAsset ) {
+
+        let data;
+
+        try {
+
+            data = JSON.parse(new BufferReader(sceneData.data).asString())
+            
+        } catch (error) {
+            
+            throw(`读取场景信息出错:${error}`)
+
+        }
+
+        return data;
+
+    }
+
+
+    parseTexture( textureData: MviewAsset ) {
+
+
+    }
+
+
+    //解压压缩文件 (sky.dat)
+    private decompress  (a: Uint8Array, c: number ) {
+        var b = new Uint8Array(c)
+          , d = 0
+          , e = new Uint32Array(4096)
+          , f = new Uint32Array(4096)
+          , g = 256
+          , h = a.length
+          , k = 0
+          , n = 1
+          , m = 0
+          , l = 1;
+        b[d++] = a[0];
+        for (var p = 1; ; p++) {
+            l = p + (p >> 1);
+            if (l + 1 >= h)
+                break;
+            var m = a[l + 1]
+              , l = a[l]
+              , r = p & 1 ? m << 4 | l >> 4 : (m & 15) << 8 | l;
+            if (r < g)
+                if (256 > r)
+                    m = d,
+                    l = 1,
+                    b[d++] = r;
+                else
+                    for (var m = d, l = f[r], r = e[r], s = r + l; r < s; )
+                        b[d++] = b[r++];
+            else if (r == g) {
+                m = d;
+                l = n + 1;
+                r = k;
+                for (s = k + n; r < s; )
+                    b[d++] = b[r++];
+                b[d++] = b[k]
+            } else
+                break;
+            e[g] = k;
+            f[g++] = n + 1;
+            k = m;
+            n = l;
+            g = 4096 <= g ? 256 : g
+        }
+        return d == c ? b : null
+    }
+
+    
+}
+
+type a = 'sky.dat'|'image/jpeg'|'image/derp'|'model/mset'|'image/jpeg'|'application/json'
+export {
+
+    Parser
+
+}
+
+

+ 11 - 0
src/webgl/assets/marmosets/shaders/ShaderCache.ts

@@ -0,0 +1,11 @@
+export default class ShaderCache {
+
+    chunks: { }
+
+    constructor() {
+
+        this.chunks = {}
+
+    }
+
+}

+ 83 - 0
src/webgl/assets/marmosets/shaders/alphaprepass.ts

@@ -0,0 +1,83 @@
+import * as THREE from 'three'
+
+type AttributesDescription = {
+
+    vPosition:THREE.Vector3
+    
+    vTexCoord: THREE.Vector2
+
+}
+
+type VaryingDescription = {
+
+    d: THREE.Vector2
+
+}
+
+const uniforms = {
+
+    uModelViewProjectionMatrix: { value: new THREE.Matrix4 },
+
+    uUVOffset: { value: new THREE.Vector2 },
+
+
+}
+
+export default {
+
+    attributesDescription: undefined as AttributesDescription | undefined,
+
+    varyingDescription: undefined as VaryingDescription | undefined,
+
+    uniforms: uniforms,
+    
+    vetexShader: `
+    
+        precision highp float;
+
+        uniform mat4 uModelViewProjectionMatrix;
+        uniform vec2 uUVOffset;
+        
+        attribute vec3 vPosition;
+        attribute vec2 vTexCoord;
+        
+        varying mediump vec2 d;
+        
+        
+        vec4 mul(mat4 i,vec3 p)     //mulPoint
+        {
+            return i[0] * p.x + ( i[1] * p.y + ( i[2]*p.z + i[3]) );
+        }
+        
+        void main(void)
+        {
+            gl_Position= mul( uModelViewProjectionMatrix, vPosition.xyz);
+            d = vTexCoord + uUVOffset;
+        }
+    `,
+
+    fragmentShader: `
+    
+        precision mediump float;
+
+        #include <matdither.glsl>
+        
+        uniform sampler2D tAlbedo;
+        
+        varying mediump vec2 vUv;
+        
+        void main()
+        {
+            float albedo=texture2D(tAlbedo,vUv).a;
+            
+            if(albedo<=f(vUv.x))
+            {
+                discard;
+            }
+        
+            gl_FragColor=vec4(0.0);
+        }
+    
+    `
+
+}

+ 83 - 0
src/webgl/assets/marmosets/shaders/bloom.ts

@@ -0,0 +1,83 @@
+import * as THREE from 'three'
+
+type AttributesDescription = {
+
+    vPosition:THREE.Vector3
+    
+    vTexCoord: THREE.Vector2
+
+}
+
+type VaryingDescription = {
+
+    d: THREE.Vector2
+
+}
+
+const uniforms = {
+
+    uModelViewProjectionMatrix: { value: new THREE.Matrix4 },
+
+    uUVOffset: { value: new THREE.Vector2 },
+
+
+}
+
+export default {
+
+    attributesDescription: undefined as AttributesDescription | undefined,
+
+    varyingDescription: undefined as VaryingDescription | undefined,
+
+    uniforms: uniforms,
+    
+    vetexShader: `
+    
+        precision highp float;
+
+        uniform mat4 uModelViewProjectionMatrix;
+        uniform vec2 uUVOffset;
+        
+        attribute vec3 vPosition;
+        attribute vec2 vTexCoord;
+        
+        varying mediump vec2 d;
+        
+        
+        vec4 mul(mat4 i,vec3 p)     //mulPoint
+        {
+            return i[0] * p.x + ( i[1] * p.y + ( i[2]*p.z + i[3]) );
+        }
+        
+        void main(void)
+        {
+            gl_Position= mul( uModelViewProjectionMatrix, vPosition.xyz);
+            d = vTexCoord + uUVOffset;
+        }
+    `,
+
+    fragmentShader: `
+    
+        precision mediump float;
+
+        #include <matdither.glsl>
+        
+        uniform sampler2D tAlbedo;
+        
+        varying mediump vec2 vUv;
+        
+        void main()
+        {
+            float albedo=texture2D(tAlbedo,vUv).a;
+            
+            if(albedo<=f(vUv.x))
+            {
+                discard;
+            }
+        
+            gl_FragColor=vec4(0.0);
+        }
+    
+    `
+
+}

+ 19 - 0
src/webgl/assets/marmosets/shaders/chunks/alphaprepassfrag.glsl

@@ -0,0 +1,19 @@
+precision mediump float;
+
+#include <matdither.glsl>
+
+uniform sampler2D tAlbedo;
+
+varying mediump vec2 vUv;
+
+void main()
+{
+	float albedo=texture2D(tAlbedo,vUv).a;
+    
+	if(albedo<=f(vUv.x))
+    {
+        discard;
+    }
+
+	gl_FragColor=vec4(0.0);
+}

+ 21 - 0
src/webgl/assets/marmosets/shaders/chunks/alphaprepassvert.glsl

@@ -0,0 +1,21 @@
+precision highp float;
+
+uniform mat4 uModelViewProjectionMatrix;
+uniform vec2 uUVOffset;
+
+attribute vec3 vPosition;
+attribute vec2 vTexCoord;
+
+varying mediump vec2 d;
+
+
+vec4 mul(mat4 i,vec3 p)     //mulPoint
+{
+    return i[0] * p.x + ( i[1] * p.y + ( i[2]*p.z + i[3]) );
+}
+
+void main(void)
+{
+    gl_Position= mul( uModelViewProjectionMatrix, vPosition.xyz);
+    d = vTexCoord + uUVOffset;
+}

+ 26 - 0
src/webgl/assets/marmosets/shaders/chunks/blit.glsl

@@ -0,0 +1,26 @@
+precision highp float;
+
+varying vec2 c;
+attribute vec2 pos;
+
+void main(){ 
+    
+    gl_Position.xy = 2.0*pos-vec2(1.0);
+    gl_Position.zw = vec2(0.5,1.0);
+    
+    c=pos;
+}
+
+
+
+
+precision highp float;
+
+varying vec2 c;
+uniform sampler2D tTex;
+
+void main(){
+
+    gl_FragColor = texture2D(tTex,c).rgbr; 
+    
+}

+ 23 - 0
src/webgl/assets/marmosets/shaders/chunks/bloom.glsl

@@ -0,0 +1,23 @@
+precision mediump float;
+
+uniform sampler2D tInput;
+uniform vec4 uKernel[BLOOM_SAMPLES];
+
+varying highp vec2 j;
+
+
+void main(void)
+{
+    vec3 c=vec3(0.0,0.0,0.0);
+    
+    for(int k=0;k <BLOOM_SAMPLES;++k)
+    {
+        vec3 l=uKernel[k].xyz;
+        vec3 m=texture2D(tInput,j+l.xy).xyz;
+        m=max(m,vec3(0.0,0.0,0.0));
+        c+=m*l.z;
+    }
+    
+    gl_FragColor.xyz = c;
+    gl_FragColor.w = 0.0;
+}

+ 17 - 0
src/webgl/assets/marmosets/shaders/chunks/bloomshrink.glsl

@@ -0,0 +1,17 @@
+precision highp float;
+
+uniform sampler2D tInput;
+
+varying highp vec2 j;
+
+void main(void)
+{
+    float o=0.25/256.0;
+
+    gl_FragColor = 0.25 * (
+        texture2D(tInput,j+vec2(o,o))
+        +texture2D(tInput,j+vec2(o,-o))
+        +texture2D(tInput,j+vec2(-o,o))
+        +texture2D(tInput,j+vec2(-o,-o))
+    ); 
+}

+ 244 - 0
src/webgl/assets/marmosets/shaders/chunks/fogfrag.glsl

@@ -0,0 +1,244 @@
+precision highp float;
+
+uniform sampler2D tDepth;
+uniform vec3 uDepthToZ;
+uniform vec4 uUnproject;
+uniform mat4 uInvViewMatrix;
+uniform float uFogInvDistance;
+uniform float uFogOpacity;
+uniform float uFogDispersion;
+uniform vec3 uFogType;
+uniform vec3 uFogColor;
+uniform float uFogIllum;
+uniform mat4 uLightMatrix;
+
+#ifdef FOG_IBL
+    uniform vec4 uFogLightSphere[9];
+#else
+    uniform vec4 uSpotParams;
+    uniform vec4 uLightPosition;
+    uniform vec3 uLightColor;
+    uniform vec4 uLightAttenuation;
+    #ifdef FOG_SHADOWS
+    uniform mat4 uShadowProj;
+    uniform sampler2D uShadowMap;
+    uniform float uDitherOffset;
+    uniform vec4 uCylinder;
+    #endif
+#endif
+
+
+vec4 h(mat4 i,vec3 p)
+{
+    return i[0]*p.x+(i[1]*p.y+(i[2]*p.z+i[3]));
+}
+
+vec3 u(mat4 i,vec3 v)
+{
+    return i[0].xyz*v.x+i[1].xyz*v.y+i[2].xyz*v.z;
+}
+
+float A(float B)
+{
+    B*=uFogInvDistance;
+    float C=uFogType.x*min(B,1.0)+(uFogType.y-uFogType.y/(1.0+16.0*B*B))+(uFogType.z-uFogType.z*exp(-3.0*B));
+    return C*uFogOpacity;
+}
+
+#ifdef FOG_SHADOWS
+float D(vec3 E)
+{
+    vec4 p=h(uShadowProj,E);
+    vec3 F=p.xyz/p.w;
+    vec4 G=texture2D(uShadowMap,F.xy);
+    float H=(G.x+G.y*(1.0/255.0))+G.z*(1.0/65025.0);
+    return F.z<H || H>=1.0?1.0:0.0;
+}    
+float f(vec2 I)
+{
+    return fract(sin(dot(I,vec2(12.9898,78.233)))*43758.5453+uDitherOffset);
+}
+void J(vec3 K,vec3 L,out float M,out float N)
+{
+    vec3 v=uSpotParams.xyz,p=uCylinder.xyz;
+    vec3 O=L-dot(L,v)*v;
+    vec3 P=(K-p)-dot(K-p,v)*v;
+    float a=dot(O,O);
+    float b=2.0*dot(O,P);
+    float c=dot(P,P)-uCylinder.w;
+    float Q=b*b-4.0*a*c;
+    if(Q>=0.0)
+    {
+        Q=sqrt(Q);
+        M=(-b-Q)/(2.0*a);
+        N=(-b+Q)/(2.0*a);
+    }
+    else
+    {
+        M=N=0.0;
+    }
+}
+#endif
+
+
+varying vec2 j;
+void main(void)
+{
+    vec3 R=uInvViewMatrix[3].xyz;
+    float H=texture2D(tDepth,j).x;
+    H=min(H,0.9999);
+
+    vec3 S;
+    S.z=uDepthToZ.y/(uDepthToZ.z*H+uDepthToZ.x);
+    S.xy=S.z*(j*uUnproject.xy+uUnproject.zw);
+    S=h(uInvViewMatrix,S).xyz;
+    vec3 T;
+    T.xy=(j*uUnproject.xy+uUnproject.zw);
+    T.z=1.0;
+    T=normalize(u(uInvViewMatrix,-T).xyz);
+    vec3 U=uFogColor;
+
+    #if defined(FOG_IBL)
+    vec3 G=u(uLightMatrix,T);
+    vec3 V=uFogLightSphere[0].xyz;
+    V+=uFogLightSphere[1].xyz*G.y;
+    V+=uFogLightSphere[2].xyz*G.z;
+    V+=uFogLightSphere[3].xyz*G.x;
+    vec3 swz=G.yyz*G.xzx;
+    V+=uFogLightSphere[4].xyz*swz.x;
+    V+=uFogLightSphere[5].xyz*swz.y;
+    V+=uFogLightSphere[7].xyz*swz.z;
+    vec3 sqr=G*G;
+    V+=uFogLightSphere[6].xyz*(3.0*sqr.z-1.0);
+    V+=uFogLightSphere[8].xyz*(sqr.x-sqr.y);
+    U=mix(U,U*V,uFogIllum);
+    float C=A(length(S-R));
+    gl_FragColor.xyz=U*C;
+    gl_FragColor.w=C;
+    return;
+
+    #else
+        #if defined(FOG_SPOT) || defined(FOG_OMNI)
+        float W=0.0,X=0.0;
+        {
+            float r=1.0/(uLightAttenuation.z);
+            float a=1.0;
+            float b=2.0*dot(T,R-uLightPosition.xyz);
+            float c=dot(uLightPosition.xyz,uLightPosition.xyz)+dot(R,R)+-2.0*dot(uLightPosition.xyz,R)+-r*r;
+            float Q=b*b-4.0*a*c;
+
+            if(Q>=0.0)
+            {
+                Q=sqrt(Q);
+                W=(-b-Q)/(2.0*a);
+                X=(-b+Q)/(2.0*a);
+            }
+        }
+        #if defined(FOG_SPOT)
+        {
+            float Y=uSpotParams.w,Z=1.0-Y;
+            vec3 v=T;
+            vec3 dc=uSpotParams.xyz;
+            vec3 dd=R-uLightPosition.xyz;
+            vec3 de=v-dot(v,dc)*dc,df=dd-dot(dd,dc)*dc;
+            float a=Y*dot(de,de)-Z*dot(v,dc)*dot(v,dc);
+            float b=2.0*Y*dot(de,df)-2.0*Z*dot(v,dc)*dot(dd,dc);
+            float c=Y*dot(df,df)-Z*dot(dd,dc)*dot(dd,dc);
+            float Q=b*b-4.0*a*c;
+            if(Q>=0.0)
+            {
+                float dh=(-b-sqrt(Q))/(2.0*a);
+                float di=(-b+sqrt(Q))/(2.0*a);
+                if(di<dh)
+                {
+                    float de=dh;dh=di;di=de;
+                }
+                bool dj=dot(-uLightPosition.xyz+R+T*dh,uSpotParams.xyz)<=0.0;
+                bool dk=dot(-uLightPosition.xyz+R+T*di,uSpotParams.xyz)<=0.0;
+                if(!dj ||!dk)
+                {
+                    if(dj)
+                    {
+                        dh=di;di=X;
+                    }
+                    else if(dk)
+                    {
+                        di=dh;dh=W;
+                    }
+                    W=max(W,dh);
+                    X=min(X,di);
+                }
+                else
+                {
+                    X=W=0.0;
+                }
+            }
+            else
+            {
+                X=W=0.0;
+            }
+        }
+        #endif
+
+        float tx=dot(T,S-R);
+        W=clamp(W,0.0,tx);
+        X=clamp(X,0.0,tx);
+        float dl=0.0;
+
+        if(X>W)
+        {
+            #ifdef FOG_SHADOWS
+                #ifdef MOBILE
+                    #define SAMPLES 16
+                #else
+                    #define SAMPLES 32
+                #endif
+                float dm=f(j)*(X-W)/float(SAMPLES-2);
+            #else
+                #define SAMPLES 8
+                float dm=0.0;
+            #endif
+            
+            for(int k=0;k<SAMPLES;++k)
+            {
+                float t=W+(X-W)*float(k)/float(SAMPLES-1);
+                vec3 p=R+(t+dm)*T;
+                float a=clamp(length(p-uLightPosition.xyz)*uLightAttenuation.z,0.0,1.0);
+                a=1.0+uLightAttenuation.x*a+uLightAttenuation.y*a*a;
+
+                #ifdef FOG_SHADOWS
+                    a*=D(p);
+                #endif
+
+                dl+=a-a*A(t);
+            }
+            
+            dl*=1.0/float(SAMPLES);
+            dl*=(X-W)*uLightAttenuation.z;
+            dl*=A(X-W);
+        }
+        
+        U*=dl*uFogIllum;
+        
+    #elif defined(FOG_DIR)
+        float C=A(dot(T,S-R));
+        #ifdef FOG_SHADOWS
+            float W,X;
+            J(R,T,W,X);
+            float tx=dot(T,S-R);
+            W=clamp(W,0.0,tx);
+            X=clamp(X,0.0,tx);
+            if(X>W){
+
+            #ifdef MOBILE
+                #define SAMPLES 16
+            #else
+                #define SAMPLES 32
+            #endif
+            float dl=0.0;float dm=f(j)*(X-W)/float(SAMPLES-2);float dn=(X-W)*(1.0/float(SAMPLES));for(int k=0;k<SAMPLES;++k){float t=W+float(k)*dn+dm;vec3 p=R+t*T;float s=D(p);C-=(1.0-s)*(A(t+dn)-A(t));}}
+            #endif
+            float du=0.5+0.5*dot(T,-uSpotParams.xyz);du=1.0+uFogDispersion*(2.0*du*du-1.0);U*=(0.1*C)*(du*uFogIllum);
+        #endif
+        gl_FragColor.xyz=U*uLightColor;gl_FragColor.w=0.0;
+    #endif
+}

+ 12 - 0
src/webgl/assets/marmosets/shaders/chunks/fogvert.glsl

@@ -0,0 +1,12 @@
+precision highp float;
+
+attribute vec2 vCoord;
+
+varying vec2 j;
+
+void main(void)
+{
+    j=vCoord;
+    gl_Position.xy=2.0*vCoord-vec2(1.0,1.0);
+    gl_Position.zw=vec2(0.0,1.0);
+}

+ 5 - 0
src/webgl/assets/marmosets/shaders/chunks/matdither.glsl

@@ -0,0 +1,5 @@
+float f(highp float I)
+{
+    highp float G=0.5*fract(gl_FragCoord.x*0.5)+0.5*fract(gl_FragCoord.y*0.5);
+    return 0.4+0.6*fract(G+3.141592e6*I);
+}

+ 352 - 0
src/webgl/assets/marmosets/shaders/chunks/matfrag.glsl

@@ -0,0 +1,352 @@
+#extension GL_OES_standard_derivatives : enable
+precision mediump float;
+
+
+varying highp vec3 dv;
+varying mediump vec2 d;
+varying mediump vec3 dA;
+varying mediump vec3 dB;
+varying mediump vec3 dC;
+
+#ifdef VERTEX_COLOR
+varying lowp vec4 dD;
+#endif
+
+#ifdef TEXCOORD_SECONDARY
+varying mediump vec2 dE;
+#endif
+
+uniform sampler2D tAlbedo;
+uniform sampler2D tReflectivity;
+uniform sampler2D tNormal;
+uniform sampler2D tExtras;
+uniform sampler2D tSkySpecular;
+
+#ifdef REFRACTION
+uniform sampler2D tRefraction;
+#endif
+
+uniform vec4 uDiffuseCoefficients[9];
+uniform vec3 uCameraPosition;
+uniform float uAlphaTest;
+uniform vec3 uFresnel;
+uniform float uHorizonOcclude;
+uniform float uHorizonSmoothing;
+
+#ifdef EMISSIVE
+uniform float uEmissiveScale;
+uniform vec4 uTexRangeEmissive;
+#endif
+
+#ifdef AMBIENT_OCCLUSION
+uniform vec4 uTexRangeAO;
+#endif
+
+#ifdef REFRACTION
+uniform float uRefractionIOREntry;
+uniform float uRefractionRayDistance;
+uniform vec3 uRefractionTint;
+uniform float uRefractionAlbedoTint;
+uniform mat4 uRefractionViewProjection;
+uniform vec4 uTexRangeRefraction;
+#endif
+
+#ifdef LIGHT_COUNT
+uniform vec4 uLightPositions[LIGHT_COUNT];
+uniform vec3 uLightDirections[LIGHT_COUNT];
+uniform vec3 uLightColors[LIGHT_COUNT];
+uniform vec3 uLightParams[LIGHT_COUNT];
+uniform vec3 uLightSpot[LIGHT_COUNT];
+#endif
+
+#ifdef ANISO
+uniform float uAnisoStrength;
+uniform vec3 uAnisoTangent;
+uniform float uAnisoIntegral;
+uniform vec4 uTexRangeAniso;
+#endif
+
+#define saturate(x) clamp( x, 0.0, 1.0 )
+
+#include <matsampling.glsl>
+#include <matlighting.glsl>
+#include <matshadows.glsl>
+#include <matskin.glsl>
+#include <matmicrofiber.glsl>
+#include <matstrips.glsl>
+
+#ifdef TRANSPARENCY_DITHER
+    #include <matdither.glsl>
+#endif
+
+void main(void)
+{
+    vec4 m=texture2D(tAlbedo,d);
+    vec3 dF=dG(m.xyz);
+    float e=m.w;
+
+    //顶点颜色
+    #ifdef VERTEX_COLOR 
+    {
+        vec3 dH=dD.xyz;
+        
+        #ifdef VERTEX_COLOR_SRGB
+        dH=dH*(dH*(dH*0.305306011+vec3(0.682171111))+vec3(0.012522878));        //Gamma 校正
+        #endif
+
+        dF*=dH;
+
+        #ifdef VERTEX_COLOR_ALPHA
+        e*=dD.w;
+        #endif
+    }
+    #endif
+
+    //AlphaTest
+    #ifdef ALPHA_TEST
+    if(e<uAlphaTest)
+    {
+        discard;
+    }
+    #endif
+
+    //透明抖动
+    #ifdef TRANSPARENCY_DITHER
+    e=(e>f(d.x))?1.0:e;
+    #endif
+
+    vec3 dI=dJ(texture2D(tNormal,d).xyz);
+
+    //各向异性
+    #ifdef ANISO
+        #ifdef ANISO_NO_DIR_TEX
+            vec3 dK=dL(uAnisoTangent);
+        #else
+            m=dM(d,uTexRangeAniso);
+            vec3 dK=2.0*m.xyz-vec3(1.0);
+            dK=dL(dK);
+        #endif
+        dK=dK-dI*dot(dK,dI);
+        dK=normalize(dK);
+        vec3 dN=dK*uAnisoStrength;
+    #endif
+
+    vec3 dO=normalize(uCameraPosition-dv);
+    m=texture2D(tReflectivity,d);
+    vec3 dP=dG(m.xyz);
+    float dQ=m.w;
+    float dR=dQ;
+
+
+    #ifdef HORIZON_SMOOTHING
+    float dS=dot(dO,dI);dS=uHorizonSmoothing-dS*uHorizonSmoothing;dQ=mix(dQ,1.0,dS*dS);
+    #endif
+
+    #ifdef STRIPVIEW
+    dT dU;dV(dU,dQ,dP);
+    #endif
+    
+    float dW=1.0;
+
+    //环境光遮蔽
+    #ifdef AMBIENT_OCCLUSION
+    
+        #ifdef AMBIENT_OCCLUSION_SECONDARY_UV
+        dW=dM(dE,uTexRangeAO).x;
+        #else
+        dW=dM(d,uTexRangeAO).x;
+        #endif
+
+    dW*=dW;
+    #endif
+
+    //皮肤渲染
+    #if defined(SKIN)
+    dX dY;
+    dZ(dY);
+    dY.ec*=dW;
+    #elif defined(MICROFIBER)
+    ed ee;ef(ee,dI);ee.eh*=dW;
+    #else
+    vec3 ei=ej(dI);ei*=dW;
+    #endif
+
+    vec3 ek=reflect(-dO,dI);
+    
+    
+    #ifdef ANISO
+    vec3 rt=ek-(0.5*dN*dot(ek,dK));vec3 el=em(rt,mix(dQ,0.5*dQ,uAnisoStrength));
+    #else
+    vec3 el=em(ek,dQ);
+    #endif
+
+    el*=en(ek,dC);
+
+    #ifdef LIGHT_COUNT
+    highp float eo=10.0/log2(dQ*0.968+0.03);
+    eo*=eo;
+    float eu=eo*(1.0/(8.0*3.1415926))+(4.0/(8.0*3.1415926));
+    eu=min(eu,1.0e3);
+
+        #ifdef SHADOW_COUNT
+        ev eA;
+        
+            #ifdef SKIN
+
+                #ifdef SKIN_VERSION_1
+                eB(eA,SHADOW_KERNEL+SHADOW_KERNEL*dY.eC);
+                #else
+                eD eE;
+                float eF=SHADOW_KERNEL+SHADOW_KERNEL*dY.eC;
+                eG(eE,eF);
+                eB(eA,eF);
+                #endif
+
+            #else
+            eB(eA,SHADOW_KERNEL);
+            #endif
+
+        #endif
+
+        #ifdef ANISO
+        eu*=uAnisoIntegral;
+        #endif
+
+    for(int k=0;k<LIGHT_COUNT;++k)
+    {
+        vec3 eH=uLightPositions[k].xyz-dv*uLightPositions[k].w;
+        
+        float eI=inversesqrt(dot(eH,eH));
+        eH*=eI;
+        float a=saturate(uLightParams[k].z/eI);
+        a=1.0+a*(uLightParams[k].x+uLightParams[k].y*a);
+        float s=saturate(dot(eH,uLightDirections[k]));
+        s=saturate(uLightSpot[k].y-uLightSpot[k].z*(1.0-s*s));
+        vec3 eJ=(a*s)*uLightColors[k].xyz;
+
+        #if defined(SKIN)
+            
+            #ifdef SHADOW_COUNT
+                
+                #ifdef SKIN_VERSION_1
+                eK(dY,eA.eL[k],1.0,eH,dI,eJ);
+                #else
+                eK(dY,eA.eL[k],eE.eE[k],eH,dI,eJ);
+                #endif
+
+            #else
+            eK(dY,1.0,0.0,eH,dI,eJ);
+            #endif
+
+        #elif defined(MICROFIBER)
+                
+            #ifdef SHADOW_COUNT
+            eM(ee,eA.eL[k],eH,dI,eJ);
+            #else
+            eM(ee,1.0,eH,dI,eJ);    
+            #endif
+            
+        #else
+        float eN=saturate((1.0/3.1415926)*dot(eH,dI));      
+            
+            #ifdef SHADOW_COUNT
+            eN*=eA.eL[k];
+            #endif
+
+        ei+=eN*eJ;
+        #endif
+
+        vec3 eO=eH+dO;
+
+        #ifdef ANISO
+        eO=eO-(dN*dot(eO,dK));
+        #endif
+
+        eO=normalize(eO);
+        float eP=eu*pow(saturate(dot(eO,dI)),eo);
+        
+        #ifdef SHADOW_COUNT
+        eP*=eA.eL[k];
+        #endif
+
+        el+=eP*eJ;
+    }
+    #endif
+
+    #if defined(SKIN)
+    vec3 ei,diff_extra;
+    eQ(ei,diff_extra,dY,dO,dI,dQ);
+    #elif defined(MICROFIBER)
+    vec3 ei,diff_extra;eR(ei,diff_extra,ee,dO,dI,dQ);
+    #endif
+
+    vec3 eS=eT(dO,dI,dP,dQ*dQ);
+    el*=eS;
+    
+
+    //折射
+    #ifdef REFRACTION
+    vec4 eU;
+    {
+        vec3 G=refract(-dO,dI,uRefractionIOREntry);
+        G=dv+G*uRefractionRayDistance;
+        vec4 eV=uRefractionViewProjection[0]*G.x+(uRefractionViewProjection[1]*G.y+(uRefractionViewProjection[2]*G.z+uRefractionViewProjection[3]));
+        vec2 c=eV.xy/eV.w;
+        c=0.5*c+vec2(0.5,0.5);
+        vec2 i=mod(floor(c),2.0);
+        c=fract(c);
+        c.x=i.x>0.0?1.0-c.x:c.x;
+        c.y=i.y>0.0?1.0-c.y:c.y;
+        eU.rgb=texture2D(tRefraction,c).xyz;
+        eU.rgb=mix(eU.rgb,eU.rgb*dF,uRefractionAlbedoTint);
+        eU.rgb=eU.rgb-eU.rgb*eS;
+        eU.rgb*=uRefractionTint;
+
+        #ifdef REFRACTION_NO_MASK_TEX
+        eU.a=1.0;
+        #else
+        eU.a=dM(d,uTexRangeRefraction).x;
+        #endif
+    }
+    #endif
+    
+    #ifdef DIFFUSE_UNLIT
+    gl_FragColor.xyz=dF;
+    #else
+    gl_FragColor.xyz=ei*dF;
+    #endif
+
+    #ifdef REFRACTION
+    gl_FragColor.xyz=mix(gl_FragColor.xyz,eU.rgb,eU.a);
+    #endif
+
+    gl_FragColor.xyz+=el;
+
+    #if defined(SKIN) || defined(MICROFIBER)
+    gl_FragColor.xyz+=diff_extra;
+    #endif
+    
+    //自发光
+    #ifdef EMISSIVE
+
+        #ifdef EMISSIVE_SECONDARY_UV
+        vec2 eW=dE;
+        #else
+        vec2 eW=d;
+        #endif
+    
+    gl_FragColor.xyz+=uEmissiveScale*dG(dM(eW,uTexRangeEmissive).xyz);
+    #endif
+
+    //网格
+    #ifdef STRIPVIEW
+    gl_FragColor.xyz=eX(dU,dI,dF,dP,dR,ei,el,gl_FragColor.xyz);
+    #endif
+
+    #ifdef NOBLEND
+    gl_FragColor.w=1.0;
+    #else
+    gl_FragColor.w=e;
+    #endif
+
+}

+ 146 - 0
src/webgl/assets/marmosets/shaders/chunks/matlighting.glsl

@@ -0,0 +1,146 @@
+vec3 eY(vec3 eZ,float fc)
+{
+    return exp(-0.5*fc/(eZ*eZ))/(eZ*2.5066283);
+}
+
+vec3 fd(vec3 eZ)
+{
+    return vec3(1.0,1.0,1.0)/(eZ*2.5066283);
+}
+
+vec3 fe(vec3 ff)
+{
+    return vec3(-0.5,-0.5,-0.5)/(ff);
+}
+
+vec3 fh(vec3 fi,float fc)
+{
+    return exp(fi*fc);
+}
+
+#define SAMPLE_COUNT 21.0
+#define SAMPLE_HALF 10.0
+#define GAUSS_SPREAD 0.05
+
+vec3 fj(float fk,float fl,vec3 fm)
+{
+    vec3 fn=vec3(fl,fl,fl);
+    fn=0.8*fn+vec3(0.2);
+    vec3 fo=cos(fn*3.14159);
+    vec3 fu=cos(fn*3.14159*0.5);
+    fu*=fu;
+    fu*=fu;
+    fu*=fu;
+    fn=fn+0.05*fo*fu*fm;
+    fu*=fu;
+    fu*=fu;
+    fu*=fu;
+    fn=fn+0.1*fo*fu*fm;
+    fn=saturate(fn);
+    fn*=fn*1.2;
+    return fn;
+}
+
+vec3 fv(vec3 fm)
+{
+    return vec3(1.0,1.0,1.0)/3.1415926;
+}
+
+float fA(float fk,float fm)
+{
+    return saturate(-fk*fm+fk+fm);
+}
+
+vec3 fB(float fk,vec3 fm)
+{
+    return saturate(-fk*fm+vec3(fk)+fm);
+}
+
+float fC(float fm)
+{
+    return-0.31830988618379*fm+0.31830988618379;
+}
+
+vec3 fD(vec3 fm)
+{
+    return-0.31830988618379*fm+vec3(0.31830988618379);
+}
+
+vec3 eT(vec3 dO,vec3 dI,vec3 dP,float fE)
+{
+    float C=1.0-saturate(dot(dO,dI));
+    float fF=C*C;
+    C*=fF*fF;
+    C*=fE;
+    return(dP-C*dP)+C*uFresnel;
+}
+
+vec2 fG(vec2 fH,vec2 fm)
+{
+    fH=1.0-fH;
+    vec2 fI=fH*fH;
+    fI*=fI;
+    fH=mix(fI,fH*0.4,fm);
+    return fH;
+}
+
+vec3 ej(vec3 fJ)
+{
+    #define c(n) uDiffuseCoefficients[n].xyz
+    vec3 G=(c(0)+fJ.y*((c(1)+c(4)*fJ.x)+c(5)*fJ.z))+fJ.x*(c(3)+c(7)*fJ.z)+c(2)*fJ.z;
+    #undef c
+    vec3 sqr=fJ*fJ;
+    G+=uDiffuseCoefficients[6].xyz*(3.0*sqr.z-1.0);
+    G+=uDiffuseCoefficients[8].xyz*(sqr.x-sqr.y);
+    return G;
+}
+
+void fK(inout vec3 fL,inout vec3 fM,inout vec3 fN,vec3 fJ)
+{
+    fL=uDiffuseCoefficients[0].xyz;
+    fM=uDiffuseCoefficients[1].xyz*fJ.y;
+    fM+=uDiffuseCoefficients[2].xyz*fJ.z;
+    fM+=uDiffuseCoefficients[3].xyz*fJ.x;
+    vec3 swz=fJ.yyz*fJ.xzx;
+    fN=uDiffuseCoefficients[4].xyz*swz.x;
+    fN+=uDiffuseCoefficients[5].xyz*swz.y;
+    fN+=uDiffuseCoefficients[7].xyz*swz.z;
+    vec3 sqr=fJ*fJ;
+    fN+=uDiffuseCoefficients[6].xyz*(3.0*sqr.z-1.0);
+    fN+=uDiffuseCoefficients[8].xyz*(sqr.x-sqr.y);
+}
+
+vec3 fO(vec3 fL,vec3 fM,vec3 fN,vec3 fP,float fm)
+{
+    fP=mix(vec3(1.0),fP,fm);
+    return(fL+fM*fP.x)+fN*fP.z;
+}
+
+vec3 fQ(vec3 fL,vec3 fM,vec3 fN,vec3 fP,vec3 fR)
+{
+    vec3 fS=mix(vec3(1.0),fP.yyy,fR);
+    vec3 fT=mix(vec3(1.0),fP.zzz,fR);
+    return(fL+fM*fS)+fN*fT;
+}
+
+vec3 em(vec3 fJ,float dQ)
+{
+    fJ/=dot(vec3(1.0),abs(fJ));
+    vec2 fU=abs(fJ.zx)-vec2(1.0,1.0);
+    vec2 fV=vec2(fJ.x<0.0?fU.x:-fU.x,fJ.z<0.0?fU.y:-fU.y);
+    vec2 fW=(fJ.y<0.0)?fV:fJ.xz;
+    fW=vec2(0.5*(254.0/256.0),0.125*0.5*(254.0/256.0))*fW+vec2(0.5,0.125*0.5);
+    float fX=fract(7.0*dQ);
+    fW.y+=0.125*(7.0*dQ-fX);
+    vec2 fY=fW+vec2(0.0,0.125);
+    vec4 fZ=mix(texture2D(tSkySpecular,fW),texture2D(tSkySpecular,fY),fX);
+    vec3 r=fZ.xyz*(7.0*fZ.w);
+    return r*r;
+}
+    
+float en(vec3 fJ,vec3 hc)
+{
+    float hd=dot(fJ,hc);
+    hd=saturate(1.0+uHorizonOcclude*hd);
+    return hd*hd;
+}

+ 60 - 0
src/webgl/assets/marmosets/shaders/chunks/matmicrofiber.glsl

@@ -0,0 +1,60 @@
+#ifdef MICROFIBER
+uniform vec4 uTexRangeFuzz;
+uniform vec4 uFresnelColor;
+uniform float uFresnelIntegral;
+uniform float uFresnelOcc;
+uniform float uFresnelGlossMask;
+
+struct ed
+{
+    vec3 eh;
+    vec3 eN;
+    vec3 he;
+    vec3 hf;
+    vec3 hh;
+};
+
+void ef(out ed s,vec3 dI)
+{
+    s.eh=s.eN=ej(dI);
+    s.he=vec3(0.0);
+    s.hf=uFresnelColor.rgb;
+    s.hh=uFresnelColor.aaa*vec3(1.0,0.5,0.25);
+
+    #ifndef MICROFIBER_NO_FUZZ_TEX
+    vec4 m=dM(d,uTexRangeFuzz);
+    s.hf*=dG(m.rgb);
+    #endif
+
+}
+
+void eM(inout ed s,float hi,vec3 eH,vec3 dI,vec3 eJ)
+{
+    float fk=dot(eH,dI);
+    float eN=saturate((1.0/3.1415926)*fk);
+    float hj=fA(fk,s.hh.z);
+
+    #ifdef SHADOW_COUNT
+    eN*=hi;
+    float hk=mix(1.0,hi,uFresnelOcc);
+    float he=hj*hk;
+    #else 
+    float he=hj;
+    #endif
+    
+    s.he=he*eJ+s.he;s.eN=eN*eJ+s.eN;
+}
+
+void eR(out vec3 ei,out vec3 diff_extra,inout ed s,vec3 dO,vec3 dI,float dQ)
+{
+    s.he*=uFresnelIntegral;
+    float fH=dot(dO,dI);
+    vec2 hl=fG(vec2(fH,fH),s.hh.xy);
+    s.he=s.eh*hl.x+(s.he*hl.y);
+    s.he*=s.hf;
+    float hm=saturate(1.0+-uFresnelGlossMask*dQ);
+    s.he*=hm*hm;
+    ei=s.eN;
+    diff_extra=s.he;
+}
+#endif

+ 61 - 0
src/webgl/assets/marmosets/shaders/chunks/matsampling.glsl

@@ -0,0 +1,61 @@
+vec3 dG(vec3 c)
+{
+    return c*c;
+}
+
+vec3 dJ(vec3 n)
+{
+    vec3 hn=dA;
+    vec3 ho=dB;
+    vec3 hu=gl_FrontFacing?dC:-dC;
+
+    #ifdef TSPACE_RENORMALIZE
+    hu=normalize(hu);
+    #endif
+
+    #ifdef TSPACE_ORTHOGONALIZE
+    hn-=dot(hn,hu)*hu;
+    #endif
+
+    #ifdef TSPACE_RENORMALIZE
+    hn=normalize(hn);
+    #endif
+
+    #ifdef TSPACE_ORTHOGONALIZE
+    ho=(ho-dot(ho,hu)*hu)-dot(ho,hn)*hn;
+    #endif
+
+    #ifdef TSPACE_RENORMALIZE
+    ho=normalize(ho);
+    #endif
+
+    #ifdef TSPACE_COMPUTE_BITANGENT
+    vec3 hv=cross(hu,hn);ho=dot(hv,ho)<0.0?-hv:hv;
+    #endif
+
+    n=2.0*n-vec3(1.0);
+    
+    return normalize(hn*n.x+ho*n.y+hu*n.z);
+}
+
+vec3 dL(vec3 t)
+{
+    vec3 hu=gl_FrontFacing?dC:-dC;
+    return normalize(dA*t.x+dB*t.y+hu*t.z);
+}
+
+vec4 dM(vec2 hA,vec4 hB){
+
+    #if GL_OES_standard_derivatives
+    vec2 hC=fract(hA);vec2 hD=fwidth(hC);float hE=(hD.x+hD.y)>0.5?-6.0:0.0;
+    return texture2D(tExtras,hC*hB.xy+hB.zw,hE);
+    #else
+    return texture2D(tExtras,fract(hA)*hB.xy+hB.zw);
+    #endif
+}
+
+vec3 hF(sampler2D hG,vec2 hH,float hI)
+{
+    vec3 n=texture2D(hG,hH,hI*2.5).xyz;
+    return dJ(n);
+}

+ 200 - 0
src/webgl/assets/marmosets/shaders/chunks/matshadows.glsl

@@ -0,0 +1,200 @@
+#ifdef SHADOW_COUNT
+    
+    #ifdef MOBILE
+        #define SHADOW_KERNEL (4.0/1536.0)
+    #else
+        #define SHADOW_KERNEL (4.0/2048.0)
+    #endif
+
+    highp vec4 h(highp mat4 i,highp vec3 p)
+    {
+        return i[0]*p.x+(i[1]*p.y+(i[2]*p.z+i[3]));
+    }
+
+    uniform sampler2D tDepth0;
+
+    #if SHADOW_COUNT > 1
+    uniform sampler2D tDepth1;
+
+        #if SHADOW_COUNT > 2
+        uniform sampler2D tDepth2;
+        #endif
+
+    #endif
+
+    uniform highp vec2 uShadowKernelRotation;
+    uniform highp vec2 uShadowMapSize;
+    uniform highp mat4 uShadowMatrices[SHADOW_COUNT];
+    uniform highp vec4 uShadowTexelPadProjections[SHADOW_COUNT];
+
+    #ifndef MOBILE
+    uniform highp mat4 uInvShadowMatrices[SHADOW_COUNT];
+    #endif
+
+    highp float hJ(highp vec3 G)
+    {
+        #ifdef SHADOW_NATIVE_DEPTH
+            return G.x;
+        #else
+            return(G.x+G.y*(1.0/255.0))+G.z*(1.0/65025.0);
+        #endif
+    }
+
+    #ifndef SHADOW_COMPARE
+        #define SHADOW_COMPARE(a,b) ((a) < (b) ? 1.0 : 0.0)
+    #endif
+
+    #ifndef SHADOW_CLIP
+        #define SHADOW_CLIP(c,v) v
+    #endif
+
+    float hK(sampler2D hL,highp vec2 hA,highp float H)
+    {
+        #ifndef MOBILE
+        highp vec2 c=hA*uShadowMapSize.x;highp vec2 a=floor(c)*uShadowMapSize.y,b=ceil(c)*uShadowMapSize.y;highp vec4 eE;eE.x=hJ(texture2D(hL,a).xyz);eE.y=hJ(texture2D(hL,vec2(b.x,a.y)).xyz);eE.z=hJ(texture2D(hL,vec2(a.x,b.y)).xyz);eE.w=hJ(texture2D(hL,b).xyz);highp vec4 hM;hM.x=SHADOW_COMPARE(H,eE.x);hM.y=SHADOW_COMPARE(H,eE.y);hM.z=SHADOW_COMPARE(H,eE.z);hM.w=SHADOW_COMPARE(H,eE.w);highp vec2 w=c-a*uShadowMapSize.x;vec2 s=(w.y*hM.zw+hM.xy)-w.y*hM.xy;return(w.x*s.y+s.x)-w.x*s.x;
+        #else
+        highp float G=hJ(texture2D(hL,hA.xy).xyz);return SHADOW_COMPARE(H,G);
+        #endif
+    }
+
+    highp float hN(sampler2D hL,highp vec3 hA,float hO)
+    {
+        highp vec2 l=uShadowKernelRotation*hO;
+        float s;
+        s=hK(hL,hA.xy+l,hA.z);
+        s+=hK(hL,hA.xy-l,hA.z);
+        s+=hK(hL,hA.xy+vec2(-l.y,l.x),hA.z);
+        s+=hK(hL,hA.xy+vec2(l.y,-l.x),hA.z);
+        s*=0.25;
+        return s*s;
+    }
+
+    struct ev{
+        float eL[LIGHT_COUNT];
+    };
+
+    void eB(out ev ss,float hO)
+    {
+        highp vec3 hP[SHADOW_COUNT];
+        vec3 hu=gl_FrontFacing?dC:-dC;
+        for(int k=0;k<SHADOW_COUNT;++k)
+        {
+            vec4 hQ=uShadowTexelPadProjections[k];
+            float hR=hQ.x*dv.x+(hQ.y*dv.y+(hQ.z*dv.z+hQ.w));
+
+            #ifdef MOBILE
+            hR*=.001+hO;
+            #else
+            hR*=.0005+0.5*hO;
+            #endif
+
+            highp vec4 hS=h(uShadowMatrices[k],dv+hR*hu);
+            hP[k]=hS.xyz/hS.w;
+        }
+        
+        float m;
+        
+        #if SHADOW_COUNT > 0
+        m=hN(tDepth0,hP[0],hO);
+        ss.eL[0]=SHADOW_CLIP(hP[0].xy,m);
+        #endif
+
+        #if SHADOW_COUNT > 1
+        m=hN(tDepth1,hP[1],hO);
+        ss.eL[1]=SHADOW_CLIP(hP[1].xy,m);
+        #endif
+
+        #if SHADOW_COUNT > 2
+        m=hN(tDepth2,hP[2],hO);
+        ss.eL[2]=SHADOW_CLIP(hP[2].xy,m);
+        #endif
+
+        for(int k=SHADOW_COUNT;k<LIGHT_COUNT;++k)
+        {
+            ss.eL[k]=1.0;
+        }
+    }
+
+    struct eD{
+        highp float eE[LIGHT_COUNT];
+    };
+
+
+    #ifdef MOBILE
+    void eG(out eD ss,float hO)
+    {
+        for(int k=0;k<LIGHT_COUNT;++k)
+        {
+            ss.eE[k]=1.0;
+        }
+    }
+    #else
+    highp vec4 hT(sampler2D hL,highp vec2 hA,highp mat4 hU)
+    {
+        highp vec4 E;
+        E.xy=hA;
+        
+        #ifndef MOBILE
+        highp vec2 c=hA*uShadowMapSize.x;
+        highp vec2 a=floor(c)*uShadowMapSize.y,b=ceil(c)*uShadowMapSize.y;
+        highp vec4 hM;
+        hM.x=hJ(texture2D(hL,a).xyz);
+        hM.y=hJ(texture2D(hL,vec2(b.x,a.y)).xyz);
+        hM.z=hJ(texture2D(hL,vec2(a.x,b.y)).xyz);
+        hM.w=hJ(texture2D(hL,b).xyz);
+        highp vec2 w=c-a*uShadowMapSize.x;
+        vec2 s=(w.y*hM.zw+hM.xy)-w.y*hM.xy;
+        E.z=(w.x*s.y+s.x)-w.x*s.x;
+        #else 
+        E.z=hJ(texture2D(hL,hA.xy).xyz);
+        #endif
+
+        E=h(hU,E.xyz);
+        E.xyz/=E.w;
+        return E;
+    }
+
+    void eG(out eD ss,float hO)
+    {
+        highp vec3 hV[SHADOW_COUNT];
+        vec3 hu=gl_FrontFacing?dC:-dC;
+        hu*=0.6;
+        for(int k=0;k<SHADOW_COUNT;++k)
+        {
+            vec4 hQ=uShadowTexelPadProjections[k];
+            float hR=hQ.x*dv.x+(hQ.y*dv.y+(hQ.z*dv.z+hQ.w));
+
+            #ifdef MOBILE
+            hR*=.001+hO;
+            #else
+            hR*=.0005+0.5*hO;
+            #endif
+
+            highp vec4 hS=h(uShadowMatrices[k],dv-hR*hu);
+            hV[k]=hS.xyz/hS.w;
+        }
+        
+        highp vec4 hW;
+
+        #if SHADOW_COUNT > 0
+        hW=hT(tDepth0,hV[0].xy,uInvShadowMatrices[0]);
+        ss.eE[0]=length(dv.xyz-hW.xyz);
+        #endif
+
+        #if SHADOW_COUNT > 1
+        hW=hT(tDepth1,hV[1].xy,uInvShadowMatrices[1]);
+        ss.eE[1]=length(dv.xyz-hW.xyz);
+        #endif
+
+        #if SHADOW_COUNT > 2
+        hW=hT(tDepth2,hV[2].xy,uInvShadowMatrices[2]);
+        ss.eE[2]=length(dv.xyz-hW.xyz);
+        #endif
+        
+        for(int k=SHADOW_COUNT;k<LIGHT_COUNT;++k)
+        {
+            ss.eE[k]=1.0;
+        }
+    }
+    #endif
+#endif

+ 218 - 0
src/webgl/assets/marmosets/shaders/chunks/matskin.glsl

@@ -0,0 +1,218 @@
+#ifdef SKIN
+
+    #ifndef SKIN_NO_SUBDERMIS_TEX
+    uniform vec4 uTexRangeSubdermis;  
+
+    #endif
+
+    #ifndef SKIN_NO_TRANSLUCENCY_TEX
+    uniform vec4 uTexRangeTranslucency;  
+
+    #endif
+
+    #ifndef SKIN_NO_FUZZ_TEX
+    uniform vec4 uTexRangeFuzz;  
+
+    #endif
+
+    uniform vec4 uTransColor;  
+    uniform vec4 uFresnelColor;  
+    uniform vec3 uSubdermisColor;  
+    uniform float uTransScatter;  
+    uniform float uFresnelOcc;  
+    uniform float uFresnelGlossMask;  
+    uniform float uTransSky;  
+    uniform float uFresnelIntegral;  
+    uniform float uTransIntegral;  
+    uniform float uSkinTransDepth;  
+    uniform float uSkinShadowBlur;  
+    uniform float uNormalSmooth;  
+
+    struct dX 
+    {
+        vec3 hX;  
+        vec3 hY,hZ,ic,he;  
+        vec3 ec,eh,id;  
+        vec3 ie;  
+        vec3 ih;  
+        vec3 ii;  
+        vec3 ij;  
+        float ik;  
+        float il;  
+        float im;  
+        float eC;  
+    }
+;  
+
+    void dZ(out dX s) 
+    {
+        vec4 m;  
+
+        #ifdef SKIN_NO_SUBDERMIS_TEX
+        s.hX=uSubdermisColor;  
+        s.im=1.0;  
+        #else 
+        m=dM(d,uTexRangeSubdermis);  
+        s.hX=dG(m.xyz);  
+        s.im=m.w*m.w;  
+        #endif
+
+        s.ij=uTransColor.rgb;  
+        s.ik=uTransScatter;  
+
+        #ifdef SKIN_VERSION_1
+        s.eC=uSkinShadowBlur*s.im;  
+        #else 
+        s.il=max(max(s.ij.r,s.ij.g),s.ij.b)*uTransColor.a;  
+        float io=max(s.hX.r,max(s.hX.g,s.hX.b));  
+        io=1.0-io;  
+        io*=io;  
+        io*=io;  
+        io*=io;  
+        io=1.0-(io*io);  
+        s.im*=io;  
+        s.eC=uSkinShadowBlur*s.im*dot(s.hX.rgb,vec3(0.333,0.334,0.333));  
+        #endif
+
+        #ifndef SKIN_NO_TRANSLUCENCY_TEX
+        m=dM(d,uTexRangeTranslucency);  
+        s.ij*=dG(m.xyz);  
+        #endif
+
+        s.ie=hF(tNormal,d,uNormalSmooth*s.im);  
+        vec3 iu,iv,iA;  
+        fK(iu,iv,iA,s.ie);  
+        s.eh=s.hY=iu+iv+iA;  
+
+        #ifdef SKIN_VERSION_1 
+        s.ec=fQ(iu,iv,iA,vec3(1.0,0.6667,0.25),s.hX);  
+        #else
+        s.ec=fQ(iu,iv,iA,vec3(1.0,0.6667,0.25),s.hX*0.2+vec3(0.1));  
+        #endif
+
+        #ifdef SKIN_VERSION_1
+        vec3 iB,iC,iD;  
+        fK(iB,iC,iD,-s.ie);  
+        s.id=fO(iB,iC,iD,vec3(1.0,0.4444,0.0625),s.ik);  
+        s.id*=uTransSky;  
+        #else 
+        s.id=vec3(0.0);  
+        #endif
+
+        s.hZ=s.ic=s.he=vec3(0.0);  
+        s.hX*=0.5;  
+        s.ik*=0.5;  
+        s.ih=uFresnelColor.rgb;  
+        s.ii=uFresnelColor.aaa*vec3(1.0,0.5,0.25);  
+
+        #ifndef SKIN_NO_FUZZ_TEX
+        m=dM(d,uTexRangeFuzz);  
+        s.ih*=dG(m.rgb);  
+        #endif
+
+    }
+
+
+void eK(inout dX s,float iE,float iF,vec3 eH,vec3 dI,vec3 eJ) 
+{
+    float fk=dot(eH,dI);  
+    float fl=dot(eH,s.ie);  
+    float eN=saturate((1.0/3.1415926)*fk);  
+    float hi=iE*iE;  
+    hi*=hi;  
+    hi=saturate(6.0*hi);  
+
+    #ifdef SKIN_VERSION_1 
+    vec3 iG=fB(fl,s.hX);  
+    #else 
+    vec3 iG=fj(fk,fl,s.hX);  
+    #endif
+
+    float iH=fA(-fl,s.ik);  
+    vec3 ic=vec3(iH*iH);  
+
+    #ifdef SKIN_VERSION_1
+        
+        #ifdef SHADOW_COUNT
+        vec3 iI=vec3(iE);  
+        float iJ=saturate(hi-2.0*(iE*iE));  
+        iI+=iJ*s.hX;  
+        float iK=iE;  
+        #endif
+
+    #else
+
+        #ifdef SHADOW_COUNT
+        vec3 iI;  
+        highp vec3 iL=(0.995*s.hX)+vec3(0.005,0.005,0.005);  
+        highp vec3 iM=vec3(1.0)-iL;  
+        iL=mix(iL,iM,iE);  
+        float iN=sqrt(iE);  
+        vec3 iO=2.0*vec3(1.0-iN);  
+        iN=1.0-iN;  
+        iN=(1.0-iN*iN);  
+        iI=saturate(pow(iL*iN,iO));  
+        highp float iP=0.35/(uSkinTransDepth+0.001);  
+        highp float iQ=saturate(iF*iP);  
+        iQ=saturate(1.0-iQ);  
+        iQ*=iQ;  
+        highp vec3 iR=vec3((-3.0*iQ)+3.15);  
+        highp vec3 iS=(0.9975*s.ij)+vec3(0.0025,0.0025,0.0025);  
+        highp float io=saturate(10.0*dot(iS,iS));  
+        vec3 iK=pow(iS*iQ,iR)*io;  
+        #else 
+        ic=vec3(0.0);  
+        #endif
+
+    #endif
+
+    float hj=fA(fl,s.ii.z);  
+
+    #ifdef SHADOW_COUNT
+    vec3 hk=mix(vec3(1.0),iI,uFresnelOcc);  
+    vec3 he=hj*hk;  
+    #else
+    vec3 he=vec3(hj);  
+    #endif
+
+    #ifdef SHADOW_COUNT
+    iG*=iI;  
+    eN*=hi;  
+    ic*=iK;  
+    #endif
+
+    s.he=he*eJ+s.he;  
+    s.ic=ic*eJ+s.ic;  
+    s.hZ=iG*eJ+s.hZ;  
+    s.hY=eN*eJ+s.hY;  
+}
+
+void eQ(out vec3 ei,out vec3 diff_extra,inout dX s,vec3 dO,vec3 dI,float dQ) 
+{
+    s.he*=uFresnelIntegral;  
+    float fH=dot(dO,dI);  
+    vec2 hl=fG(vec2(fH,fH),s.ii.xy);  
+    s.he=s.eh*hl.x+(s.he*hl.y);  
+    s.he*=s.ih;  
+    float hm=saturate(1.0+-uFresnelGlossMask*dQ);  
+    s.he*=hm*hm;  
+    s.ic=s.ic*uTransIntegral;  
+
+    #ifdef SKIN_VERSION_1
+    s.hZ=(s.hZ*fD(s.hX))+s.ec;  
+    #else
+    s.hZ=(s.hZ*fv(s.hX))+s.ec;  
+    #endif
+
+    ei=mix(s.hY,s.hZ,s.im);  
+
+    #ifdef SKIN_VERSION_1
+    s.ic=(s.ic+s.id)*s.ij;  
+    diff_extra=(s.he+s.ic)*s.im;  
+    #else
+    ei+=s.ic*s.il;  
+    diff_extra=s.he*s.im;  
+    #endif
+
+}
+#endif

+ 34 - 0
src/webgl/assets/marmosets/shaders/chunks/matstrips.glsl

@@ -0,0 +1,34 @@
+#ifdef STRIPVIEW
+uniform float uStrips[5];
+uniform vec2 uStripRes;
+
+struct dT
+{
+    float io[5];
+    float bg;
+};
+
+void dV(out dT iT,inout float dQ,inout vec3 dP)
+{
+    highp vec2 hA=gl_FragCoord.xy*uStripRes-vec2(1.0,1.0);
+    hA.x+=0.25*hA.y;
+    iT.io[0]=step(hA.x,uStrips[0]);
+    iT.io[1]=step(hA.x,uStrips[1]);
+    iT.io[2]=step(hA.x,uStrips[2]);
+    iT.io[3]=step(hA.x,uStrips[3]);
+    iT.io[4]=step(hA.x,uStrips[4]);
+    iT.bg=1.0-iT.io[4];
+    iT.io[4]-=iT.io[3];
+    iT.io[3]-=iT.io[2];
+    iT.io[2]-=iT.io[1];
+    iT.io[1]-=iT.io[0];
+    bool iU=iT.io[4]>0.0;
+    dQ=iU?0.5:dQ;
+    dP=iU?vec3(0.1):dP;
+}
+
+vec3 eX(dT iT,vec3 dI,vec3 dF,vec3 dP,float dQ,vec3 ei,vec3 el,vec3 iV)
+{
+    return iT.io[0]*(dI*0.5+vec3(0.5))+iT.io[1]*dF+iT.io[2]*dP+vec3(iT.io[3]*dQ)+iT.io[4]*(vec3(0.12)+0.3*ei+el)+iT.bg*iV;
+}
+#endif

+ 72 - 0
src/webgl/assets/marmosets/shaders/chunks/matvert.glsl

@@ -0,0 +1,72 @@
+precision highp float;
+
+uniform mat4 uModelViewProjectionMatrix;
+uniform mat4 uSkyMatrix;
+uniform vec2 uUVOffset;
+
+attribute vec3 vPosition;
+attribute vec2 vTexCoord;
+attribute vec2 vTangent;
+attribute vec2 vBitangent;
+attribute vec2 vNormal;
+
+#ifdef VERTEX_COLOR
+attribute vec4 vColor;
+#endif
+
+#ifdef TEXCOORD_SECONDARY
+attribute vec2 vTexCoord2;
+#endif
+
+varying highp vec3 dv;
+varying mediump vec2 d;
+varying mediump vec3 dA;
+varying mediump vec3 dB;
+varying mediump vec3 dC;
+
+#ifdef VERTEX_COLOR
+varying lowp vec4 dD;
+#endif
+
+#ifdef TEXCOORD_SECONDARY
+varying mediump vec2 dE;
+#endif
+
+vec3 iW(vec2 v)
+{
+    bool iX=(v.y>(32767.1/65535.0));
+    v.y=iX?(v.y-(32768.0/65535.0)):v.y;
+    vec3 r;
+    r.xy=(2.0*65535.0/32767.0)*v-vec2(1.0);
+    r.z=sqrt(clamp(1.0-dot(r.xy,r.xy),0.0,1.0));
+    r.z=iX?-r.z:r.z;
+    return r;
+}
+
+vec4 h(mat4 i,vec3 p)
+{
+    return i[0]*p.x+(i[1]*p.y+(i[2]*p.z+i[3]));
+}
+
+vec3 u(mat4 i,vec3 v)
+{
+    return i[0].xyz*v.x+i[1].xyz*v.y+i[2].xyz*v.z;
+}
+
+void main(void)
+{
+    gl_Position=h(uModelViewProjectionMatrix,vPosition.xyz);
+    d=vTexCoord+uUVOffset;
+    dA=u(uSkyMatrix,iW(vTangent));
+    dB=u(uSkyMatrix,iW(vBitangent));
+    dC=u(uSkyMatrix,iW(vNormal));
+    dv=h(uSkyMatrix,vPosition.xyz).xyz;
+
+    #ifdef VERTEX_COLOR
+    dD=vColor;
+    #endif
+
+    #ifdef TEXCOORD_SECONDARY
+    dE=vTexCoord2;
+    #endif
+}

+ 10 - 0
src/webgl/assets/marmosets/shaders/chunks/postaa.glsl

@@ -0,0 +1,10 @@
+precision mediump float;
+
+uniform sampler2D tInput;
+
+varying vec2 j;
+
+void main(void)
+{
+    gl_FragColor=texture2D(tInput,j);
+}

+ 108 - 0
src/webgl/assets/marmosets/shaders/chunks/postfrag.glsl

@@ -0,0 +1,108 @@
+precision mediump float;
+
+uniform sampler2D tInput;
+
+#ifdef BLOOM
+uniform sampler2D tBloom;
+#endif 
+
+#ifdef GRAIN
+uniform sampler2D tGrain;
+#endif 
+
+#ifdef COLOR_LUT
+uniform sampler2D tLUT;
+#endif 
+
+uniform vec3 uScale;
+uniform vec3 uBias;
+uniform vec3 uSaturation;
+uniform vec4 uSharpenKernel;
+uniform vec3 uSharpness;
+uniform vec3 uBloomColor;
+uniform vec4 uVignetteAspect;
+uniform vec4 uVignette;
+uniform vec4 uGrainCoord;
+uniform vec2 uGrainScaleBias;
+
+varying vec2 j;
+
+vec3 iY(vec3 c)
+{
+    vec3 iZ=sqrt(c);
+    return(iZ-iZ*c)+c*(0.4672*c+vec3(0.5328));
+}
+
+void main(void)
+{
+    vec4 jc=texture2D(tInput,j);
+    vec3 c=jc.xyz;
+
+    #ifdef SHARPEN
+    vec3 hM=texture2D(tInput,j+uSharpenKernel.xy).xyz;
+    hM+=texture2D(tInput,j-uSharpenKernel.xy).xyz;
+    hM+=texture2D(tInput,j+uSharpenKernel.zw).xyz;
+    hM+=texture2D(tInput,j-uSharpenKernel.zw).xyz;
+    vec3 jd=uSharpness.x*c-uSharpness.y*hM;
+    c+=clamp(jd,-uSharpness.z,uSharpness.z);
+    #endif 
+
+    #ifdef BLOOM
+    c+=uBloomColor*texture2D(tBloom,j).xyz;
+    #endif 
+
+    #ifdef VIGNETTE
+    vec2 je=j*uVignetteAspect.xy-uVignetteAspect.zw;
+    vec3 v=clamp(vec3(1.0,1.0,1.0)-uVignette.xyz*dot(je,je),0.0,1.0);
+    vec3 jf=v*v;
+    jf*=v;
+    c*=mix(v,jf,uVignette.w);
+    #endif 
+
+    #ifdef SATURATION
+    float gray=dot(c,vec3(0.3,0.59,0.11));
+    c=mix(vec3(gray,gray,gray),c,uSaturation);
+    #endif 
+
+    #ifdef CONTRAST
+    c=c*uScale+uBias;
+    #endif 
+
+    #ifdef GRAIN
+    float jh=uGrainScaleBias.x*texture2D(tGrain,j*uGrainCoord.xy+uGrainCoord.zw).x+uGrainScaleBias.y;
+    c+=c*jh;
+    #endif 
+
+    #ifdef REINHARD
+    {
+        c*=1.8;
+        float ji=dot(c,vec3(0.3333));
+        c=clamp(c/(1.0+ji),0.0,1.0);
+    }
+    #elif defined(HEJL)
+    {
+        const highp float jj=0.22,jk=0.3,jl=.1,jm=0.2,jn=.01,jo=0.3;
+        const highp float ju=1.25;
+        highp vec3 eO=max(vec3(0.0),c-vec3(.004));
+        c=(eO*((ju*jj)*eO+ju*vec3(jl*jk,jl*jk,jl*jk))+ju*vec3(jm*jn,jm*jn,jm*jn))/(eO*(jj*eO+vec3(jk,jk,jk))+vec3(jm*jo,jm*jo,jm*jo))-ju*vec3(jn/jo,jn/jo,jn/jo);
+    }
+    #elif defined(ACES)
+    {
+        vec3 a=c*(c+0.0245786)-0.000090537;
+        vec3 b=c*(0.983729*c+0.4329510)+0.238081;
+        c=a/b;
+    }
+    #endif 
+
+    #ifdef COLOR_LUT
+    c=clamp(c,0.0,1.0);
+    c=(255.0/256.0)*c+vec3(0.5/256.0);
+    c.x=texture2D(tLUT,c.xx).x;
+    c.y=texture2D(tLUT,c.yy).y;
+    c.z=texture2D(tLUT,c.zz).z;
+    c*=c;
+    #endif 
+
+    gl_FragColor.xyz=iY(c);
+    gl_FragColor.w=jc.w;
+}

+ 12 - 0
src/webgl/assets/marmosets/shaders/chunks/postvert.glsl

@@ -0,0 +1,12 @@
+precision highp float;
+
+attribute vec2 vCoord;
+
+varying vec2 j;
+
+void main(void)
+{
+    j=vCoord;
+    gl_Position.xy=2.0*vCoord-vec2(1.0,1.0);
+    gl_Position.zw=vec2(0.0,1.0);
+}

+ 52 - 0
src/webgl/assets/marmosets/shaders/chunks/shadowfloorfrag.glsl

@@ -0,0 +1,52 @@
+precision mediump float;
+
+varying highp vec3 dv;
+varying mediump vec2 jv;
+varying mediump vec3 dC;
+
+uniform vec3 uShadowCatcherParams;
+
+#ifdef LIGHT_COUNT
+uniform vec4 uLightPositions[LIGHT_COUNT];
+uniform vec3 uLightDirections[LIGHT_COUNT];
+uniform vec3 uLightColors[LIGHT_COUNT];
+uniform vec3 uLightParams[LIGHT_COUNT];
+uniform vec3 uLightSpot[LIGHT_COUNT];
+#endif
+
+#define saturate(x) clamp( x, 0.0, 1.0 )
+#define SHADOW_COMPARE(a,b) ((a) < (b) || (b) >= 1.0 ? 1.0 : 0.0)
+#define SHADOW_CLIP(c,v) ((c.x<0.0 || c.x>1.0 || c.y<0.0 || c.y>1.0) ? 1.0 : v)
+#include <matshadows.glsl>
+
+void main(void)
+{
+    ev eA;
+    eB(eA,SHADOW_KERNEL);
+    vec3 jA=vec3(0.0,0.0,0.0);
+    vec3 jB=vec3(0.0,0.0,0.0);
+
+    for(int k=0;k<SHADOW_COUNT;++k)
+    {
+        vec3 eH=uLightPositions[k].xyz-dv*uLightPositions[k].w;
+        float eI=inversesqrt(dot(eH,eH));
+        eH*=eI;
+        float a=saturate(uLightParams[k].z/eI);
+        a=1.0+a*(uLightParams[k].x+uLightParams[k].y*a);
+        float s=saturate(dot(eH,uLightDirections[k]));
+        s=saturate(uLightSpot[k].y-uLightSpot[k].z*(1.0-s*s));
+        vec3 jC=mix(uLightColors[k].xyz,vec3(1.0,1.0,1.0),uShadowCatcherParams.x);
+        vec3 jD=(a*s)*jC;
+        jD*=saturate(dot(eH,dC));
+        jB+=jD;
+        jA+=jD*eA.eL[k];
+    }
+    
+    float jE=1.0e-4;
+    vec3 r=(jA+jE)/(jB+jE);
+    float jF=saturate(dot(jv,jv))*uShadowCatcherParams.z;
+    r=mix(r,vec3(1.0,1.0,1.0),jF);
+    r=mix(vec3(1.0,1.0,1.0),r,uShadowCatcherParams.y);
+    gl_FragColor.xyz=r;
+    gl_FragColor.w=1.0;
+}

+ 24 - 0
src/webgl/assets/marmosets/shaders/chunks/shadowfloorvert.glsl

@@ -0,0 +1,24 @@
+precision highp float;
+
+uniform mat4 uModelViewProjectionMatrix;
+uniform mat4 uModelSkyMatrix;
+uniform float uScale;
+
+attribute vec3 vPosition;
+
+varying highp vec3 dv;
+varying mediump vec2 jv;
+varying mediump vec3 dC;
+
+vec4 h(mat4 i,vec3 p)
+{
+    return i[0]*p.x+(i[1]*p.y+(i[2]*p.z+i[3]));
+}
+
+void main(void)
+{
+    jv=vPosition.xz;
+    dC=normalize(uModelSkyMatrix[1].xyz);
+    dv=h(uModelSkyMatrix,vPosition).xyz;
+    gl_Position=h(uModelViewProjectionMatrix,vPosition);
+}

+ 35 - 0
src/webgl/assets/marmosets/shaders/chunks/shadowfrag.glsl

@@ -0,0 +1,35 @@
+precision highp float;
+
+varying vec2 jG;
+
+#ifdef ALPHA_TEST
+varying mediump vec2 d;
+uniform sampler2D tAlbedo;
+#endif
+
+vec3 jH(float v)
+{
+    vec4 jI=vec4(1.0,255.0,65025.0,16581375.0)*v;
+    jI=fract(jI);
+    jI.xyz-=jI.yzw*(1.0/255.0);
+    return jI.xyz;
+}
+
+void main(void)
+{
+    #ifdef ALPHA_TEST
+    float e=texture2D(tAlbedo,d).a;
+    if(e<0.5)
+    {
+        discard;
+    }
+    #endif
+
+    #ifdef SHADOW_NATIVE_DEPTH
+    gl_FragColor.xyz=vec3(0.0,0.0,0.0);
+    #else
+    gl_FragColor.xyz=jH((jG.x/jG.y)*0.5+0.5);
+    #endif
+
+    gl_FragColor.w=0.0;
+}

+ 28 - 0
src/webgl/assets/marmosets/shaders/chunks/shadowvert.glsl

@@ -0,0 +1,28 @@
+precision highp float;
+attribute vec3 vPosition;
+attribute vec2 vTexCoord;
+uniform mat4 uMeshTransform;
+uniform mat4 uViewProjection;
+varying vec2 jG;
+
+#ifdef ALPHA_TEST
+varying mediump vec2 d;
+uniform vec2 uUVOffset;
+#endif
+
+vec4 h(mat4 i,vec3 p)
+{
+    return i[0]*p.x+(i[1]*p.y+(i[2]*p.z+i[3]));
+}
+
+void main(void)
+{
+    vec3 p=h(uMeshTransform,vPosition).xyz;
+    gl_Position=h(uViewProjection,p);
+    jG=gl_Position.zw;
+
+    #ifdef ALPHA_TEST
+    d=vTexCoord+uUVOffset;
+    #endif
+
+}

+ 13 - 0
src/webgl/assets/marmosets/shaders/chunks/sky.glsl

@@ -0,0 +1,13 @@
+precision highp float;
+
+uniform sampler2D tSkyTexture;
+uniform float uAlpha;
+
+varying vec2 d;
+
+void main(void)
+{
+    vec3 r=texture2D(tSkyTexture,d).xyz;
+    gl_FragColor.xyz=r*r;
+    gl_FragColor.w=uAlpha;
+}

+ 28 - 0
src/webgl/assets/marmosets/shaders/chunks/skyBake.glsl

@@ -0,0 +1,28 @@
+precision highp float;
+
+varying vec2 tc;
+attribute vec4 p;
+
+void main(){ 
+
+    gl_Position=p;
+    tc=vec2(0.5,0.5/8.0)*p.xy+vec2(0.5,6.5/8.0); 
+    
+}
+
+
+
+
+precision highp float;
+
+varying vec2 tc;
+
+uniform sampler2D tex;
+uniform float b;
+
+void main() {    
+    
+    vec4 s = texture2D(tex,tc);
+    gl_FragColor.xyz = s.xyz*(b*s.w);
+    
+}

+ 28 - 0
src/webgl/assets/marmosets/shaders/chunks/skySH.glsl

@@ -0,0 +1,28 @@
+precision mediump float;
+
+uniform vec4 uSkyCoefficients[9];
+uniform float uAlpha;
+
+varying vec3 jJ;
+
+void main(void)
+{
+    vec3 G=normalize(jJ);
+
+    vec3 r=uSkyCoefficients[0].xyz;
+    r+=uSkyCoefficients[1].xyz*G.y;
+    r+=uSkyCoefficients[2].xyz*G.z;
+    r+=uSkyCoefficients[3].xyz*G.x;
+
+    vec3 swz=G.yyz*G.xzx;
+    r+=uSkyCoefficients[4].xyz*swz.x;
+    r+=uSkyCoefficients[5].xyz*swz.y;
+    r+=uSkyCoefficients[7].xyz*swz.z;
+
+    vec3 sqr=G*G;
+    r+=uSkyCoefficients[6].xyz*(3.0*sqr.z-1.0);
+    r+=uSkyCoefficients[8].xyz*(sqr.x-sqr.y);
+    
+    gl_FragColor.xyz=r;
+    gl_FragColor.w=uAlpha;
+}

+ 37 - 0
src/webgl/assets/marmosets/shaders/chunks/skyvert.glsl

@@ -0,0 +1,37 @@
+precision highp float;
+
+uniform mat4 uInverseSkyMatrix;
+uniform mat4 uViewProjection;
+
+attribute vec3 vPosition;
+attribute vec2 vTexCoord;
+
+#if SKYMODE == 3
+varying vec3 jJ;
+#else
+varying vec2 d;
+#endif
+
+vec4 h(mat4 i,vec3 p)
+{
+    return i[0]*p.x+(i[1]*p.y+(i[2]*p.z+i[3]));
+}
+
+vec4 u(mat4 i,vec3 v)
+{
+    return i[0]*v.x+i[1]*v.y+i[2]*v.z;
+}
+
+void main(void)
+{
+    vec3 p=h(uInverseSkyMatrix,vPosition).xyz;
+    gl_Position=u(uViewProjection,p);
+    gl_Position.z-=(1.0/65535.0)*gl_Position.w;
+
+    #if SKYMODE == 3
+    jJ=vPosition;
+    jJ.xy+=1e-20*vTexCoord;
+    #else
+    d=vTexCoord;
+    #endif
+}

+ 14 - 0
src/webgl/assets/marmosets/shaders/chunks/wirefrag.glsl

@@ -0,0 +1,14 @@
+precision highp float;
+
+uniform vec4 uStripParams;
+
+void main(void)
+{
+
+    vec2 c=gl_FragCoord.xy*uStripParams.xy-vec2(1.0,1.0);
+    c.x+=0.25*c.y;
+    
+    float a=c.x<uStripParams.z?0.0:0.9;
+    a=c.x<uStripParams.w?a:0.0;
+    gl_FragColor=vec4(0.0,0.0,0.0,a);
+}

+ 16 - 0
src/webgl/assets/marmosets/shaders/chunks/wirevert.glsl

@@ -0,0 +1,16 @@
+precision highp float;
+
+uniform mat4 uModelViewProjectionMatrix;
+
+attribute vec3 vPosition;
+
+vec4 h(mat4 i,vec3 p)
+{
+    return i[0]*p.x+(i[1]*p.y+(i[2]*p.z+i[3]));
+}
+
+void main(void)
+{
+    gl_Position = h(uModelViewProjectionMatrix,vPosition);
+    gl_Position.z+=-0.00005*gl_Position.w;
+}

+ 156 - 0
src/webgl/assets/marmosets/shaders/posteffect.ts

@@ -0,0 +1,156 @@
+import * as THREE from 'three'
+
+type AttributesDescription = {
+
+    vPosition:THREE.Vector3
+    
+    vTexCoord: THREE.Vector2
+
+}
+
+type VaryingDescription = {
+
+    d: THREE.Vector2
+
+}
+
+const uniforms = {
+
+  
+}
+
+export default {
+
+
+    attibuteDescription: {} as AttributesDescription,
+
+    varying: {} as VaryingDescription,
+
+    uniforms: uniforms,
+
+    vertexShader :`
+
+            varying vec2 j;
+
+            void main() {
+
+                j = uv;
+                gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+            }
+
+    `,
+
+    fragmentShader:`
+
+        precision mediump float;
+
+        uniform sampler2D tInput;
+        
+        #ifdef BLOOM
+        uniform sampler2D tBloom;
+        #endif 
+        
+        #ifdef GRAIN
+        uniform sampler2D tGrain;
+        #endif 
+        
+        #ifdef COLOR_LUT
+        uniform sampler2D tLUT;
+        #endif 
+        
+        uniform vec3 uScale;
+        uniform vec3 uBias;
+        uniform vec3 uSaturation;
+        uniform vec4 uSharpenKernel;
+        uniform vec3 uSharpness;
+        uniform vec3 uBloomColor;
+        uniform vec4 uVignetteAspect;
+        uniform vec4 uVignette;
+        uniform vec4 uGrainCoord;
+        uniform vec2 uGrainScaleBias;
+        
+        varying vec2 j;
+        
+        vec3 iY(vec3 c)
+        {
+            vec3 iZ=sqrt(c);
+            return(iZ-iZ*c)+c*(0.4672*c+vec3(0.5328));
+        }
+        
+        void main(void)
+        {
+            vec4 jc=texture2D(tInput,j);
+            vec3 c=jc.xyz;
+        
+            #ifdef SHARPEN
+            vec3 hM=texture2D(tInput,j+uSharpenKernel.xy).xyz;
+            hM+=texture2D(tInput,j-uSharpenKernel.xy).xyz;
+            hM+=texture2D(tInput,j+uSharpenKernel.zw).xyz;
+            hM+=texture2D(tInput,j-uSharpenKernel.zw).xyz;
+            vec3 jd=uSharpness.x*c-uSharpness.y*hM;
+            c+=clamp(jd,-uSharpness.z,uSharpness.z);
+            #endif 
+        
+            #ifdef BLOOM
+            c+=uBloomColor*texture2D(tBloom,j).xyz;
+            #endif 
+        
+            #ifdef VIGNETTE
+            vec2 je=j*uVignetteAspect.xy-uVignetteAspect.zw;
+            vec3 v=clamp(vec3(1.0,1.0,1.0)-uVignette.xyz*dot(je,je),0.0,1.0);
+            vec3 jf=v*v;
+            jf*=v;
+            c*=mix(v,jf,uVignette.w);
+            #endif 
+        
+            #ifdef SATURATION
+            float gray=dot(c,vec3(0.3,0.59,0.11));
+            c=mix(vec3(gray,gray,gray),c,uSaturation);
+            #endif 
+        
+            #ifdef CONTRAST
+            c=c*uScale+uBias;
+            #endif 
+        
+            #ifdef GRAIN
+            float jh=uGrainScaleBias.x*texture2D(tGrain,j*uGrainCoord.xy+uGrainCoord.zw).x+uGrainScaleBias.y;
+            c+=c*jh;
+            #endif 
+        
+            #ifdef REINHARD
+            {
+                c*=1.8;
+                float ji=dot(c,vec3(0.3333));
+                c=clamp(c/(1.0+ji),0.0,1.0);
+            }
+            #elif defined(HEJL)
+            {
+                const highp float jj=0.22,jk=0.3,jl=.1,jm=0.2,jn=.01,jo=0.3;
+                const highp float ju=1.25;
+                highp vec3 eO=max(vec3(0.0),c-vec3(.004));
+                c=(eO*((ju*jj)*eO+ju*vec3(jl*jk,jl*jk,jl*jk))+ju*vec3(jm*jn,jm*jn,jm*jn))/(eO*(jj*eO+vec3(jk,jk,jk))+vec3(jm*jo,jm*jo,jm*jo))-ju*vec3(jn/jo,jn/jo,jn/jo);
+            }
+            #elif defined(ACES)
+            {
+                vec3 a=c*(c+0.0245786)-0.000090537;
+                vec3 b=c*(0.983729*c+0.4329510)+0.238081;
+                c=a/b;
+            }
+            #endif 
+        
+            #ifdef COLOR_LUT
+            c=clamp(c,0.0,1.0);
+            c=(255.0/256.0)*c+vec3(0.5/256.0);
+            c.x=texture2D(tLUT,c.xx).x;
+            c.y=texture2D(tLUT,c.yy).y;
+            c.z=texture2D(tLUT,c.zz).z;
+            c*=c;
+            #endif 
+        
+            gl_FragColor.xyz=iY(c);
+            gl_FragColor.w=jc.w;
+        }
+    `
+
+}

+ 13 - 0
src/webgl/materials/marmoset/BasicMaterial.ts

@@ -0,0 +1,13 @@
+import * as THREE from 'three'
+
+export default class BasicMaterial extends THREE.MeshBasicMaterial {
+
+    constructor() {
+
+        super()
+
+        this.color.setHex(0xFF00FF)
+
+    }
+
+}

+ 19 - 0
src/webgl/materials/marmoset/ComplexMaterial.ts

@@ -0,0 +1,19 @@
+import * as THREE from 'three';
+
+export default class ComplexMaterial extends THREE.ShaderMaterial {
+
+
+    
+
+    constructor() {
+
+        super();
+
+    }
+
+    build() {
+
+
+    }
+
+}

+ 157 - 0
src/webgl/materials/marmoset/MeshMaterial.ts

@@ -0,0 +1,157 @@
+import * as THREE from 'three'
+
+import { Material as MaterialParameter, MviewAsset } from '../../assets/marmosets/MviewFiles'
+import MarmosetTexture from '@/webgl/textures/MarmosetTexture';
+
+
+// note 
+
+// ---- Blend ----  ( blendTint )
+// none | alpha | add
+//
+// none: disable
+// alpha: blendFuncSeparate(a.SRC_ALPHA, a.ONE_MINUS_SRC_ALPHA, a.ONE_MINUS_DST_ALPHA, a.ONE)
+// add: a.blendColor(g[0], g[1], g[2], 1); a.blendFunc(a.ONE, a.CONSTANT_COLOR)
+
+//
+
+
+export default class MeshMaterial extends THREE.MeshPhysicalMaterial {
+
+   
+    constructor() {
+
+        super({})
+
+        
+    }
+
+
+    build( parameter: MaterialParameter, textures: Map<string, MarmosetTexture>, envMap?: THREE.CubeTexture ) {
+
+        this.name = parameter.name;
+        console.log(parameter)
+
+        //this.side = THREE.DoubleSide
+        
+        this.color.set(0xffffff)
+        this.map = textures.get(parameter.albedoTex) || null
+        
+        //this.normalScale = new THREE.Vector2(0,0);
+        this.normalMap = textures.get(parameter.normalTex) || null; 
+        this.normalMapType = THREE.TangentSpaceNormalMap  
+       
+        //this.metalness = 1
+        this.metalnessMap = textures.get(parameter.reflectivityTex) || null;
+
+        //this.roughness = 0;
+        this.roughnessMap = textures.get(parameter.glossTex) || null;
+
+        // this.clearcoat = 0.6
+        // this.clearcoatNormalMap = this.normalMap
+        // this.clearcoatRoughness = 0.3;
+
+        this.envMap = envMap || null
+        this.envMapIntensity = 0;
+
+        //this.aoMapIntensity = 0.5;
+        //this.aoMap = textures.get(parameter.extrasTex) || null;
+    
+        this.reflectivity = 0;
+
+        this.transparent = parameter.blend != "none";
+   
+       
+
+        this.alphaMap = textures.get(parameter.alphaTex) || null;
+        this.BlendingParameter( parameter.blend );
+        
+        this.alphaTest = parameter.alphaTest || 0;
+
+        this.needsUpdate = true
+    
+    }   
+
+    private BlendingParameter( blendingMode: string ) {
+
+        switch (blendingMode) {
+
+            case "none":
+                this.blending = THREE.NoBlending;
+                break;
+            case "add":
+                this.blending =  THREE.AdditiveBlending;
+                break;
+            case "alpha":
+                this.blending = THREE.CustomBlending;        // gl.blendFuncSeparate( gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE_MINUS_DST_ALPHA, gl.ONE)
+                this.blendSrc = THREE.SrcAlphaFactor;
+                this.blendDst = THREE.OneMinusSrcAlphaFactor;
+                this.blendSrcAlpha = THREE.OneMinusDstAlphaFactor;
+                this.blendDstAlpha = THREE.OneFactor;
+                break;
+
+            default:
+                this.blending =  THREE.NoBlending
+        }
+    }
+
+
+    // private generateVertexShader() {
+
+    //     let vs = `
+
+    //         attribute vec2 aTangent;
+    //         attribute vec2 aBitangent;
+    //         attribute vec2 aNormal;
+
+         
+    //         varying mediump vec3 vNormal;
+    //         varying mediump vec2 vUv;
+
+    //         vec3 iW(vec2 v)
+    //         {
+    //             bool iX=(v.y>(32767.1/65535.0));
+    //             v.y=iX?(v.y-(32768.0/65535.0)):v.y;
+    //             vec3 r;
+    //             r.xy=(2.0*65535.0/32767.0)*v-vec2(1.0);
+    //             r.z=sqrt(clamp(1.0-dot(r.xy,r.xy),0.0,1.0));
+    //             r.z=iX?-r.z:r.z;
+    //             return r;
+    //         }
+
+
+    //         void main() 
+    //         {
+
+    //             gl_Position = projectionMatrix * modelViewMatrix * vec4(position.xyz, 1.0);
+                
+    //             vNormal = normalMatrix * normal; //iW(aNormal);  //normalize(normalMatrix * normal);
+    //             vUv = uv;
+    //         }
+
+    //     `
+    //     this.vertexShader = vs;
+    // }
+
+    // private generateFragmentShader() {
+
+    //     let fs = `
+
+    //         varying mediump vec3 vNormal;
+    //         varying mediump vec2 vUv;
+
+    //         vec3 packNormalToRGB( const in vec3 normal ) {
+    //             return normalize( normal ) * 0.5 + 0.5;
+    //         }
+
+    //         void main() 
+    //         {
+    //             vec3 color = packNormalToRGB(vNormal);  //vec3(vUv, 0.0); 
+    //             gl_FragColor = vec4(color, 1.0);
+    //         }
+        
+    //     `
+    //     this.fragmentShader = fs;
+    // }
+
+}

+ 12 - 0
src/webgl/materials/marmoset/index.ts

@@ -0,0 +1,12 @@
+
+import MeshMaterial from './MeshMaterial'
+
+
+
+
+
+export {
+
+    MeshMaterial
+
+}

+ 205 - 0
src/webgl/objects/MarmosetModel.ts

@@ -0,0 +1,205 @@
+import * as THREE from 'three'
+import BufferReader from '../assets/marmosets/parser/BufferReader';
+
+import { MviewAsset, Scene as MviewScene, Mesh as MviewMesh, Material as MviewMaterial } from '../assets/marmosets/MviewFiles';
+import { MeshMaterial } from '../materials/marmoset'
+import BasicMaterial from '../materials/marmoset/BasicMaterial';
+
+class MarmosetModel extends THREE.Object3D {
+
+    meshs: THREE.Mesh[]
+
+    constructor() {
+
+        super()
+
+        this.meshs = [];
+            
+    }
+
+
+    private compressVector3( vectorIn: THREE.Vector2 )  
+    {
+        let vectorOut = new THREE.Vector3();
+
+        let revert = vectorIn.y > 32767.1/65535.0;
+
+        vectorIn.y = revert ? vectorIn.y - 32768.0/65535.0 : vectorIn.y;
+
+        vectorOut.x = (2.0*65535.0/32767.0)* vectorIn.x - 1.0;
+        vectorOut.y = (2.0*65535.0/32767.0)* vectorIn.y - 1.0;
+        vectorOut.z = Math.sqrt( THREE.MathUtils.clamp( 1 - (vectorOut.x * vectorOut.x + vectorOut.y * vectorOut.y), 0, 1) );
+
+        vectorOut.z = revert ? -vectorOut.z : vectorOut.z;
+        
+        return vectorOut;
+
+    }
+
+
+    buildMeshes( meshes: MviewMesh[], files: Map<string, MviewAsset>, materials: Map<string, MeshMaterial> ) {
+
+        if(meshes.length > 0) {
+
+
+            for( let i = 0; i < meshes.length; i++ ) {
+
+                let item = meshes[i];
+
+                let file = files.get( item.file )
+    
+                if( !file ) {
+    
+                    console.warn(`找不到[Mesh]${ item.name }的数据`)
+    
+                } else {
+        
+                    this.buildMesh(item, file, materials)
+                    
+                }
+                
+            }
+
+
+        }
+
+    }
+
+
+    buildMesh( mviewMesh: MviewMesh, asset: MviewAsset, materialAssets: Map<string, MeshMaterial>) {
+
+        let bufferReader = new BufferReader(asset.data);
+
+        let stride = 32; //8 字节   position 3 * 4, uv 2 * 4, tangent 1 * 4, bitTangent 1 * 4, normal 1 *4 
+
+        let indexBuffer = bufferReader.readBytes(mviewMesh.indexCount * mviewMesh.indexTypeSize);
+        let indexBufferAttribute = mviewMesh.indexTypeSize == 2 ? new THREE.Uint16BufferAttribute(indexBuffer, 1) : new THREE.Uint32BufferAttribute(indexBuffer, 1);
+       
+
+        let wireBuffer = bufferReader.readBytes(mviewMesh.wireCount * mviewMesh.indexTypeSize);
+
+        let vertexBuffer = bufferReader.readBytes(mviewMesh.vertexCount * stride);
+        let useTHREE = true;
+        let positionAttribute: THREE.InterleavedBufferAttribute | THREE.Float32BufferAttribute
+        let uvAttribute: THREE.InterleavedBufferAttribute | THREE.Float32BufferAttribute
+        let normalAttribute: THREE.InterleavedBufferAttribute | THREE.Float32BufferAttribute
+        let tangentAttribute: THREE.InterleavedBufferAttribute  | THREE.Uint16BufferAttribute | undefined
+        let bitTangentAttribute: THREE.InterleavedBufferAttribute  | THREE.Uint16BufferAttribute | undefined
+
+        if( useTHREE ) {
+
+            let dataView = new DataView(vertexBuffer);
+
+            let positionAttributeArray = new Float32Array(mviewMesh.vertexCount * 3);
+            let uvAttributeArray = new Float32Array(mviewMesh.vertexCount * 2);
+            let normalAttributeArray = new Float32Array(mviewMesh.vertexCount * 3);
+
+            for( let i = 0; i < mviewMesh.vertexCount; i++ ) {
+
+                positionAttributeArray[3 * i + 0] = dataView.getFloat32(32 * i + 0, true);
+                positionAttributeArray[3 * i + 1] = dataView.getFloat32(32 * i + 4, true);
+                positionAttributeArray[3 * i + 2] = dataView.getFloat32(32 * i + 8, true);
+
+                uvAttributeArray[2 * i + 0] = dataView.getFloat32(32 * i + 12, true);
+                uvAttributeArray[2 * i + 1] = dataView.getFloat32(32 * i + 16, true); 
+
+                let normal = new THREE.Vector2()
+                    normal.x = dataView.getUint16( 32 * i + 28, true ) / 65535
+                    normal.y = dataView.getUint16( 32 * i + 30, true ) / 65535
+            
+
+                let normal3 = this.compressVector3(normal)
+
+                normalAttributeArray[3 * i + 0] = normal3.x;
+                normalAttributeArray[3 * i + 1] = normal3.y;
+                normalAttributeArray[3 * i + 2] = normal3.z;
+               
+            }
+            
+            positionAttribute = new THREE.Float32BufferAttribute(positionAttributeArray, 3)
+            uvAttribute = new THREE.Float32BufferAttribute(uvAttributeArray, 2)
+            normalAttribute = new THREE.Float32BufferAttribute(normalAttributeArray, 3)
+            tangentAttribute = undefined
+            bitTangentAttribute = undefined
+
+        } else {
+
+           
+            let dataView = new DataView(vertexBuffer);
+
+            let positionAttributeArray = new Float32Array(mviewMesh.vertexCount * 3);
+            let uvAttributeArray = new Float32Array(mviewMesh.vertexCount * 2);
+            let tangentAttributeArray = new Uint16Array(mviewMesh.vertexCount * 2);
+            let bitTangentAttributeArray = new Uint16Array(mviewMesh.vertexCount * 2)
+            let normalAttributeArray = new Uint16Array(mviewMesh.vertexCount * 2);
+
+            for( let i = 0; i < mviewMesh.vertexCount; i++ ) {
+
+                positionAttributeArray[3 * i + 0] = dataView.getFloat32(32 * i + 0, true);
+                positionAttributeArray[3 * i + 1] = dataView.getFloat32(32 * i + 4, true);
+                positionAttributeArray[3 * i + 2] = dataView.getFloat32(32 * i + 8, true);
+
+                uvAttributeArray[2 * i + 0] = dataView.getFloat32(32 * i + 12, true);
+                uvAttributeArray[2 * i + 1] = dataView.getFloat32(32 * i + 16, true); 
+
+                tangentAttributeArray[2 * i + 0] = dataView.getUint16(32 * i + 20, true);
+                tangentAttributeArray[2 * i + 1] = dataView.getUint16(32 * i + 22, true);
+            
+                bitTangentAttributeArray[2 * i + 0] = dataView.getUint16(32 * i + 24, true);
+                bitTangentAttributeArray[2 * i + 1] = dataView.getUint16(32 * i + 26, true);
+
+                normalAttributeArray[2 * i + 0] = dataView.getUint16(32 * i + 28, true);
+                normalAttributeArray[2 * i + 1] = dataView.getUint16(32 * i + 30, true);
+            }
+
+            positionAttribute = new THREE.Float32BufferAttribute(positionAttributeArray, 3)
+            uvAttribute = new THREE.Float32BufferAttribute(uvAttributeArray, 2)
+            tangentAttribute = new THREE.Uint16BufferAttribute( tangentAttributeArray, 2);
+            bitTangentAttribute = new THREE.Uint16BufferAttribute( bitTangentAttributeArray, 2);
+            normalAttribute = new THREE.Uint16BufferAttribute(normalAttributeArray, 2, true);
+
+        }
+        
+
+
+        let geometry = new THREE.BufferGeometry();
+            geometry.setAttribute("position", positionAttribute);
+            geometry.setAttribute("uv", uvAttribute);
+            tangentAttribute && geometry.setAttribute("aTangent", tangentAttribute);
+            bitTangentAttribute && geometry.setAttribute("aBitangent", bitTangentAttribute);
+            useTHREE ? geometry.setAttribute("normal", normalAttribute) : geometry.setAttribute("aNormal", normalAttribute);
+            geometry.setIndex(indexBufferAttribute);
+
+            geometry.computeBoundingBox()
+            geometry.computeBoundingSphere()
+            
+        
+        for(let i = 0; i < mviewMesh.subMeshes.length; i++ ) {
+
+            let subMesh = mviewMesh.subMeshes[i];
+            geometry.addGroup(subMesh.firstIndex, subMesh.indexCount, i)
+            
+        }
+
+        let materials = mviewMesh.subMeshes.map( item => materialAssets.get(item.material) || new BasicMaterial())
+    
+        let mesh = new THREE.Mesh(geometry, materials );
+            mesh.name = mviewMesh.name
+
+        // mesh = new THREE.Mesh(
+        //     new THREE.SphereBufferGeometry(30, 50, 50),
+        //     materialAssets.get("Sonya_Exosuit1")
+        // )
+
+        this.add(mesh);
+        
+        return mesh;
+    }
+
+    private buildGeometry( ) {
+
+
+    }
+}
+
+export default MarmosetModel

+ 339 - 0
src/webgl/posts/TestPass.ts

@@ -0,0 +1,339 @@
+// import * as THREE from 'three';
+// import { PostEffect as PostEffectParameter } from '../assets/marmosets/MviewFiles'
+// import { Pass } from 'three/examples/jsm/postprocessing/Pass';
+
+
+// const parameterTest: PostEffectParameter = {
+
+//     toneMap: 2,         // 0 - Linear  1 - Reinhard  2 - Filmic(Hejl)
+
+//     brightness: [1, 1, 1, 6],
+
+//     contrast: [1, 1, 1, 1],
+
+//     bias: [1, 1, 1, 0.5],
+
+//     saturation: [1, 1, 1, 1],
+
+
+//     //Sharpen 
+
+//     sharpen: 0,
+
+//     sharpenLimit: 0.23,
+
+
+//     //Bloom
+
+//     bloomColor: [1, 1, 1, 0],
+
+//     bloomSize: 0.0625,
+
+
+//     //Vignette
+
+//     vignette: [0, 0, 0, 0],
+
+//     vignetteCurve: 0,
+
+
+//     //Grain
+
+//     grain: 0.04,
+
+//     grainSharpness: 1,
+
+    
+//     colorLUT: []
+
+// }
+
+// let unifroms = {
+
+//     //Common
+//     uTime: { value: 0 },
+    
+//     //Input
+//     tInput: { value: null },
+    
+//     //Bloom
+//     tBloom: { value: null },
+
+//     //Grain
+//     tGrain: { value: null },
+
+//     //Color LUT
+//     tLUT: { value: null },
+
+//     uScale: { value: new THREE.Vector3 },
+//     uBias: { value: new THREE.Vector3 },
+//     uSaturation: { value : new THREE.Vector3 },
+//     uSharpenKernel: { value: new THREE.Vector4 },
+//     uSharpness: { value: new THREE.Vector3 },
+//     uBloomColor: { value: new THREE.Vector3 },
+//     uVignetteAspect: { value: new THREE.Vector4 },
+//     uVignette: { value: new THREE.Vector4 },
+//     uGrainCoord: { value: new THREE.Vector4 },
+//     uGrainScaleBias: { value: new THREE.Vector2 }
+
+// }
+
+
+// export default class TestPass implements Pass  {
+
+//     enabled: boolean;
+//     needsSwap: boolean;
+//     clear: boolean;
+//     renderToScreen: boolean;
+
+//     fsQuad: Pass.FullScreenQuad
+//     material: THREE.ShaderMaterial;
+
+//     viewSize: THREE.Vector2;
+
+
+//     //Bloom
+
+
+    
+ 
+//     constructor() {
+
+//         this.enabled = true;
+//         this.needsSwap = false;
+//         this.clear = true;
+//         this.renderToScreen = true;
+
+//         this.material = this.generateMaterial();
+//         this.fsQuad = new Pass.FullScreenQuad( this.material );
+
+//         this.viewSize = new THREE.Vector2()
+//     }
+
+
+//     build( parameters: PostEffectParameter ) {
+
+//         let p = this.computerParameters( parameters, this.viewSize.x, this.viewSize.y );
+
+
+//     }
+
+//     private computerParameters( parameters: PostEffectParameter, screenWidth: number, screenHeight: number ) {
+
+//         let b = parameters;
+
+
+//         unifroms.uScale.value.set( parameters.contrast[0] * parameters.contrast[3], parameters.contrast[1] * parameters.contrast[3], parameters.contrast[2] * parameters.contrast[3] );
+//         unifroms.uBias.value.set( parameters.bias[0] * parameters.bias[3], parameters.bias[1] * parameters.bias[3], parameters.bias[2] * parameters.bias[3] );
+//         unifroms.uBias.value.x = -unifroms.uBias.value.x * unifroms.uScale.value.x + unifroms.uBias.value.x;
+//         unifroms.uBias.value.y = -unifroms.uBias.value.y * unifroms.uScale.value.y + unifroms.uBias.value.y;
+//         unifroms.uBias.value.z = -unifroms.uBias.value.z * unifroms.uScale.value.z + unifroms.uBias.value.z;
+        
+        
+//         let brightness = new THREE.Vector3( parameters.brightness[0] * parameters.brightness[3], parameters.brightness[1] * parameters.brightness[3], parameters.brightness[2] * parameters.brightness[3] )
+//         unifroms.uScale.value.x *= brightness.x;
+//         unifroms.uScale.value.y *= brightness.y;
+//         unifroms.uScale.value.z *= brightness.z;
+
+//         unifroms.uBias.value.set( parameters.bias[0] * brightness.x, parameters.bias[1] * brightness.y, parameters.bias[2] * brightness.z );
+        
+         
+//         var e = [b.brightness[0] * b.brightness[3], b.brightness[1] * b.brightness[3], b.brightness[2] * b.brightness[3]];
+//         d.scale = [d.scale[0] * e[0], d.scale[1] * e[1], d.scale[2] * e[2]];
+//         d.bias = [d.bias[0] * e[0], d.bias[1] * e[1], d.bias[2] * e[2]];
+//         d.saturation = [b.saturation[0] * b.saturation[3], b.saturation[1] * b.saturation[3], b.saturation[2] * b.saturation[3]];
+//         d.bloomColor = [b.bloomColor[0] * b.bloomColor[3], b.bloomColor[1] * b.bloomColor[3], b.bloomColor[2] * b.bloomColor[3]];
+//         d.sharpen = [b.sharpen, 0.25 * b.sharpen, b.sharpenLimit];
+//         d.sharpenKernel = [1 / screenWidth, 0, 0, 1 / screenHeight];
+       
+
+
+//         e = screenWidth > screenHeight ? screenWidth : screenHeight;
+       
+//         d.vignetteAspect = [screenWidth / e, screenHeight / e, 0.5 * screenWidth / e, 0.5 * screenHeight / e];
+//         d.vignette = [2 * (1 - b.vignette[0]) * b.vignette[3], 2 * (1 - b.vignette[1]) * b.vignette[3], 2 * (1 - b.vignette[2]) * b.vignette[3], b.vignetteCurve];
+//         var e = 1 / this.noiseTexture.desc.width
+//           , f = 1 / this.noiseTexture.desc.height
+//           , g = 1 - b.grainSharpness;
+//         d.grainCoord = [e * screenWidth, f * screenHeight, 0.5 * g * e, 0.5 * g * f];
+//         d.grainScaleBias = [2 * b.grain, -b.grain];
+
+
+//         return d
+
+//     }
+
+//     private generateMaterial() {
+
+//         let material = new THREE.ShaderMaterial();
+
+//         material.uniforms = unifroms;
+
+//         material.vertexShader = `
+
+//             varying vec2 j;
+
+//             void main() {
+
+//                 j = uv;
+//                 gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+//             }
+
+//         `
+
+//         material.fragmentShader = `
+        
+//             precision mediump float;
+
+//             uniform sampler2D tInput;
+            
+//             #ifdef BLOOM
+//             uniform sampler2D tBloom;
+//             #endif 
+            
+//             #ifdef GRAIN
+//             uniform sampler2D tGrain;
+//             #endif 
+            
+//             #ifdef COLOR_LUT
+//             uniform sampler2D tLUT;
+//             #endif 
+            
+//             uniform vec3 uScale;
+//             uniform vec3 uBias;
+//             uniform vec3 uSaturation;
+//             uniform vec4 uSharpenKernel;
+//             uniform vec3 uSharpness;
+//             uniform vec3 uBloomColor;
+//             uniform vec4 uVignetteAspect;
+//             uniform vec4 uVignette;
+//             uniform vec4 uGrainCoord;
+//             uniform vec2 uGrainScaleBias;
+            
+//             varying vec2 j;
+            
+//             vec3 iY(vec3 c)
+//             {
+//                 vec3 iZ=sqrt(c);
+//                 return(iZ-iZ*c)+c*(0.4672*c+vec3(0.5328));
+//             }
+            
+//             void main(void)
+//             {
+//                 vec4 jc=texture2D(tInput,j);
+//                 vec3 c=jc.xyz;
+            
+//                 #ifdef SHARPEN
+//                 vec3 hM=texture2D(tInput,j+uSharpenKernel.xy).xyz;
+//                 hM+=texture2D(tInput,j-uSharpenKernel.xy).xyz;
+//                 hM+=texture2D(tInput,j+uSharpenKernel.zw).xyz;
+//                 hM+=texture2D(tInput,j-uSharpenKernel.zw).xyz;
+//                 vec3 jd=uSharpness.x*c-uSharpness.y*hM;
+//                 c+=clamp(jd,-uSharpness.z,uSharpness.z);
+//                 #endif 
+            
+//                 #ifdef BLOOM
+//                 c+=uBloomColor*texture2D(tBloom,j).xyz;
+//                 #endif 
+            
+//                 #ifdef VIGNETTE
+//                 vec2 je=j*uVignetteAspect.xy-uVignetteAspect.zw;
+//                 vec3 v=clamp(vec3(1.0,1.0,1.0)-uVignette.xyz*dot(je,je),0.0,1.0);
+//                 vec3 jf=v*v;
+//                 jf*=v;
+//                 c*=mix(v,jf,uVignette.w);
+//                 #endif 
+            
+//                 #ifdef SATURATION
+//                 float gray=dot(c,vec3(0.3,0.59,0.11));
+//                 c=mix(vec3(gray,gray,gray),c,uSaturation);
+//                 #endif 
+            
+//                 #ifdef CONTRAST
+//                 c=c*uScale+uBias;
+//                 #endif 
+            
+//                 #ifdef GRAIN
+//                 float jh=uGrainScaleBias.x*texture2D(tGrain,j*uGrainCoord.xy+uGrainCoord.zw).x+uGrainScaleBias.y;
+//                 c+=c*jh;
+//                 #endif 
+            
+//                 #ifdef REINHARD
+//                 {
+//                     c*=1.8;
+//                     float ji=dot(c,vec3(0.3333));
+//                     c=clamp(c/(1.0+ji),0.0,1.0);
+//                 }
+//                 #elif defined(HEJL)
+//                 {
+//                     const highp float jj=0.22,jk=0.3,jl=.1,jm=0.2,jn=.01,jo=0.3;
+//                     const highp float ju=1.25;
+//                     highp vec3 eO=max(vec3(0.0),c-vec3(.004));
+//                     c=(eO*((ju*jj)*eO+ju*vec3(jl*jk,jl*jk,jl*jk))+ju*vec3(jm*jn,jm*jn,jm*jn))/(eO*(jj*eO+vec3(jk,jk,jk))+vec3(jm*jo,jm*jo,jm*jo))-ju*vec3(jn/jo,jn/jo,jn/jo);
+//                 }
+//                 #elif defined(ACES)
+//                 {
+//                     vec3 a=c*(c+0.0245786)-0.000090537;
+//                     vec3 b=c*(0.983729*c+0.4329510)+0.238081;
+//                     c=a/b;
+//                 }
+//                 #endif 
+            
+//                 #ifdef COLOR_LUT
+//                 c=clamp(c,0.0,1.0);
+//                 c=(255.0/256.0)*c+vec3(0.5/256.0);
+//                 c.x=texture2D(tLUT,c.xx).x;
+//                 c.y=texture2D(tLUT,c.yy).y;
+//                 c.z=texture2D(tLUT,c.zz).z;
+//                 c*=c;
+//                 #endif 
+            
+//                 gl_FragColor.xyz=iY(c);
+//                 gl_FragColor.w=jc.w;
+//             }
+        
+
+//         `
+//         material.needsUpdate = true
+
+//         return material;
+
+//     }
+
+
+//     setSize(width: number, height: number): void {
+//         //throw new Error("Method not implemented.");
+    
+//     }
+//     render(renderer: THREE.WebGLRenderer, writeBuffer: THREE.WebGLRenderTarget, readBuffer: THREE.WebGLRenderTarget, deltaTime: number, maskActive: boolean): void {
+//         //throw new Error("Method not implemented.");
+
+//         renderer.getSize(this.viewSize)        
+//         writeBuffer.setSize(this.viewSize.x, this.viewSize.y);
+//         readBuffer.setSize(this.viewSize.x, this.viewSize.y);
+
+
+//         this.material.uniforms['tInput'].value = readBuffer.texture;
+//         this.material.uniforms['uTime'].value += deltaTime
+
+//         if ( this.renderToScreen ) {
+
+// 			renderer.setRenderTarget( null );
+// 			this.fsQuad.render( renderer );
+
+// 		} else {
+
+// 			renderer.setRenderTarget( writeBuffer );
+
+// 			if ( this.clear ) renderer.clear();
+
+// 			this.fsQuad.render( renderer );
+
+//         }
+        
+
+//     }
+
+    
+// }

+ 7 - 0
src/webgl/posts/index.ts

@@ -0,0 +1,7 @@
+import TestPass from './TestPass'
+
+export {
+
+    TestPass
+    
+}

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 320 - 0
src/webgl/sky/MarmosetSky.ts


+ 44 - 0
src/webgl/textures/MarmosetTexture.ts

@@ -0,0 +1,44 @@
+import * as THREE from 'three'
+
+import { MviewAsset } from '../assets/marmosets/MviewFiles'
+
+class MarmosetTexture extends THREE.Texture {
+
+    constructor() {
+
+        super();
+
+
+    } 
+
+    build( asset: MviewAsset) {
+
+       
+        this.name = asset.name;
+        let image = new Image();
+
+        this.magFilter = THREE.LinearFilter;
+        this.minFilter = THREE.LinearFilter;
+        this.generateMipmaps = true
+        this.anisotropy = 4;
+
+        image.src = URL.createObjectURL(new Blob([new Uint8Array(asset.data)], { type: asset.type }))
+        image.onload = event => {
+
+            this.image = image
+            this.needsUpdate = true;
+            
+        }
+
+        this.premultiplyAlpha = false
+    }
+
+
+    // 1. mipMap  true
+    // 2. aniso   mobile ? 0 : 4
+    // 3. clamp   !!pamarmeter
+    // 4. filter   
+
+}
+
+export default MarmosetTexture

+ 39 - 0
tsconfig.json

@@ -0,0 +1,39 @@
+{
+  "compilerOptions": {
+    "target": "esnext",
+    "module": "esnext",
+    "strict": true,
+    "jsx": "preserve",
+    "importHelpers": true,
+    "moduleResolution": "node",
+    "experimentalDecorators": true,
+    "esModuleInterop": true,
+    "allowSyntheticDefaultImports": true,
+    "sourceMap": true,
+    "baseUrl": ".",
+    "types": [
+      "webpack-env"
+    ],
+    "paths": {
+      "@/*": [
+        "src/*"
+      ]
+    },
+    "lib": [
+      "esnext",
+      "dom",
+      "dom.iterable",
+      "scripthost"
+    ]
+  },
+  "include": [
+    "src/**/*.ts",
+    "src/**/*.tsx",
+    "src/**/*.vue",
+    "tests/**/*.ts",
+    "tests/**/*.tsx"
+  ],
+  "exclude": [
+    "node_modules"
+  ]
+}