Skip to content

Commit

Permalink
feat: add graphic bath mesh (#319)
Browse files Browse the repository at this point in the history
add new prefab data load and parser
add prefab component
add prefab morph animation
close sample prefab debug
add blend shape anim
add animtor split blendShape and skeleton anim
fix animator
add skeleton setting
Add feature of new Bloom Post.
add BitMap
add OrderMap
new Bloom Post
remove repeat field 'format'
fix skeleton world position
fix apath components
fix value parser to comdata
fix graphic update
fix prefab node name
HoverCameraController add flowTarget
Replace old Bloom.
fix blendShape
add new material shader
add LitSSSShader
add navigation mesh path finder.
adapt Navi3DConst value
exclude zero direction of calc navi mesh
Add navi mesh parse action.
add new material framework
add new shader and material pass
fix new skin component clone
fix sample renderer error
add graphic mesh
fix pointlight shadow
fix sphere geometry uv
  • Loading branch information
X-OldGentleMan authored Oct 31, 2023
1 parent d1b79be commit 7df4f95
Show file tree
Hide file tree
Showing 318 changed files with 13,198 additions and 2,908 deletions.
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Orillusion | Samples</title>
<title>Graphic3D | Samples</title>
<style>
html,
body {
Expand Down Expand Up @@ -115,11 +115,11 @@
}
</style>
</head>

<body>
<svg class="toggle" onclick="document.body.classList.add('show')" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M17,11H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h14c0.6,0,1,0.4,1,1S17.6,11,17,11z"></path><path d="M21,7H3C2.4,7,2,6.6,2,6s0.4-1,1-1h18c0.6,0,1,0.4,1,1S21.6,7,21,7z"></path><path d="M21,15H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h18c0.6,0,1,0.4,1,1S21.6,15,21,15z"></path><path d="M17,19H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h14c0.6,0,1,0.4,1,1S17.6,19,17,19z"></path>
</svg>
<script src="https://unpkg.com/peerjs@1.5.0/dist/peerjs.min.js"></script>
<script type="module" src="/samples/index.ts"></script>
</body>
</html>
1 change: 1 addition & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./src/index"
2 changes: 2 additions & 0 deletions packages/debug/GUIHelp.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { GTAOPost } from '../../src/index.js';
import { GUI } from './dat.gui.module.js'

/**
* @internal
*/
class _GUIHelp {

public debug: boolean = false;
public data: any;
public gui: GUI;
Expand Down
3 changes: 3 additions & 0 deletions packages/effect/grass/geometry/GrassGeometry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ export class GrassGeometry extends GeometryBase {
indexCount: indexes.length,
vertexStart: 0,
index: 0,
vertexCount: 0,
firstStart: 0,
topology: 0
});

this.bounds = new BoundingBox(Vector3.ZERO, new Vector3(9999, 9999, 9999));
Expand Down
113 changes: 37 additions & 76 deletions packages/effect/grass/material/GrassMaterial.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BlendMode, Color, GPUAddressMode, Material, RenderShader, RendererType, ShaderLib, Texture, Vector2, Vector3, Vector4 } from "@orillusion/core";
import { BlendMode, Color, GPUAddressMode, Material, RenderShaderPass, PassType, Shader, ShaderLib, Texture, Vector2, Vector3, Vector4 } from "@orillusion/core";
import { GrassShader } from "../shader/GrassShader";
import { GrassVertexAttributeShader } from "../shader/GrassVertexAttributeShader";
import { GrassCastShadowShader } from "../shader/GrassCastShadowShader";
Expand All @@ -7,11 +7,12 @@ export class GrassMaterial extends Material {
constructor() {
super();

let newShader = new Shader();
ShaderLib.register("GrassVertexAttributeShader", GrassVertexAttributeShader);
ShaderLib.register("GrassShader", GrassShader);

let colorPass = new RenderShader(`GrassShader`, `GrassShader`);
this.defaultPass = colorPass;
let colorPass = new RenderShaderPass(`GrassShader`, `GrassShader`);
colorPass.passType = PassType.COLOR;
colorPass.setShaderEntry(`VertMain`, `FragMain`)
colorPass.setDefine("TRANSFORMVERTEX", true);
let shaderState = colorPass.shaderState;
Expand All @@ -21,17 +22,18 @@ export class GrassMaterial extends Material {
shaderState.useLight = true;
shaderState.castShadow = false;
shaderState.blendMode = BlendMode.NONE;
newShader.addRenderPass(colorPass);

ShaderLib.register("GrassCastShadowShader", GrassCastShadowShader);

let shadowPass = new RenderShader(`GrassCastShadowShader`, `GrassCastShadowShader`);
let shadowPass = new RenderShaderPass(`GrassCastShadowShader`, `GrassCastShadowShader`);
shadowPass.passType = PassType.SHADOW
shadowPass.setDefine("USE_ALPHACUT", true);
shadowPass.setDefine("TRANSFORMVERTEX", true);
shadowPass.setShaderEntry(`VertMain`)
shadowPass.shaderState.blendMode = BlendMode.NONE;
shadowPass.shaderState.receiveEnv = false;
this.addPass(RendererType.SHADOW, shadowPass);

newShader.addRenderPass(shadowPass);

colorPass.setUniformColor("baseColor", new Color(0.0, 1.0, 0.0, 1.0));
colorPass.setUniformColor("grassBottomColor", new Color(3 / 255, 16 / 255, 3 / 255));
Expand Down Expand Up @@ -67,159 +69,118 @@ export class GrassMaterial extends Material {
// this.baseMap = Engine3D.res.whiteTexture;
colorPass.doubleSide = true;
shadowPass.doubleSide = true;

this.shader = newShader;
}

public set baseMap(texture: Texture) {
// texture.visibility = GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT;
let shadowPass = this.getPass(RendererType.SHADOW)[0];

this.defaultPass.setTexture(`baseMap`, texture);
shadowPass.setTexture(`baseMap`, texture);
this.shader.setTexture(`baseMap`, texture);
}

public get baseMap(): Texture {
return this.defaultPass.getTexture(`baseMap`);
return this.shader.getTexture(`baseMap`);
}

public set windMap(texture: Texture) {
// texture.visibility = GPUShaderStage.VERTEX;
texture.addressModeU = GPUAddressMode.repeat;
texture.addressModeV = GPUAddressMode.repeat;
this.defaultPass.setTexture("windMap", texture);
let shadowPass = this.getPass(RendererType.SHADOW)[0];

shadowPass.setTexture("windMap", texture);
this.shader.setTexture("windMap", texture);
}

public set windBound(v: Vector4) {
this.defaultPass.setUniformVector4("windBound", v);
let shadowPass = this.getPass(RendererType.SHADOW)[0];

this.defaultPass.setUniformVector4("windBound", v);
shadowPass.setUniformVector4("windBound", v);
this.shader.setUniformVector4("windBound", v);
}

public get windBound(): Vector4 {
return this.defaultPass.uniforms["windBound"].vector4;
return this.shader.getUniform("windBound").data;
}

public set grassBaseColor(v: Color) {
this.defaultPass.setUniformColor("grassBottomColor", v);
let shadowPass = this.getPass(RendererType.SHADOW)[0];
shadowPass.setUniformColor("grassBottomColor", v);
this.shader.setUniformColor("grassBottomColor", v);
}

public get grassBaseColor(): Color {
return this.defaultPass.uniforms["grassBottomColor"].color;
return this.shader.getUniformColor("grassBottomColor");
}

public set grassTopColor(v: Color) {
this.defaultPass.setUniformColor("grassTopColor", v);
let shadowPass = this.getPass(RendererType.SHADOW)[0];

shadowPass.setUniformColor("grassTopColor", v);
this.shader.setUniformColor("grassTopColor", v);
}

public get grassTopColor(): Color {
return this.defaultPass.uniforms["grassTopColor"].color;
return this.shader.getUniformColor("grassTopColor");
}

public set windDirection(v: Vector2) {
this.defaultPass.setUniformVector2("windDirection", v);
let shadowPass = this.getPass(RendererType.SHADOW)[0];

shadowPass.setUniformVector2("windDirection", v);
this.shader.setUniformVector2("windDirection", v);
}

public get windDirection(): Vector2 {
return this.defaultPass.uniforms["windDirection"].vector2;
return this.shader.getUniform("windDirection").data;
}

public set windPower(v: number) {
this.defaultPass.setUniformFloat("windPower", v);
let shadowPass = this.getPass(RendererType.SHADOW)[0];

shadowPass.setUniformFloat("windPower", v);
this.shader.setUniformFloat("windPower", v);
}

public get windPower(): number {
return this.defaultPass.uniforms["windPower"].data;
return this.shader.getUniform("windPower").data;
}

public set windSpeed(v: number) {
this.defaultPass.setUniformFloat("windSpeed", v);
let shadowPass = this.getPass(RendererType.SHADOW)[0];

shadowPass.setUniformFloat("windSpeed", v);
this.shader.setUniformFloat("windSpeed", v);
}

public get windSpeed(): number {
return this.defaultPass.uniforms["windSpeed"].data;
return this.shader.getUniform("windSpeed").data;
}

public set grassHeight(v: number) {
this.defaultPass.setUniformFloat("grassHeight", v);
let shadowPass = this.getPass(RendererType.SHADOW)[0];

shadowPass.setUniformFloat("grassHeight", v);
this.shader.setUniformFloat("grassHeight", v);
}

public get grassHeight(): number {
return this.defaultPass.uniforms["grassHeight"].data;
return this.shader.getUniform("grassHeight").data;
}

public set curvature(v: number) {
this.defaultPass.setUniformFloat("curvature", v);
let shadowPass = this.getPass(RendererType.SHADOW)[0];

shadowPass.setUniformFloat("curvature", v);
this.shader.setUniformFloat("curvature", v);
}

public get curvature(): number {
return this.defaultPass.uniforms["curvature"].data;
return this.shader.getUniform("curvature").data;
}

public set roughness(v: number) {
this.defaultPass.setUniformFloat("roughness", v);
let shadowPass = this.getPass(RendererType.SHADOW)[0];

shadowPass.setUniformFloat("roughness", v);
this.shader.setUniformFloat("roughness", v);
}

public get roughness(): number {
return this.defaultPass.uniforms["roughness"].data;
return this.shader.getUniform("roughness").data;
}

public set translucent(v: number) {
this.defaultPass.setUniformFloat("translucent", v);
let shadowPass = this.getPass(RendererType.SHADOW)[0];

shadowPass.setUniformFloat("translucent", v);
this.shader.setUniformFloat("translucent", v);
}

public get translucent(): number {
return this.defaultPass.uniforms["translucent"].data;
return this.shader.getUniform("translucent").data;
}

public set soft(v: number) {
this.defaultPass.setUniformFloat("soft", v);
let shadowPass = this.getPass(RendererType.SHADOW)[0];

shadowPass.setUniformFloat("soft", v);
this.shader.setUniformFloat("soft", v);
}

public get soft(): number {
return this.defaultPass.uniforms["soft"].data;
return this.shader.getUniform("soft").data;
}

public set specular(v: number) {
this.defaultPass.setUniformFloat("specular", v);
let shadowPass = this.getPass(RendererType.SHADOW)[0];

shadowPass.setUniformFloat("specular", v);
this.shader.setUniformFloat("specular", v);
}

public get specular(): number {
return this.defaultPass.uniforms["specular"].data;
return this.shader.getUniform("specular").data;
}
}
1 change: 1 addition & 0 deletions packages/effect/grass/shader/GrassCastShadowShader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export let GrassCastShadowShader = /* wgsl */`
var windMap: texture_2d<f32>;
const DEGREES_TO_RADIANS : f32 = 3.1415926 / 180.0 ;
const PI : f32 = 3.1415926 ;
@vertex
fn VertMain( vertex:VertexAttributes ) -> VertexOutput {
Expand Down
1 change: 1 addition & 0 deletions packages/effect/grass/shader/GrassShader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export let GrassShader = /* wgsl */`
var windMap: texture_2d<f32>;
const DEGREES_TO_RADIANS : f32 = 3.1415926 / 180.0 ;
const PI : f32 = 3.1415926 ;
@vertex
fn VertMain( vertex:VertexAttributes ) -> VertexOutput {
Expand Down
4 changes: 2 additions & 2 deletions packages/media-extention/ChromaKeyMaterial.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Engine3D, ShaderLib, Vector4, Color, BlendMode, registerMaterial, Material, RenderShader, Texture } from "@orillusion/core";
import { Engine3D, ShaderLib, Vector4, Color, BlendMode, registerMaterial, Material, RenderShaderPass, Texture } from "@orillusion/core";
import { ChromaKeyShader } from "./ChromaKeyShader";

/**
Expand All @@ -14,7 +14,7 @@ export class ChromaKeyMaterial extends Material {
super();

ShaderLib.register("ChromaKeyShader", ChromaKeyShader);
this.defaultPass = new RenderShader(
this.defaultPass = new RenderShaderPass(
`ChromaKeyShader`,
`ChromaKeyShader`
);
Expand Down
4 changes: 2 additions & 2 deletions packages/media-extention/ImageMaterial.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Engine3D, ShaderLib, Vector4, Color, Texture, Material, RenderShader } from "@orillusion/core";
import { Engine3D, ShaderLib, Vector4, Color, Texture, Material, RenderShaderPass } from "@orillusion/core";
import ImageMaterialShader from "./ImageMaterialShader.wgsl?raw";


Expand All @@ -15,7 +15,7 @@ export class ImageMaterial extends Material {
constructor() {
super();
ShaderLib.register("ImageMaterialShader", ImageMaterialShader);
this.defaultPass = new RenderShader(`ImageMaterialShader`, `ImageMaterialShader`);
this.defaultPass = new RenderShaderPass(`ImageMaterialShader`, `ImageMaterialShader`);
this.defaultPass.setShaderEntry(`VertMain`, `FragMain`)
this.defaultPass.setUniformVector4(`transformUV1`, new Vector4(0, 0, 1, 1));
this.defaultPass.setUniformVector4(`transformUV2`, new Vector4(0, 0, 1, 1));
Expand Down
Loading

0 comments on commit 7df4f95

Please sign in to comment.