-
Notifications
You must be signed in to change notification settings - Fork 622
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(GBuff): compressed GBuff data. (#412)
* feat: v0.8 add reflection renderer add reflection sphere add ibl specular add ibl diffuse add lun light add graphic fix shadow back fix passType fix light parameters. fix blend mode. fix Resize Context3D. fix Csm shadow bias. Fix: Sample of Grass. Sample of SpotLight. fix ibl diffuse use SH Fix: Gtao Fix: remove SH color. --------- Co-authored-by: ZenderJK <vvn.plus.site@gmail.com> Co-authored-by: ShuangLiu <liu.shuang@huasheng.io>
- Loading branch information
1 parent
7b2169d
commit 4649add
Showing
288 changed files
with
10,146 additions
and
2,624 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export let GrassAnimCompute_cs = /*wgsl*/` | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
export let GrassGeometryCompute_cs = /*wgsl*/` | ||
struct GrassNode { | ||
grassCount: f32, | ||
grassHSegment: f32, | ||
grassWight: f32, | ||
grassHeigh: f32, | ||
grassX: f32, | ||
grassY: f32, | ||
grassZ: f32, | ||
grassRotation: f32 | ||
} | ||
@group(0) @binding(3) var<storage, read> nodeBuffer : array<GrassNode> ; | ||
var<private> zero_pos : vec3f = vec3f(0.0,0.0,0.0); | ||
var<private> zero_uv : vec2f = vec2f(0.0,0.0); | ||
fn compute(workgroup_id:vec3<u32>,local_invocation_id:vec3<u32>) { | ||
// Grass geometry compute code goes here | ||
var time = globalUniform.time * 0.005; | ||
let globalIndex = workgroup_id.x * 256u + local_invocation_id.x ; | ||
if(globalIndex < drawBuffer.skipFace2 * 12u){ | ||
// if(globalIndex == 0u){ | ||
// } | ||
let nodeInfo = nodeBuffer[globalIndex]; | ||
let posWs = vec3f(nodeInfo.grassX, nodeInfo.grassY, nodeInfo.grassZ) ; | ||
if(IsOutofFrustum(posWs.xyz,0.1)){ | ||
// drawCube(globalIndex,posWs,nodeInfo.grassWight,nodeInfo.grassWight,nodeInfo.grassWight,0.0,time,0.0); | ||
let mat = buildYRotateXMat4(nodeInfo.grassRotation,posWs.x, posWs.y, posWs.z); | ||
let vertexOffset = vec4f(sin(time + f32(local_invocation_id.x) / 16.0 ) ,0.0,0.0,0.0); | ||
let width = nodeInfo.grassWight * 0.5 ; | ||
let height = nodeInfo.grassHeigh * 0.5 ; | ||
// var p0 = (mat * vec4f(-width, height, 0.0,1.0)) + vertexOffset; | ||
// var p1 = (mat * vec4f(width, height, 0.0,1.0)) + vertexOffset; | ||
// var p2 = mat * vec4f(width, 0.0, 0.0,1.0) ; | ||
// var p3 = mat * vec4f(-width, 0.0, 0.0,1.0) ; | ||
// let u0 = vec2f(0.0, 0.0); | ||
// let u1 = vec2f(1.0, 0.0); | ||
// let u2 = vec2f(1.0, 1.0); | ||
// let u3 = vec2f(0.0, 1.0); | ||
// drawFace(globalIndex,p0.xyz,p1.xyz,p2.xyz,u0,u1,u2); | ||
// drawFace(globalIndex,p0.xyz,p2.xyz,p3.xyz,u0,u2,u3); | ||
var p0 = (mat * vec4f(width * 0.5, height, 0.0,1.0)) + vertexOffset; | ||
var p1 = (mat * vec4f(-width, 0.0, 0.0,1.0)) ;// + vertexOffset; | ||
var p2 = mat * vec4f(width, 0.0, 0.0,1.0) ; | ||
let u0 = vec2f(0.5, 0.0); | ||
let u1 = vec2f(1.0, 1.0); | ||
let u2 = vec2f(0.0, 1.0); | ||
drawFace(globalIndex,p0.xyz,p1.xyz,p2.xyz,u0,u1,u2); | ||
}else{ | ||
// drawCube(globalIndex,zero_pos,0.0,0.0,0.0,0.0,0.0,0.0); | ||
drawFace(globalIndex,zero_pos,zero_pos,zero_pos,zero_uv,zero_uv,zero_uv); | ||
} | ||
} | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
import { ComputeShader, DynamicDrawStruct, DynamicFaceRenderer, Struct, graphicDynamicCompute } from "@orillusion/core"; | ||
import { GrassGeometryCompute_cs } from "../compute/grass/GrassGeometryCompute_cs"; | ||
|
||
export class GrassNodeStruct extends DynamicDrawStruct { | ||
grassCount: number = 1; | ||
grassHSegment: number = 1; | ||
grassWight: number = 2; | ||
grassHeigh: number = 4; | ||
grassX: number = 0; | ||
grassY: number = 0; | ||
grassZ: number = 0; | ||
grassRotation: number = 0; | ||
} | ||
|
||
export class GrassRenderer extends DynamicFaceRenderer { | ||
grassGeometryCompute: ComputeShader; | ||
|
||
constructor() { | ||
super(); | ||
} | ||
|
||
public init(param?: any): void { | ||
super.init(param); | ||
} | ||
|
||
protected createComputeKernel(): void { | ||
console.log("createComputeKernel"); | ||
|
||
|
||
this.grassGeometryCompute = new ComputeShader(graphicDynamicCompute(GrassGeometryCompute_cs)); | ||
this.grassGeometryCompute.workerSizeX = Math.floor(this.maxNodeCount / 256) + 1; | ||
// this._onStartKernel.push(this.grassGeometryCompute); | ||
this._onFrameKernelGroup.push(this.grassGeometryCompute); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,4 @@ export default defineConfig({ | |
} | ||
} | ||
} | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.