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

Add alphaMap to Standard material schema. #5031

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/components/material.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ These properties are available on top of the base material properties.

| Property | Description | Default Value |
|-------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|---------------|
| alphaMap | Alpha map. Controls the opacity of the mesh. Can either be a selector to an `<img>`, or an inline URL. Requires `transparent=true`. | None
| alphaTextureRepeat | How many times the alpha texture repeats in the X and Y direction | 1 1
| alphaTextureOffset | How the displacement texture is offset in the x y direction | 0 0
| ambientOcclusionMap | Ambient occlusion map. Used to add shadows to the mesh. Can either be a selector to an `<img>`, or an inline URL. Requires 2nd set of UVs (see below). | None |
| ambientOcclusionMapIntensity | The intensity of the ambient occlusion map, a number between 0 and 1. | 1 |
| ambientOcclusionTextureRepeat | How many times the ambient occlusion texture repeats in the X and Y direction. | 1 1 |
Expand Down
6 changes: 6 additions & 0 deletions src/shaders/standard.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ module.exports.Shader = registerShader('standard', {
normalTextureOffset: {type: 'vec2'},
normalTextureRepeat: {type: 'vec2', default: {x: 1, y: 1}},

alphaMap: {type: 'map'},
alphaTextureOffset: {type: 'vec2'},
alphaTextureRepeat: {type: 'vec2', default: {x: 1, y: 1}},

offset: {type: 'vec2', default: {x: 0, y: 0}},
repeat: {type: 'vec2', default: {x: 1, y: 1}},

Expand Down Expand Up @@ -74,6 +78,7 @@ module.exports.Shader = registerShader('standard', {
if (data.ambientOcclusionMap) { utils.material.updateDistortionMap('ambientOcclusion', this, data); }
if (data.metalnessMap) { utils.material.updateDistortionMap('metalness', this, data); }
if (data.roughnessMap) { utils.material.updateDistortionMap('roughness', this, data); }
if (data.alphaMap) { utils.material.updateDistortionMap('alpha', this, data); }
this.updateEnvMap(data);
},

Expand All @@ -85,6 +90,7 @@ module.exports.Shader = registerShader('standard', {
if (data.ambientOcclusionMap) { utils.material.updateDistortionMap('ambientOcclusion', this, data); }
if (data.metalnessMap) { utils.material.updateDistortionMap('metalness', this, data); }
if (data.roughnessMap) { utils.material.updateDistortionMap('roughness', this, data); }
if (data.alphaMap) { utils.material.updateDistortionMap('alpha', this, data); }
this.updateEnvMap(data);
},

Expand Down