Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open shader core API by ShaderLab #274

Merged
merged 92 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 82 commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
4555409
fix: multi material error
zhuxudong Apr 9, 2024
2083f73
feat: refactor fog
zhuxudong Apr 24, 2024
f7000ef
refactor: init input
zhuxudong Apr 24, 2024
b5537a3
refactor: shadow and shadow fade
zhuxudong Apr 25, 2024
4f52bb1
refactor: delete shadow file
zhuxudong Apr 25, 2024
4277188
refactor: delete shader chunks
zhuxudong Apr 25, 2024
6f1bb85
refactor: init shading_pbr
zhuxudong Apr 25, 2024
9de2d4a
refactor: init ibl and radiance
zhuxudong Apr 25, 2024
f9fa541
refactor: init surfaceData.glsl
zhuxudong Apr 25, 2024
6528327
refactor: init temp
zhuxudong Apr 26, 2024
ac62e5a
refactor: init surfaceData
zhuxudong Apr 26, 2024
271ab34
refactor: delete reflected light
zhuxudong Apr 26, 2024
46b29f0
refactor: delete inner varyings
zhuxudong Apr 26, 2024
2aeb827
refactor: enhance ibl function
zhuxudong Apr 29, 2024
b77eedc
perf: enhance anisotropy
zhuxudong Apr 29, 2024
a0b9812
refactor: lobe
zhuxudong Apr 30, 2024
9f1b534
refactor: rename
zhuxudong Apr 30, 2024
91e1b69
fix: test #define bug
zhuxudong Apr 30, 2024
cff36bc
refactor: avoid repeat include
zhuxudong Apr 30, 2024
c1a8901
refactor: perf code
zhuxudong May 6, 2024
f2b8a00
refactor: move register function
zhuxudong May 8, 2024
f51f874
refactor: create shader
zhuxudong May 8, 2024
008bb2d
chore: support thin material demo
zhuxudong May 8, 2024
d249f37
chore: merge error
zhuxudong May 8, 2024
0f7e615
"v0.0.0-experimental-shaderlab.0"
zhuxudong May 10, 2024
1825da4
"v0.0.0-experimental-shaderlab-thin.0"
zhuxudong May 10, 2024
073f951
Revert ""v0.0.0-experimental-shaderlab.0""
zhuxudong May 10, 2024
db9703f
refactor: prettier editor props
zhuxudong May 11, 2024
640fddd
refactor: prettier editor props
zhuxudong May 11, 2024
480b43d
refactor: change default value
zhuxudong May 11, 2024
1d8a2bb
"v0.0.0-experimental-shaderlab-thin.1"
zhuxudong May 11, 2024
4005483
refactor: code enhance
zhuxudong May 14, 2024
702a574
fix: shader error
zhuxudong May 14, 2024
d850b70
enhance: split surface init
zhuxudong May 14, 2024
19dd765
Merge branch 'refactor/pbr-shaderlab' into refactor/thin-shader
zhuxudong May 14, 2024
0c50d1a
refactor: new api
zhuxudong May 14, 2024
0d455e8
chore: move pass
zhuxudong May 17, 2024
5189541
chore: lowercase to uppercase
zhuxudong May 17, 2024
022a9f2
chore: remove shadingPBR.glsl
zhuxudong May 17, 2024
4326a2e
Merge branch 'refactor/pbr-shaderlab' into refactor/thin-shader
zhuxudong May 17, 2024
8c8bdfb
"v0.0.0-experimental-shaderlab-thin.2"
zhuxudong May 17, 2024
24b96a6
refactor: add brdfData to enable modify surfaceData
zhuxudong Jun 12, 2024
c3bd539
"v0.0.0-experimental-shaderlab-thin.3"
zhuxudong Jun 12, 2024
93161ae
refactor: delete brdfData.tbn
zhuxudong Jun 13, 2024
9285572
"v0.0.0-experimental-shaderlab-thin.4"
zhuxudong Jun 13, 2024
bb48d43
refactor: init geometry data to surfaceData
zhuxudong Jun 14, 2024
dbf5d2d
"v0.0.0-experimental-shaderlab-thin.5"
zhuxudong Jun 14, 2024
26a48cf
refactor: change tangent logic
zhuxudong Jun 18, 2024
190609d
"v0.0.0-experimental-shaderlab-thin.6"
zhuxudong Jun 18, 2024
412549e
refactor: delete thin shader
zhuxudong Jun 24, 2024
4f2f373
perf: enhance code
zhuxudong Jun 24, 2024
9e07c00
"v0.0.0-experimental-shaderlab-thin.7"
zhuxudong Jun 24, 2024
7aba925
refactor: revert culled logic
zhuxudong Jun 24, 2024
562c128
"v0.0.0-experimental-shaderlab-thin.8"
zhuxudong Jun 24, 2024
0c8faa5
"v0.0.0-experimental-shaderlab-pbr.0"
zhuxudong Jun 24, 2024
e78d604
refactor: rename
zhuxudong Jun 24, 2024
054c43e
"v0.0.0-experimental-shaderlab-pbr.1"
zhuxudong Jun 24, 2024
544c5d4
refactor: add shading function macro
zhuxudong Jun 25, 2024
9e7f2d2
"v0.0.0-experimental-shaderlab-pbr.2"
zhuxudong Jun 25, 2024
761f107
refactor: add surfaceShading
zhuxudong Jun 25, 2024
d86f3f4
"v0.0.0-experimental-shaderlab-pbr.3"
zhuxudong Jun 25, 2024
15adf57
refactor: move out macro
zhuxudong Jun 25, 2024
b196c78
"v0.0.0-experimental-shaderlab-pbr.4"
zhuxudong Jun 25, 2024
7d87e38
refactor: override function macro
zhuxudong Jun 25, 2024
94d142f
"v0.0.0-experimental-shaderlab-pbr.5"
zhuxudong Jun 25, 2024
178ef1d
refactor: format change
zhuxudong Jun 27, 2024
b1874b2
refactor: delete todo
zhuxudong Jun 27, 2024
f358db7
fix: clamp roughness
zhuxudong Jun 27, 2024
0fadeea
refactor: delete override function cause of shaderLab
zhuxudong Jun 27, 2024
8791680
refactor: support repeat macro now cause of shaderlab
zhuxudong Jun 27, 2024
460bc03
fix: attenuation error
zhuxudong Jun 27, 2024
14b03d1
fix: clamp specular aa
zhuxudong Jul 11, 2024
99b02e7
ci: add registerShader function
zhuxudong Jul 16, 2024
0d28e97
refactor: include editorProps
zhuxudong Jul 16, 2024
f85cc8d
refactor: add NEED_TANGENT
zhuxudong Jul 16, 2024
71c39db
refactor: add ibl function macro
zhuxudong Jul 16, 2024
7384531
refactor: remove eidtor props outside
zhuxudong Jul 16, 2024
7802c98
refactor: abstract some function
zhuxudong Jul 16, 2024
459e8d7
refactor: init vetex shader
zhuxudong Jul 16, 2024
dfca3ab
refactor: delete MATERIAL_NEED_TILING_OFFSET and MATERIAL_NEED_WORL…
zhuxudong Jul 16, 2024
561c531
refactor: delete MATERIAL_OMIT_NORMAL
zhuxudong Jul 16, 2024
de4af12
chore: test compile bug
zhuxudong Jul 17, 2024
a6a2151
refactor: init vertex
zhuxudong Jul 17, 2024
57945a5
fix: pre SCENE_IS_CALCULATE_SHADOWS
zhuxudong Jul 17, 2024
67fdc58
refactor: add Macros.glsl
zhuxudong Jul 17, 2024
c8ac015
refactor: adapter to webgl1
zhuxudong Jul 17, 2024
7403430
refactor: rename
zhuxudong Jul 17, 2024
1cbf9be
refactor: split varyings and attributes from light
zhuxudong Jul 17, 2024
0ad84df
refactor: rename varyings
zhuxudong Jul 17, 2024
9eac515
fix: tbn refactor
zhuxudong Jul 17, 2024
f6ebf97
refactor: move function to brdf.glsl
zhuxudong Jul 17, 2024
d21e3c6
refactor: split surfaceData and brdfData
zhuxudong Jul 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
},
"pnpm": {
"overrides": {
"@galacean/engine": "^1.2.0-alpha.5"
"@galacean/engine": "^1.2.0-beta.1"
}
}
}
2 changes: 1 addition & 1 deletion packages/auxiliary-lines/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-auxiliary-lines",
"version": "1.2.0-beta.3",
"version": "0.0.0-experimental-shaderlab-pbr.5",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
Expand Down
2 changes: 1 addition & 1 deletion packages/controls/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-controls",
"version": "1.2.0-beta.3",
"version": "0.0.0-experimental-shaderlab-pbr.5",
"license": "MIT",
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion packages/custom-gltf-parser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-custom-gltf-parser",
"version": "1.2.0-beta.3",
"version": "0.0.0-experimental-shaderlab-pbr.5",
"license": "MIT",
"scripts": {
"b:types": "tsc"
Expand Down
2 changes: 1 addition & 1 deletion packages/custom-material/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-custom-material",
"version": "1.2.0-beta.3",
"version": "0.0.0-experimental-shaderlab-pbr.5",
"license": "MIT",
"scripts": {
"b:types": "tsc",
Expand Down
2 changes: 1 addition & 1 deletion packages/draco/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-draco",
"version": "1.2.0-beta.3",
"version": "0.0.0-experimental-shaderlab-pbr.5",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
Expand Down
2 changes: 1 addition & 1 deletion packages/dynamic-bone/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-dynamic-bone",
"version": "1.2.0-beta.3",
"version": "0.0.0-experimental-shaderlab-pbr.5",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
Expand Down
2 changes: 1 addition & 1 deletion packages/framebuffer-picker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-framebuffer-picker",
"version": "1.2.0-beta.3",
"version": "0.0.0-experimental-shaderlab-pbr.5",
"license": "MIT",
"module": "dist/es/index.js",
"main": "dist/commonjs/browser.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/galacean-engine-toolkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit",
"version": "1.2.0-beta.3",
"version": "0.0.0-experimental-shaderlab-pbr.5",
"license": "MIT",
"scripts": {
"b:types": "tsc"
Expand Down
2 changes: 1 addition & 1 deletion packages/geometry-sketch/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-geometry-sketch",
"version": "1.2.0-beta.3",
"version": "0.0.0-experimental-shaderlab-pbr.5",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
Expand Down
2 changes: 1 addition & 1 deletion packages/gizmo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-gizmo",
"version": "1.2.0-beta.3",
"version": "0.0.0-experimental-shaderlab-pbr.5",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
Expand Down
2 changes: 1 addition & 1 deletion packages/input-logger/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-input-logger",
"version": "1.2.0-beta.3",
"version": "0.0.0-experimental-shaderlab-pbr.5",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
Expand Down
2 changes: 1 addition & 1 deletion packages/lines/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-lines",
"version": "1.2.0-beta.3",
"version": "0.0.0-experimental-shaderlab-pbr.5",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
Expand Down
2 changes: 1 addition & 1 deletion packages/navigation-gizmo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-navigation-gizmo",
"version": "1.2.0-beta.3",
"version": "0.0.0-experimental-shaderlab-pbr.5",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
Expand Down
2 changes: 1 addition & 1 deletion packages/outline/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-outline",
"version": "1.2.0-beta.3",
"version": "0.0.0-experimental-shaderlab-pbr.5",
"license": "MIT",
"module": "dist/es/index.js",
"main": "dist/commonjs/browser.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/shaderlab/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/engine-toolkit-shader-lab",
"version": "1.2.0-beta.3",
"version": "0.0.0-experimental-shaderlab-pbr.5",
"license": "MIT",
"scripts": {
"b:types": "tsc"
Expand Down
25 changes: 0 additions & 25 deletions packages/shaderlab/src/GSLPBRMaterial.ts

This file was deleted.

24 changes: 23 additions & 1 deletion packages/shaderlab/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
export { GSLPBRMaterial } from "./GSLPBRMaterial";
import { Shader, ShaderFactory } from "@galacean/engine";
import { PBRSource, fragmentList } from "./shaders";

let includeRegistered = false;
let shaderRegistered = false;

export function registerIncludes() {
if (includeRegistered) return;

for (const sourceFragment of fragmentList) {
ShaderFactory.registerInclude(sourceFragment.includeKey, sourceFragment.source);
}

includeRegistered = true;
}

export function registerShader() {
if (shaderRegistered) return;

Shader.create(PBRSource);

shaderRegistered = true;
}
104 changes: 104 additions & 0 deletions packages/shaderlab/src/shaders/BlendShape.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#ifndef BLENDSHAPE_INCLUDED
#define BLENDSHAPE_INCLUDED

#ifdef RENDERER_HAS_BLENDSHAPE
#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE
mediump sampler2DArray renderer_BlendShapeTexture;
ivec3 renderer_BlendShapeTextureInfo;
float renderer_BlendShapeWeights[RENDERER_BLENDSHAPE_COUNT];

vec3 getBlendShapeVertexElement(int blendShapeIndex, int vertexElementIndex){
int y = vertexElementIndex / renderer_BlendShapeTextureInfo.y;
int x = vertexElementIndex - y * renderer_BlendShapeTextureInfo.y;
ivec3 uv = ivec3(x, y , blendShapeIndex);
return (texelFetch(renderer_BlendShapeTexture, uv, 0)).xyz;
}
#else
#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )
float renderer_BlendShapeWeights[2];
#else
#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )
float renderer_BlendShapeWeights[4];
#else
float renderer_BlendShapeWeights[8];
#endif
#endif
#endif

void calculateBlendShape(Attributes attributes, inout vec4 position
#ifdef RENDERER_HAS_NORMAL
,inout vec3 normal
#endif
#ifdef RENDERER_HAS_TANGENT
,inout vec4 tangent
#endif
){
#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE
int vertexOffset = gl_VertexID * renderer_BlendShapeTextureInfo.x;
for(int i = 0; i < RENDERER_BLENDSHAPE_COUNT; i++){
int vertexElementOffset = vertexOffset;
float weight = renderer_BlendShapeWeights[i];
// Warnning: Multiplying by 0 creates weird precision issues, causing rendering anomalies in Ace2 Android13
if(weight != 0.0){
position.xyz += getBlendShapeVertexElement(i, vertexElementOffset) * weight;

#if defined( RENDERER_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_NORMAL )
vertexElementOffset += 1;
normal += getBlendShapeVertexElement(i, vertexElementOffset) * weight;
#endif

#if defined( RENDERER_HAS_TANGENT ) && defined(RENDERER_BLENDSHAPE_HAS_TANGENT)
vertexElementOffset += 1;
tangent.xyz += getBlendShapeVertexElement(i, vertexElementOffset) * weight;
#endif
}

}
#else
position.xyz += attributes.POSITION_BS0 * renderer_BlendShapeWeights[0];
position.xyz += attributes.POSITION_BS1 * renderer_BlendShapeWeights[1];

#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )
#ifdef RENDERER_HAS_NORMAL
normal += attributes.NORMAL_BS0 * renderer_BlendShapeWeights[0];
normal += attributes.NORMAL_BS1 * renderer_BlendShapeWeights[1];
#endif

#ifdef RENDERER_HAS_TANGENT
tangent.xyz += attributes.TANGENT_BS0 * renderer_BlendShapeWeights[0];
tangent.xyz += attributes.TANGENT_BS1 * renderer_BlendShapeWeights[1];
#endif
#else
#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )
position.xyz += attributes.POSITION_BS2 * renderer_BlendShapeWeights[2];
position.xyz += attributes.POSITION_BS3 * renderer_BlendShapeWeights[3];

#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_HAS_NORMAL )
normal += attributes.NORMAL_BS0 * renderer_BlendShapeWeights[0];
normal += attributes.NORMAL_BS1 * renderer_BlendShapeWeights[1];
normal += attributes.NORMAL_BS2 * renderer_BlendShapeWeights[2];
normal += attributes.NORMAL_BS3 * renderer_BlendShapeWeights[3];
#endif

#if defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && defined( RENDERER_HAS_TANGENT )
tangent.xyz += attributes.TANGENT_BS0 * renderer_BlendShapeWeights[0];
tangent.xyz += attributes.TANGENT_BS1 * renderer_BlendShapeWeights[1];
tangent.xyz += attributes.TANGENT_BS2 * renderer_BlendShapeWeights[2];
tangent.xyz += attributes.TANGENT_BS3 * renderer_BlendShapeWeights[3];
#endif
#else
position.xyz += attributes.POSITION_BS2 * renderer_BlendShapeWeights[2];
position.xyz += attributes.POSITION_BS3 * renderer_BlendShapeWeights[3];
position.xyz += attributes.POSITION_BS4 * renderer_BlendShapeWeights[4];
position.xyz += attributes.POSITION_BS5 * renderer_BlendShapeWeights[5];
position.xyz += attributes.POSITION_BS6 * renderer_BlendShapeWeights[6];
position.xyz += attributes.POSITION_BS7 * renderer_BlendShapeWeights[7];
#endif
#endif
#endif
}

#endif


#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef COMMON_INCLUDED
#define COMMON_INCLUDED

#define PI 3.14159265359
#define RECIPROCAL_PI 0.31830988618
#define EPSILON 1e-6
Expand Down Expand Up @@ -92,3 +95,6 @@ float remapDepthBufferLinear01(float z){

#define INVERSE_MAT(mat) inverseMat(mat)
#endif


#endif
30 changes: 30 additions & 0 deletions packages/shaderlab/src/shaders/Fog.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef FOG_INCLUDED
#define FOG_INCLUDED

#if SCENE_FOG_MODE != 0
vec4 scene_FogColor;
vec4 scene_FogParams; // (-1/(end-start), end/(end-start), density/ln(2),density/sprt(ln(2)));

vec4 fog(vec4 color, vec3 positionVS){
float fogDepth = length(positionVS);

#if SCENE_FOG_MODE == 1
// (end-z) / (end-start) = z * (-1/(end-start)) + (end/(end-start))
float fogIntensity = clamp(fogDepth * scene_FogParams.x + scene_FogParams.y, 0.0, 1.0);
#elif SCENE_FOG_MODE == 2
// exp(-z * density) = exp2((-z * density)/ln(2)) = exp2(-z * density/ln(2))
float fogIntensity = clamp(exp2(-fogDepth * scene_FogParams.z), 0.0, 1.0);
#elif SCENE_FOG_MODE == 3
// exp(-(z * density)^2) = exp2(-(z * density)^2/ln(2)) = exp2(-(z * density/sprt(ln(2)))^2)
float factor = fogDepth * scene_FogParams.w;
float fogIntensity = clamp(exp2(-factor * factor), 0.0, 1.0);
#endif

color.rgb = mix(scene_FogColor.rgb, color.rgb, fogIntensity);

return color;
}
#endif


#endif
4 changes: 0 additions & 4 deletions packages/shaderlab/src/shaders/FogFragment.glsl

This file was deleted.

18 changes: 0 additions & 18 deletions packages/shaderlab/src/shaders/FogFragmentDeclaration.glsl

This file was deleted.

4 changes: 0 additions & 4 deletions packages/shaderlab/src/shaders/FogVertex.glsl

This file was deleted.

Loading
Loading