Skip to content

Commit

Permalink
Merge v0.7.1
Browse files Browse the repository at this point in the history
## [0.7.1](v0.7.0...v0.7.1) (2023-11-14)


### Bug Fixes

* Auto sort transparent renderers. ([#318](#318)) ([5becdc4](5becdc4))
* fix: load gltf sample
* fix: fix grass sample
* fix: fix media-extention material
* fix: fix post sample resize bug
* fix: fix csm shadow
* fix: Cancel automatic resizing of rendertexture in GI
* fix: Wrong offset for bloom
* fix: reduce texture sample times
* fix: texture Count Exceeded the maximum limit of 7

### Features
* **engine:** enable gpu attachments texture auto resize
* **graphic:** add new graphic samples
* **sample:** update physics car sample ([#327](#327)) ([e09b243](e09b243))
  • Loading branch information
lslzl3000 committed Nov 20, 2023
2 parents 9d304b1 + 2fc6f27 commit f4402e3
Show file tree
Hide file tree
Showing 115 changed files with 3,238 additions and 565 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
## [0.7.1](https://github.com/Orillusion/orillusion/compare/v0.7.0...v0.7.1) (2023-11-14)


### Bug Fixes

* Auto sort transparent renderers. ([#318](https://github.com/Orillusion/orillusion/issues/318)) ([5becdc4](https://github.com/Orillusion/orillusion/commit/5becdc48739e4ce7745d15a60c46612f991ae5f2))
* fix: load gltf sample
* fix: fix grass sample
* fix: fix media-extention material
* fix: fix post sample resize bug
* fix: fix csm shadow
* fix: Cancel automatic resizing of rendertexture in GI
* fix: Wrong offset for bloom
* fix: reduce texture sample times
* fix: texture Count Exceeded the maximum limit of 7

### Features
* **engine:** enable gpu attachments texture auto resize
* **graphic:** add new graphic samples
* **sample:** update physics car sample ([#327](https://github.com/Orillusion/orillusion/issues/327)) ([e09b243](https://github.com/Orillusion/orillusion/commit/e09b24386bb517d1277e00dcaa4105999d2dd856))



# [0.7.0](https://github.com/Orillusion/orillusion/compare/v0.6.9...v0.7.0) (2023-11-01)


Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orillusion/core",
"version": "0.7.0",
"version": "0.7.1",
"author": "Orillusion",
"description": "Orillusion WebGPU Engine",
"main": "./dist/orillusion.umd.js",
Expand Down Expand Up @@ -31,7 +31,7 @@
"dev": "vite",
"build": "tsc --p tsconfig.build.json && vite build && npm run build:types && npm run minify",
"build:test": "tsc --p tsconfig.build.json && vite build",
"build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json && mv dist/src dist/types",
"build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json && rm -rf dist/packages && mv dist/src dist/types",
"minify": "./node_modules/vite/node_modules/.bin/esbuild dist/orillusion.es.max.js --minify --outfile=dist/orillusion.es.js && ./node_modules/vite/node_modules/.bin/esbuild dist/orillusion.umd.max.js --minify --outfile=dist/orillusion.umd.js",
"test": "electron test/ci/main.js",
"test:ci": "xvfb-maybe -- electron --enable-unsafe-webgpu --enable-features=Vulkan --use-vulkan=swiftshader --use-webgpu-adapter=swiftshader --no-sandbox test/ci/main.js",
Expand Down
17 changes: 9 additions & 8 deletions packages/effect/grass/shader/GrassVertexAttributeShader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ export let GrassVertexAttributeShader: string = /*wgsl*/ `
}
struct VertexOutput {
@location(0) varying_UV0: vec2<f32>,
@location(1) varying_UV1: vec2<f32>,
@location(2) varying_ViewPos: vec4<f32>,
@location(3) varying_Clip: vec4<f32>,
@location(4) varying_WPos: vec4<f32>,
@location(5) varying_WNormal: vec3<f32>,
@location(6) varying_Color: vec4<f32>,
@location(0) index: f32,
@location(1) varying_UV0: vec2<f32>,
@location(2) varying_UV1: vec2<f32>,
@location(3) varying_ViewPos: vec4<f32>,
@location(4) varying_Clip: vec4<f32>,
@location(5) varying_WPos: vec4<f32>,
@location(6) varying_WNormal: vec3<f32>,
@location(7) varying_Color: vec4<f32>,
#if USE_SHADOWMAPING
@location(7) varying_ShadowPos: vec4<f32>,
@location(8) varying_ShadowPos: vec4<f32>,
#endif
@builtin(position) member: vec4<f32>
};
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orillusion/effect",
"version": "0.1.1",
"version": "0.1.2",
"author": "Orillusion",
"description": "Orillusion Effects Plugin",
"main": "./dist/effect.umd.js",
Expand Down
3 changes: 2 additions & 1 deletion samples/base/Sample_Destroy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ class Sample_Destroy {
GUIHelp.addButton("del", () => {
for (let i = 0; i < list.length; i++) {
const obj = list[i];
obj.destroy();
obj.destroy(true);
}
list.length = 0;
});
GUIHelp.open()
}
Expand Down
23 changes: 10 additions & 13 deletions samples/ext/Sample_Grass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ export class Sample_Grass {

Engine3D.startRenderView(this.view);

this.post = this.view.scene.addComponent(PostProcessingComponent);
let fxaa = this.post.addPost(FXAAPost);
let fog = this.post.addPost(GlobalFog);
fog.fogColor = new Color(136 / 255, 215 / 255, 236 / 255, 1);
fog.start = 0;
fog.overrideSkyFactor = 0.0764;
fog.ins = 1;
fog.falloff = 0.626;
fog.scatteringExponent = 3;
fog.dirHeightLine = 10;
// this.post = this.view.scene.addComponent(PostProcessingComponent);
// let fxaa = this.post.addPost(FXAAPost);
// let fog = this.post.addPost(GlobalFog);
// fog.fogColor = new Color(136 / 255, 215 / 255, 236 / 255, 1);
// fog.start = 0;
// fog.overrideSkyFactor = 0.0764;
// fog.ins = 1;
// fog.falloff = 0.626;
// fog.scatteringExponent = 3;
// fog.dirHeightLine = 10;
// post.addPost(TAAPost);

this.createScene(this.view.scene);
Expand Down Expand Up @@ -148,9 +148,6 @@ export class Sample_Grass {
// GUIHelp.addFolder("shadow");
// GUIHelp.add(Engine3D.setting.shadow, "shadowBound", 0.0, 3000, 0.0001);
// GUIHelp.endFolder();

let globalFog = this.post.getPost(GlobalFog);
// GUIUtil.renderFog(globalFog);
}

}
Expand Down
4 changes: 2 additions & 2 deletions samples/graphic/Sample_GraphicLine.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { createExampleScene, createSceneParam } from "@samples/utils/ExampleScene";
import { Object3D, Scene3D, Engine3D, GlobalIlluminationComponent, Object3DUtil, GTAOPost, PostProcessingComponent, TAAPost, Vector3, Color, AnimationCurve, Keyframe } from "@orillusion/core";
import { Scene3D, Engine3D, Vector3, Color, AnimationCurve, Keyframe, View3D } from "@orillusion/core";
import { GUIUtil } from "@samples/utils/GUIUtil";
import { GUIHelp } from "@orillusion/debug/GUIHelp";

class Sample_GraphicLine {
scene: Scene3D;
view: import("c:/work/git/orillusion-nian/src/index").View3D;
view: View3D;
async run() {

Engine3D.setting.material.materialChannelDebug = true;
Expand Down
2 changes: 1 addition & 1 deletion samples/graphic/Sample_GraphicMeshWave.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GUIHelp } from "@orillusion/debug/GUIHelp";
import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, LitMaterial, MeshRenderer, BoxGeometry, SphereGeometry, VirtualTexture, GPUTextureFormat, UnLitMaterial, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Graphic3DMesh, Matrix4, Time, BlendMode, PrefabParser } from "@orillusion/core";
import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Graphic3DMesh, Matrix4, Time, BlendMode, PrefabParser } from "@orillusion/core";
import { GUIUtil } from "@samples/utils/GUIUtil";
import { Stats } from "@orillusion/stats";

Expand Down
2 changes: 1 addition & 1 deletion samples/graphic/Sample_GraphicMesh_0.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GUIHelp } from "@orillusion/debug/GUIHelp";
import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, LitMaterial, MeshRenderer, BoxGeometry, SphereGeometry, VirtualTexture, GPUTextureFormat, UnLitMaterial, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Graphic3DMesh, Matrix4, Time, BlendMode } from "@orillusion/core";
import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Graphic3DMesh, Matrix4, Time, BlendMode } from "@orillusion/core";
import { GUIUtil } from "@samples/utils/GUIUtil";
import { Stats } from "@orillusion/stats";

Expand Down
2 changes: 1 addition & 1 deletion samples/graphic/Sample_GraphicMesh_1.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GUIHelp } from "@orillusion/debug/GUIHelp";
import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, LitMaterial, MeshRenderer, BoxGeometry, SphereGeometry, VirtualTexture, GPUTextureFormat, UnLitMaterial, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Graphic3DMesh, Matrix4, Time, BlendMode, Color } from "@orillusion/core";
import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Graphic3DMesh, Matrix4, Time, BlendMode, Color } from "@orillusion/core";
import { GUIUtil } from "@samples/utils/GUIUtil";
import { Stats } from "@orillusion/stats";

Expand Down
2 changes: 1 addition & 1 deletion samples/graphic/Sample_GraphicMesh_2.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GUIHelp } from "@orillusion/debug/GUIHelp";
import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, LitMaterial, MeshRenderer, BoxGeometry, SphereGeometry, VirtualTexture, GPUTextureFormat, UnLitMaterial, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Graphic3DMesh, Matrix4, Time, BlendMode } from "@orillusion/core";
import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Graphic3DMesh, Matrix4, Time, BlendMode } from "@orillusion/core";
import { GUIUtil } from "@samples/utils/GUIUtil";
import { Stats } from "@orillusion/stats";

Expand Down
2 changes: 1 addition & 1 deletion samples/graphic/Sample_GraphicMesh_3.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GUIHelp } from "@orillusion/debug/GUIHelp";
import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, LitMaterial, MeshRenderer, BoxGeometry, SphereGeometry, VirtualTexture, GPUTextureFormat, UnLitMaterial, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Graphic3DMesh, Matrix4, Time, BlendMode, PrefabParser } from "@orillusion/core";
import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, MeshRenderer, UnLitTexArrayMaterial, BitmapTexture2DArray, Vector3, Graphic3DMesh, Matrix4, Time, PrefabParser } from "@orillusion/core";
import { GUIUtil } from "@samples/utils/GUIUtil";
import { Stats } from "@orillusion/stats";

Expand Down
172 changes: 172 additions & 0 deletions samples/graphic/Sample_MeshLines.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
import { Engine3D, Scene3D, CameraUtil, HoverCameraController, Object3D, MeshRenderer, View3D, PlaneGeometry, UnLitMaterial, Color, Vector3, PointerEvent3D, Camera3D, SphereGeometry, CylinderGeometry, MathUtil, BlendMode, GPUCullMode } from '@orillusion/core';
import * as dat from "@orillusion/debug/dat.gui.module";
import { Stats } from '@orillusion/stats';

class Sample_MeshLines {
private onDraw: boolean = false
private scene: Scene3D
private camera: Camera3D
private lastTime: number
private path: Object3D[] = []
private hoverCameraController: HoverCameraController;
private lastX: number = -1
private lastY: number = -1
private pointGeometry: SphereGeometry
private lineGeometry: CylinderGeometry
private material: UnLitMaterial

public lineWidth: number = 0.1
public drawInterval: number = 30
public precision: number = 32
public depth: number = 0
public lineColor: Color = new Color(1, 0, 0)

async run() {
// init engine
await Engine3D.init();
// create new Scene
let scene = new Scene3D();
scene.addComponent(Stats)
this.scene = scene;

// init camera3D
let mainCamera = CameraUtil.createCamera3D(null, scene);
mainCamera.perspective(60, Engine3D.aspect, 1, 2000.0);

// add a basic camera controller
this.hoverCameraController = mainCamera.object3D.addComponent(HoverCameraController);
this.hoverCameraController.setCamera(0, 0, 20)

this.camera = mainCamera

this.pointGeometry = new SphereGeometry(0.5, 32, 32)
this.lineGeometry = new CylinderGeometry(0.5, 0.5, 1, 32, 32)
this.material = new UnLitMaterial()
this.material.baseColor = this.lineColor

// add basic plane
let plane = new Object3D();
let mr = plane.addComponent(MeshRenderer);
mr.geometry = new PlaneGeometry(20, 20, 1, 1, Vector3.Z_AXIS);
let mat = new UnLitMaterial()
mat.baseColor = new Color(1, 1, 1, 0.4)
mat.transparent = true
mat.cullMode = GPUCullMode.none
mat.blendMode = BlendMode.NORMAL
mr.material = mat;
scene.addChild(plane);

// create a view with target scene and camera
let view = new View3D();
view.scene = scene;
view.camera = mainCamera;

// start render
Engine3D.startRenderView(view);

Engine3D.inputSystem.addEventListener(PointerEvent3D.POINTER_DOWN, this.onMouseDown, this, null, 999);
Engine3D.inputSystem.addEventListener(PointerEvent3D.POINTER_MOVE, this.onMouseMove, this);
Engine3D.inputSystem.addEventListener(PointerEvent3D.POINTER_UP, this.onMouseUp, this);

// debug GUI
let gui = new dat.GUI();
let f = gui.addFolder('Orillusion');
f.add(this, 'lineWidth', 0.1, 2, 0.1);
f.add(this, 'precision', 4, 64, 1).onChange((precision) => {
this.lineGeometry = new CylinderGeometry(0.5, 0.5, 1, precision, precision)
this.pointGeometry = new SphereGeometry(0.5, precision, precision)
});
f.add(this, 'depth', -1, 1, 0.01);
f.add(this, 'drawInterval', 15, 100, 1);
f.addColor({lineColor: Object.values(this.lineColor).map((v,i)=> i === 3 ? v : v*255)}, 'lineColor').onChange(v=>{
this.lineColor = new Color(v[0]/255, v[1]/255, v[2]/255, v[3])
this.material = new UnLitMaterial()
this.material.baseColor = this.lineColor
});
f.add({'resetView': () => this.hoverCameraController.setCamera(0, 0, 20)}, 'resetView')
f.add({'clearCanvas': () => {
this.path.map((point) => {
this.scene.removeChild(point)
})
this.path.length = 0
}}, 'clearCanvas')
f.open()

// add tips
gui.add({tips: 'Press to rotate camera'}, 'tips').name('Left Mouse')
gui.add({tips: 'Press to draw lines'}, 'tips').name('Right Mouse')
}

onMouseDown(e: PointerEvent3D) {
if(e.mouseCode === 2) {
e.stopImmediatePropagation()
this.lastTime = Date.now()
this.onDraw = true;
this.drawPoint(e.mouseX, e.mouseY);
this.lastX = e.mouseX;
this.lastY = e.mouseY;
}
}

onMouseMove(e: PointerEvent3D) {
if (!this.onDraw) return;
e.stopImmediatePropagation()
const now = Date.now();
if (now - this.lastTime > this.drawInterval) {
this.drawLine(e.mouseX, e.mouseY);
this.drawPoint(e.mouseX, e.mouseY);
this.lastTime = now;
this.lastX = e.mouseX
this.lastY = e.mouseY
}
}

onMouseUp(e: PointerEvent3D) {
this.onDraw = false;
this.lastX = -1;
this.lastY = -1;
}

drawPoint(x: number, y: number) {
let point = new Object3D();
let mr = point.addComponent(MeshRenderer);
mr.geometry = this.pointGeometry;
mr.material = this.material;
point.scaleX = point.scaleY = point.scaleZ = this.lineWidth
this.camera.worldToScreenPoint(this.hoverCameraController.target, Vector3.HELP_0)
const pos = this.camera.screenPointToWorld(x, y, Vector3.HELP_0.z + this.depth / 100);
point.x = pos.x;
point.y = pos.y;
point.z = pos.z;
this.path.push(point);
this.scene.addChild(point);
}

drawLine(x: number, y: number) {
this.camera.worldToScreenPoint(this.hoverCameraController.target, Vector3.HELP_0)
const start = this.camera.screenPointToWorld(this.lastX, this.lastY, Vector3.HELP_0.z + this.depth / 100);
const end = this.camera.screenPointToWorld(x, y, Vector3.HELP_0.z);
const distance = Math.sqrt(end.distanceToSquared(start))
let line = new Object3D();
let mr = line.addComponent(MeshRenderer);
mr.geometry = this.lineGeometry;
mr.material = this.material;
line.scaleX = line.scaleZ = this.lineWidth;
line.scaleY = distance;
line.x = start.x + (end.x - start.x) / 2;
line.y = start.y + (end.y - start.y) / 2;
line.z = start.z + (end.z - start.z) / 2;

// normalize the direction vector
const dir = Vector3.HELP_1.set(end.x - start.x, end.y - start.y, end.z - start.z).normalize()
const rot = MathUtil.fromToRotation(Vector3.Y_AXIS, dir)
// make sure the rotation is valid
if (!Number.isNaN(rot.x) && !Number.isNaN(rot.y) && !Number.isNaN(rot.z)) {
line.transform.localRotQuat = rot;
}
this.path.push(line);
this.scene.addChild(line);
}
}

new Sample_MeshLines().run()
Loading

0 comments on commit f4402e3

Please sign in to comment.