-
-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
shaderlab pbr support refraction (#2470)
* feat: pbr support refraction
- Loading branch information
Showing
8 changed files
with
79 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,28 @@ struct RefractionModelResult{ | |
// vec3 directionExit; // out ray direction | ||
}; | ||
|
||
void refractionModelBox(vec3 V, vec3 positionWS, vec3 normalWS, float ior, float thickness, out RefractionModelResult ray){ | ||
//https://docs.unity3d.com/Packages/[email protected]/manual/refraction-models.html | ||
void refractionModelSphere(vec3 V, vec3 positionWS, vec3 normalWS, float ior, float thickness, out RefractionModelResult ray){ | ||
// Refracted ray | ||
vec3 R1 = refract(V, normalWS, 1.0 / ior); | ||
// Center of the tangent sphere | ||
// vec3 C = positionWS - normalWS * thickness * 0.5; | ||
|
||
// Second refraction (tangent sphere out) | ||
float dist = dot(-normalWS, R1) * thickness; | ||
// Out hit point in the tangent sphere | ||
vec3 P1 = positionWS + R1 * dist; | ||
// Out normal | ||
// vec3 N1 = safeNormalize(C - P1); | ||
// Out refracted ray | ||
// vec3 R2 = refract(R1, N1, ior); | ||
|
||
ray.transmissionLength = dist; | ||
ray.positionExit = P1; | ||
// ray.directionExit = R2; | ||
} | ||
|
||
void refractionModelPlanar(vec3 V, vec3 positionWS, vec3 normalWS, float ior, float thickness, out RefractionModelResult ray){ | ||
// Refracted ray | ||
vec3 R = refract(V, normalWS, 1.0 / ior); | ||
// Optical depth within the thin plane | ||
|