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

shaderlab pbr support refraction #2470

Merged
merged 44 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
dd09252
feat: shaderlab pbr support refraction
hhhhkrx Dec 18, 2024
1fc002e
fix: disableMacro
hhhhkrx Dec 19, 2024
adfdfec
fix: name
hhhhkrx Dec 19, 2024
62844aa
Merge branch 'dev/1.4' of github.com:galacean/engine into refraction
hhhhkrx Dec 20, 2024
ffa2912
fix: refraction mode
hhhhkrx Dec 20, 2024
1fc63b2
fix: keep iridescenceRange unified
hhhhkrx Dec 20, 2024
bab9582
fix: refraction
hhhhkrx Dec 20, 2024
174e0e7
fix: refraction
hhhhkrx Dec 20, 2024
47fb197
fix: refraction mode
hhhhkrx Dec 20, 2024
f9b748c
fix: refraction
hhhhkrx Dec 24, 2024
4ef6387
Merge branch 'dev/1.4' of github.com:galacean/engine into refraction
hhhhkrx Dec 24, 2024
76b40b1
fix: refraction
hhhhkrx Dec 24, 2024
3abe5c1
fix: refraction
hhhhkrx Dec 24, 2024
b81bbeb
fix: refraction
hhhhkrx Dec 24, 2024
bcc9daf
fix: refraction
hhhhkrx Dec 24, 2024
b9b9558
fix: refraction
hhhhkrx Dec 24, 2024
9d8a37e
Merge branch 'dev/1.4' of github.com:galacean/engine into refraction
hhhhkrx Dec 24, 2024
84e2f0d
fix: refraction mode
hhhhkrx Dec 24, 2024
e977cbc
fix: refraction mode
hhhhkrx Dec 24, 2024
4040c26
fix: refraction shader
hhhhkrx Dec 24, 2024
420566d
fix: refraction
hhhhkrx Dec 24, 2024
4a3ce3e
fix: refraction mode
hhhhkrx Dec 24, 2024
6b19600
fix: refraction
hhhhkrx Dec 24, 2024
129ac02
fix: refraction value
hhhhkrx Dec 24, 2024
1ff952d
fix: refraction
hhhhkrx Dec 24, 2024
1f011eb
Merge branch 'dev/1.4' into refraction
hhhhkrx Dec 27, 2024
76d9063
fix: dev/1.4
hhhhkrx Dec 27, 2024
d2c26cf
refactor: opt code
hhhhkrx Dec 27, 2024
9d9e4ae
fix: refraction mode
hhhhkrx Dec 27, 2024
02ae05e
fix: refractionModel name
hhhhkrx Dec 27, 2024
a493e26
fix: refraction mode
hhhhkrx Dec 27, 2024
59e0da3
fix: sort
hhhhkrx Dec 27, 2024
e062e18
fix: include
hhhhkrx Dec 27, 2024
aa434e4
fix: refraction mode enable
hhhhkrx Dec 27, 2024
82d9754
fix: refracion mode number
hhhhkrx Dec 27, 2024
4c5eb18
fix: refraction model
hhhhkrx Dec 27, 2024
b6c874a
fix: refraction name
hhhhkrx Dec 27, 2024
0bf8d73
fix: refraction mode
hhhhkrx Dec 27, 2024
1f20667
fix: annotation
hhhhkrx Dec 27, 2024
d4b5d11
fix: attenuation
hhhhkrx Dec 27, 2024
df27aef
fix: attenuation
hhhhkrx Dec 27, 2024
1ba3440
fix: refraction
hhhhkrx Dec 27, 2024
09397f0
fix: annotation
hhhhkrx Dec 27, 2024
e7718de
fix: refraction mode
hhhhkrx Dec 27, 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
186 changes: 178 additions & 8 deletions packages/core/src/material/PBRMaterial.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { MathUtil, Vector2, Vector3, Vector4, Color } from "@galacean/engine-math";
import { Engine } from "../Engine";
import { ShaderProperty } from "../shader";
import { ShaderMacro, ShaderProperty } from "../shader";
import { Shader } from "../shader/Shader";
import { Texture2D } from "../texture/Texture2D";
import { PBRBaseMaterial } from "./PBRBaseMaterial";
import { RefractionMode } from "./enums/Refraction";
import { RenderQueueType } from "../shader/enums/RenderQueueType";

/**
* PBR (Metallic-Roughness Workflow) Material.
Expand Down Expand Up @@ -31,6 +33,22 @@
private static _sheenTextureProp = ShaderProperty.getByName("material_SheenTexture");
private static _sheenRoughnessTextureProp = ShaderProperty.getByName("material_SheenRoughnessTexture");

protected _refractionMode: RefractionMode;
protected static _refractionMacro: ShaderMacro = ShaderMacro.getByName("MATERIAL_ENABLE_SS_REFRACTION");
private static _refractionSphereMacro: ShaderMacro = ShaderMacro.getByName("REFRACTION_SPHERE");
private static _refractionPlaneMacro: ShaderMacro = ShaderMacro.getByName("REFRACTION_PLANE");
private static _refractionThinMacro: ShaderMacro = ShaderMacro.getByName("REFRACTION_THIN");
private static _transmissionMacro: ShaderMacro = ShaderMacro.getByName("MATERIAL_HAS_TRANSMISSION");
private static _thicknessMacro: ShaderMacro = ShaderMacro.getByName("MATERIAL_HAS_THICKNESS");
private static _absorptionMacro: ShaderMacro = ShaderMacro.getByName("MATERIAL_HAS_ABSORPTION");
private static _thicknessTextureMacro: ShaderMacro = ShaderMacro.getByName("MATERIAL_HAS_THICKNESS_TEXTURE");
private static _transmissionTextureMacro: ShaderMacro = ShaderMacro.getByName("MATERIAL_HAS_TRANSMISSION_TEXTURE");
private static _transmissionProp = ShaderProperty.getByName("material_Transmission");
private static _transmissionTextureProp = ShaderProperty.getByName("material_TransmissionTexture");
private static _attenuationColorProp = ShaderProperty.getByName("material_AttenuationColor");
private static _attenuationDistanceProp = ShaderProperty.getByName("material_AttenuationDistance");
private static _thicknessProp = ShaderProperty.getByName("material_Thickness");
private static _thicknessTextureProp = ShaderProperty.getByName("material_ThicknessTexture");
zhuxudong marked this conversation as resolved.
Show resolved Hide resolved
/**
* Index Of Refraction.
* @defaultValue `1.5`
Expand Down Expand Up @@ -289,6 +307,145 @@
}
}

/**
* Refraction switch.
* @remarks Use refractionMode to set the refraction shape.
*/
get refractionMode(): RefractionMode {
return this._refractionMode;
}

Check warning on line 316 in packages/core/src/material/PBRMaterial.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/material/PBRMaterial.ts#L315-L316

Added lines #L315 - L316 were not covered by tests

set refractionMode(value: RefractionMode) {
if (value !== this._refractionMode) {
if (value) {
this.shaderData.enableMacro(PBRMaterial._refractionMacro);
this.renderState.renderQueueType = RenderQueueType.Transparent;
this.renderState.blendState.targetBlendState.enabled = false;
} else {
this.shaderData.disableMacro(PBRMaterial._refractionMacro);
this.renderState.renderQueueType = RenderQueueType.Opaque;
this.renderState.blendState.targetBlendState.enabled = true;
zhuxudong marked this conversation as resolved.
Show resolved Hide resolved
}

Check warning on line 328 in packages/core/src/material/PBRMaterial.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/material/PBRMaterial.ts#L325-L328

Added lines #L325 - L328 were not covered by tests
}
this._refractionMode = value;
this.setRefractionMode(value);
}
hhhhkrx marked this conversation as resolved.
Show resolved Hide resolved

private setRefractionMode(refractionMode: RefractionMode): void {
this.shaderData.disableMacro(PBRMaterial._refractionSphereMacro);
this.shaderData.disableMacro(PBRMaterial._refractionPlaneMacro);
this.shaderData.disableMacro(PBRMaterial._refractionThinMacro);
zhuxudong marked this conversation as resolved.
Show resolved Hide resolved

switch (refractionMode) {
case RefractionMode.Sphere:
zhuxudong marked this conversation as resolved.
Show resolved Hide resolved
this.shaderData.enableMacro(PBRMaterial._refractionSphereMacro);
break;

Check warning on line 342 in packages/core/src/material/PBRMaterial.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/material/PBRMaterial.ts#L341-L342

Added lines #L341 - L342 were not covered by tests
case RefractionMode.Plane:
this.shaderData.enableMacro(PBRMaterial._refractionPlaneMacro);
break;
case RefractionMode.Thin:
this.shaderData.enableMacro(PBRMaterial._refractionThinMacro);
break;

Check warning on line 348 in packages/core/src/material/PBRMaterial.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/material/PBRMaterial.ts#L347-L348

Added lines #L347 - L348 were not covered by tests
}
}

/**
* Transmission factor.
* @defaultValue `0.0`
*/
get transmission(): number {
return this.shaderData.getFloat(PBRMaterial._transmissionProp);
}

Check warning on line 358 in packages/core/src/material/PBRMaterial.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/material/PBRMaterial.ts#L357-L358

Added lines #L357 - L358 were not covered by tests

set transmission(value: number) {
value = Math.max(0, Math.min(1, value));
zhuxudong marked this conversation as resolved.
Show resolved Hide resolved
if (!!this.shaderData.getFloat(PBRMaterial._transmissionProp) !== !!value) {
this.shaderData.disableMacro(PBRMaterial._transmissionMacro);
} else {
this.shaderData.enableMacro(PBRMaterial._transmissionMacro);
}
this.shaderData.setFloat(PBRMaterial._transmissionProp, value);
}

Check warning on line 368 in packages/core/src/material/PBRMaterial.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/material/PBRMaterial.ts#L361-L368

Added lines #L361 - L368 were not covered by tests
hhhhkrx marked this conversation as resolved.
Show resolved Hide resolved

/**
* Transmission texture.
* @remarks Use red channel, and multiply 'transmission'.
*/
get transmissionTexture(): Texture2D {
return <Texture2D>this.shaderData.getTexture(PBRMaterial._transmissionTextureProp);
}

Check warning on line 376 in packages/core/src/material/PBRMaterial.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/material/PBRMaterial.ts#L375-L376

Added lines #L375 - L376 were not covered by tests

set transmissionTexture(value: Texture2D) {
this.shaderData.setTexture(PBRMaterial._transmissionTextureProp, value);
if (value) {
this.shaderData.enableMacro(PBRMaterial._transmissionTextureMacro);
} else {
this.shaderData.disableMacro(PBRMaterial._transmissionTextureMacro);
}
}

Check warning on line 385 in packages/core/src/material/PBRMaterial.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/material/PBRMaterial.ts#L379-L385

Added lines #L379 - L385 were not covered by tests

/**
* Attenuation color.
* @defaultValue `[1,1,1]`
*/
get attenuationColor(): Color {
return this.shaderData.getColor(PBRMaterial._attenuationColorProp);
}

Check warning on line 393 in packages/core/src/material/PBRMaterial.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/material/PBRMaterial.ts#L392-L393

Added lines #L392 - L393 were not covered by tests

set attenuationColor(value: Color) {
const attenuationColor = this.shaderData.getColor(PBRMaterial._attenuationColorProp);
if (value !== attenuationColor) {
attenuationColor.copyFrom(value);
}
}

Check warning on line 400 in packages/core/src/material/PBRMaterial.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/material/PBRMaterial.ts#L396-L400

Added lines #L396 - L400 were not covered by tests

/**
* Attenuation distance, greater than 0.0.
* @defaultValue `infinity`
*/
get attenuationDistance(): number {
zhuxudong marked this conversation as resolved.
Show resolved Hide resolved
return this.shaderData.getFloat(PBRMaterial._attenuationDistanceProp);
}

Check warning on line 408 in packages/core/src/material/PBRMaterial.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/material/PBRMaterial.ts#L407-L408

Added lines #L407 - L408 were not covered by tests

set attenuationDistance(value: number) {
value = Math.max(0, value);
this.shaderData.setFloat(PBRMaterial._attenuationDistanceProp, value);
}

Check warning on line 413 in packages/core/src/material/PBRMaterial.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/material/PBRMaterial.ts#L411-L413

Added lines #L411 - L413 were not covered by tests

/**
* Thickness, greater than or equal to 0.0.
* @defaultValue `0.0`
*/
get thickness(): number {
return this.shaderData.getFloat(PBRMaterial._thicknessProp);
zhuxudong marked this conversation as resolved.
Show resolved Hide resolved
}

Check warning on line 421 in packages/core/src/material/PBRMaterial.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/material/PBRMaterial.ts#L420-L421

Added lines #L420 - L421 were not covered by tests

set thickness(value: number) {
value = Math.max(0, value);
if (!!this.shaderData.getFloat(PBRMaterial._thicknessProp) !== !!value) {
this.shaderData.disableMacro(PBRMaterial._thicknessMacro);
} else {
this.shaderData.enableMacro(PBRMaterial._thicknessMacro);
}
this.shaderData.setFloat(PBRMaterial._thicknessProp, value);
}

Check warning on line 431 in packages/core/src/material/PBRMaterial.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/material/PBRMaterial.ts#L424-L431

Added lines #L424 - L431 were not covered by tests
hhhhkrx marked this conversation as resolved.
Show resolved Hide resolved

/**
* Thickness texture.
* @remarks Use green channel, and multiply 'thickness', range is 0.0 to 1.0.
*/
get thicknessTexture(): Texture2D {
return <Texture2D>this.shaderData.getTexture(PBRMaterial._thicknessTextureProp);
}

Check warning on line 439 in packages/core/src/material/PBRMaterial.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/material/PBRMaterial.ts#L438-L439

Added lines #L438 - L439 were not covered by tests

set thicknessTexture(value: Texture2D) {
this.shaderData.setTexture(PBRMaterial._thicknessTextureProp, value);
if (value) {
this.shaderData.enableMacro(PBRMaterial._thicknessTextureMacro);
} else {
this.shaderData.disableMacro(PBRMaterial._thicknessTextureMacro);
}
}

Check warning on line 448 in packages/core/src/material/PBRMaterial.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/material/PBRMaterial.ts#L442-L448

Added lines #L442 - L448 were not covered by tests
/**
* Create a pbr metallic-roughness workflow material instance.
* @param engine - Engine to which the material belongs
Expand All @@ -304,8 +461,18 @@
shaderData.setVector4(PBRMaterial._iridescenceInfoProp, new Vector4(0, 1.3, 100, 400));
const sheenColor = new Color(0, 0, 0);
shaderData.setColor(PBRMaterial._sheenColorProp, sheenColor);
this.refractionMode = RefractionMode.Plane;
zhuxudong marked this conversation as resolved.
Show resolved Hide resolved
shaderData.setFloat(PBRMaterial._thicknessProp, 0);
zhuxudong marked this conversation as resolved.
Show resolved Hide resolved
shaderData.setFloat(PBRMaterial._attenuationDistanceProp, Infinity);
const attenuationColor = new Color(1, 1, 1);
shaderData.setColor(PBRMaterial._attenuationColorProp, attenuationColor);

// @ts-ignore
this._iridescenceRange._onValueChanged = this._onIridescenceRangeChanged.bind(this);
this._iridescenceRange._onValueChanged = () => {
const iridescenceInfo = this.shaderData.getVector4(PBRMaterial._iridescenceInfoProp);
iridescenceInfo.z = this._iridescenceRange.x;
iridescenceInfo.w = this._iridescenceRange.y;
};

Check warning on line 475 in packages/core/src/material/PBRMaterial.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/material/PBRMaterial.ts#L472-L475

Added lines #L472 - L475 were not covered by tests
// @ts-ignore
sheenColor._onValueChanged = () => {
const enableSheen = sheenColor.r + sheenColor.g + sheenColor.b > 0;
Expand All @@ -318,12 +485,15 @@
}
}
};
}

private _onIridescenceRangeChanged(): void {
const iridescenceInfo = this.shaderData.getVector4(PBRMaterial._iridescenceInfoProp);
iridescenceInfo.z = this._iridescenceRange.x;
iridescenceInfo.w = this._iridescenceRange.y;
// @ts-ignore
attenuationColor._onValueChanged = () => {
const enableAbsorption = attenuationColor.r + attenuationColor.g + attenuationColor.b > 1;
zhuxudong marked this conversation as resolved.
Show resolved Hide resolved
if (enableAbsorption) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cache absorption state to switch macro

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@todo: do you need MATERIAL_HAS_ABSORPTION

this.shaderData.enableMacro(PBRMaterial._absorptionMacro);
} else {
this.shaderData.disableMacro(PBRMaterial._absorptionMacro);
}

Check warning on line 495 in packages/core/src/material/PBRMaterial.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/material/PBRMaterial.ts#L494-L495

Added lines #L494 - L495 were not covered by tests
};
}

/**
Expand Down
11 changes: 11 additions & 0 deletions packages/core/src/material/enums/Refraction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Refraction mode.
*/
export enum RefractionMode {
zhuxudong marked this conversation as resolved.
Show resolved Hide resolved
/** Refraction shape is sphere */
Sphere,
/** Refraction shape is plane */
Plane,
/** Refraction shape is thin */
zhuxudong marked this conversation as resolved.
Show resolved Hide resolved
Thin
}
11 changes: 11 additions & 0 deletions packages/loader/src/gltf/extensions/GLTFExtensionSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,16 @@ export interface IKHRMaterialsIridescence {
iridescenceThicknessTexture?: ITextureInfo;
}

/**
* Interfaces from the KHR_materials_volume extension
*/
export interface IKHRMaterialsVolume {
thicknessFactor?: number;
thicknessTexture?: ITextureInfo;
attenuationDistance?: number;
attenuationColor?: number[];
}

export type GLTFExtensionSchema =
| IKHRLightsPunctual_Light
| IKHRMaterialsClearcoat
Expand All @@ -207,4 +217,5 @@ export type GLTFExtensionSchema =
| IKHRXmp_Node
| IGalaceanAnimation
| IKHRMaterialsIridescence
| IKHRMaterialsVolume
| Object;
23 changes: 23 additions & 0 deletions packages/loader/src/gltf/extensions/KHR_materials_transmission.ts
Original file line number Diff line number Diff line change
@@ -1,0 +1,23 @@
import { PBRMaterial, Texture2D } from "@galacean/engine-core";
import { GLTFMaterialParser } from "../parser/GLTFMaterialParser";
import { registerGLTFExtension } from "../parser/GLTFParser";
import { GLTFParserContext, GLTFParserType } from "../parser/GLTFParserContext";
import { GLTFExtensionMode, GLTFExtensionParser } from "./GLTFExtensionParser";
import { IKHRMaterialsTransmission } from "./GLTFExtensionSchema";

@registerGLTFExtension("KHR_materials_transmission", GLTFExtensionMode.AdditiveParse)
class KHR_materials_transmission extends GLTFExtensionParser {
override additiveParse(context: GLTFParserContext, material: PBRMaterial, schema: IKHRMaterialsTransmission): void {
const { transmissionFactor = 0, transmissionTexture } = schema;

material.transmission = transmissionFactor;

if (transmissionTexture) {
GLTFMaterialParser._checkOtherTextureTransform(transmissionTexture, "Transmission texture");

context.get<Texture2D>(GLTFParserType.Texture, transmissionTexture.index).then((texture) => {
material.transmissionTexture = texture;
});
}
}

Check warning on line 22 in packages/loader/src/gltf/extensions/KHR_materials_transmission.ts

View check run for this annotation

Codecov / codecov/patch

packages/loader/src/gltf/extensions/KHR_materials_transmission.ts#L11-L22

Added lines #L11 - L22 were not covered by tests
}
34 changes: 34 additions & 0 deletions packages/loader/src/gltf/extensions/KHR_materials_volume.ts
Original file line number Diff line number Diff line change
@@ -1,0 +1,34 @@
import { PBRMaterial, Texture2D } from "@galacean/engine-core";
import { Color } from "@galacean/engine-math";
import { GLTFMaterialParser } from "../parser/GLTFMaterialParser";
import { registerGLTFExtension } from "../parser/GLTFParser";
import { GLTFParserContext, GLTFParserType } from "../parser/GLTFParserContext";
import { GLTFExtensionMode, GLTFExtensionParser } from "./GLTFExtensionParser";
import { IKHRMaterialsVolume } from "./GLTFExtensionSchema";

@registerGLTFExtension("KHR_materials_volume", GLTFExtensionMode.AdditiveParse)
class KHR_materials_volume extends GLTFExtensionParser {
override additiveParse(context: GLTFParserContext, material: PBRMaterial, schema: IKHRMaterialsVolume): void {
const { thicknessFactor = 0, thicknessTexture, attenuationDistance = Infinity, attenuationColor } = schema;

material.thickness = thicknessFactor;
material.attenuationDistance = attenuationDistance;

if (attenuationColor) {
material.attenuationColor.set(
Color.linearToGammaSpace(attenuationColor[0]),
Color.linearToGammaSpace(attenuationColor[1]),
Color.linearToGammaSpace(attenuationColor[2]),
undefined
);
}
hhhhkrx marked this conversation as resolved.
Show resolved Hide resolved

if (thicknessTexture) {
GLTFMaterialParser._checkOtherTextureTransform(thicknessTexture, "Thickness texture");

context.get<Texture2D>(GLTFParserType.Texture, thicknessTexture.index).then((texture) => {
material.thicknessTexture = texture;
});
}
hhhhkrx marked this conversation as resolved.
Show resolved Hide resolved
}

Check warning on line 33 in packages/loader/src/gltf/extensions/KHR_materials_volume.ts

View check run for this annotation

Codecov / codecov/patch

packages/loader/src/gltf/extensions/KHR_materials_volume.ts#L12-L33

Added lines #L12 - L33 were not covered by tests
}
9 changes: 9 additions & 0 deletions packages/shader-shaderlab/src/shaders/PBR.gs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ Shader "PBR.gs" {
material_SheenTexture("ColorTexture", Texture2D);
material_SheenRoughnessTexture("RoughnessTexture", Texture2D);
}

Header("Refraction"){
material_AttenuationColor("AttenuationColor", Color ) = (1, 1, 1, 1);
GuoLei1990 marked this conversation as resolved.
Show resolved Hide resolved
material_AttenuationDistance("AttenuationDistance", Range(0, 1, 0.01)) = 0;
material_Transmission("Transmission", Range(0, 1, 0.01)) = 0;
material_Thickness("Thickness", Range(0, 5, 0.01)) = 0;
material_TransmissionTexture("TransmissionTexture", Texture2D);
material_ThicknessTexture("ThicknessTexture", Texture2D);
GuoLei1990 marked this conversation as resolved.
Show resolved Hide resolved
GuoLei1990 marked this conversation as resolved.
Show resolved Hide resolved
}

Header("Common") {
material_AlphaCutoff( "AlphaCutoff", Range(0, 1, 0.01) ) = 0;
Expand Down
7 changes: 7 additions & 0 deletions packages/shader-shaderlab/src/shaders/shadingPBR/BRDF.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct SurfaceData{
float specularAO;
float f0;
float opacity;
float IOR;

// geometry
vec3 position;
Expand Down Expand Up @@ -64,6 +65,12 @@ struct SurfaceData{
vec3 sheenColor;
#endif

#ifdef MATERIAL_ENABLE_SS_REFRACTION
vec3 attenuationColor;
float attenuationDistance;
float transmission;
float thickness;
#endif
};


Expand Down
Loading
Loading