We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
PlayCanvas Editor is using v1.73.4.
Let's have a look how refractionIndex works:
refractionIndex
StandardMaterialOptionsBuilder#_updateMaterialOptions:
StandardMaterialOptionsBuilder#_updateMaterialOptions
options.refractionTint = (stdMat.refraction !== 1.0) ? 1 : 0; options.refractionIndexTint = (stdMat.refractionIndex !== 1.0 / 1.5) ? 1 : 0; options.iorTint = stdMat.refractionIndex !== 1.0 / 1.5 ? 1 : 0;
options.iorTint will pass to ShaderGeneratorStandard#_addMap
options.iorTint
ShaderGeneratorStandard#_addMap
const isFloatTint = !!(tintOption & 1); const isVecTint = !!(tintOption & 2); const invertOption = !!(options[invertName]); subCode = this._addMapDefs(isFloatTint, isVecTint, vertexColorOption, textureOption, invertOption) + subCode;
isFloatTint will replace iorPS's macro:
isFloatTint
iorPS
#ifdef MAPFLOAT uniform float material_refractionIndex; #endif void getIor() { #ifdef MAPFLOAT dIor = material_refractionIndex; #else dIor = 1.0 / 1.5; #endif }
In the end, the dIor will be used to calculate f0:
dIor
f0
float f0 = 1.0 / litArgs_ior; f0 = (f0 - 1.0) / (f0 + 1.0); f0 *= f0;
So when refractionIndex is zero, the f0 = (1.0 / 0.0) = infinity.
f0 = (1.0 / 0.0) = infinity
Here is the document of refraction
refraction
@Property {number} refraction Defines the visibility of refraction. Material can refract the same cube map as used for reflections.
If the refraction is zero, the refraction should be invisible. It seems we should let options.iorTint respect refraction ?
- options.iorTint = stdMat.refractionIndex !== 1.0 / 1.5 ? 1 : 0; + options.iorTint = (stdMaterial.refraction > 0 && stdMat.refractionIndex !== 1.0 / 1.5) ? 1 : 0;
Or how should it be ?
The text was updated successfully, but these errors were encountered:
mvaligursky
No branches or pull requests
20240905093445_rec_-convert.mp4
PlayCanvas Editor is using v1.73.4.
Let's have a look how
refractionIndex
works:StandardMaterialOptionsBuilder#_updateMaterialOptions
:options.iorTint
will pass toShaderGeneratorStandard#_addMap
isFloatTint
will replaceiorPS
's macro:In the end, the
dIor
will be used to calculatef0
:So when
refractionIndex
is zero, thef0 = (1.0 / 0.0) = infinity
.Here is the document of
refraction
If the
refraction
is zero, the refraction should be invisible.It seems we should let
options.iorTint
respectrefraction
?Or how should it be ?
The text was updated successfully, but these errors were encountered: