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

Simplified passing ior #4441

Merged
merged 1 commit into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 0 additions & 2 deletions src/graphics/program-lib/chunks/chunks.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ import gamma2_2PS from './common/frag/gamma2_2.js';
import gles3PS from './common/frag/gles3.js';
import gles3VS from './common/vert/gles3.js';
import glossPS from './standard/frag/gloss.js';
import iorPS from './standard/frag/ior.js';
import instancingVS from './lit/vert/instancing.js';
import lightDiffuseLambertPS from './lit/frag/lightDiffuseLambert.js';
import lightDirPointPS from './lit/frag/lightDirPoint.js';
Expand Down Expand Up @@ -269,7 +268,6 @@ const shaderChunks = {
gles3PS,
gles3VS,
glossPS,
iorPS,
instancingVS,
lightDiffuseLambertPS,
lightDirPointPS,
Expand Down
5 changes: 3 additions & 2 deletions src/graphics/program-lib/chunks/lit/frag/refraction.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export default /* glsl */`
uniform float material_refraction;
uniform float material_refractionIndex;

vec3 refract2(vec3 viewVec, vec3 Normal, float IOR) {
float vn = dot(viewVec, Normal);
Expand All @@ -8,11 +9,11 @@ vec3 refract2(vec3 viewVec, vec3 Normal, float IOR) {
return refrVec;
}

void addRefraction(float ior) {
void addRefraction() {
// use same reflection code with refraction vector
vec3 tmpDir = dReflDirW;
vec4 tmpRefl = dReflection;
dReflDirW = refract2(-dViewDirW, dNormalW, ior);
dReflDirW = refract2(-dViewDirW, dNormalW, material_refractionIndex);

dReflection = vec4(0);
addReflection();
Expand Down
16 changes: 0 additions & 16 deletions src/graphics/program-lib/chunks/standard/frag/ior.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/graphics/program-lib/programs/lit-shader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ class LitShader {
}

if (this.reflections && options.refraction) {
code += " addRefraction(dIor);\n";
code += " addRefraction();\n";
}
}
code += "\n";
Expand Down
6 changes: 0 additions & 6 deletions src/graphics/program-lib/programs/standard.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,6 @@ const standard = {
code.append(this._addMap("diffuse", "diffusePS", options, litShader.chunks));
func.append("getAlbedo();");

if (options.refraction) {
decl.append("float dIor;");
code.append(this._addMap("refractionIndex", "iorPS", options, litShader.chunks));
func.append("getRefractionIndex();");
}

// specularity & glossiness
if ((litShader.lighting && options.useSpecular) || litShader.reflections) {
decl.append("vec3 dSpecularity;");
Expand Down