forked from bartvdbraak/blender
Cycles / OSL:
* Rename fresnel_dielectric() to fresnel_dielectric_cos() to match SVM, easier when searching code. * Also remove an old code comment in bsdf_reflection.h from Cycles branch days.
This commit is contained in:
parent
d3f9fb677b
commit
2efe0f6733
@ -59,7 +59,6 @@ __device float3 bsdf_reflection_eval_transmit(const ShaderClosure *sc, const flo
|
|||||||
|
|
||||||
__device int bsdf_reflection_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
|
__device int bsdf_reflection_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
|
||||||
{
|
{
|
||||||
//const BsdfReflectionClosure *self = (const BsdfReflectionClosure*)sc->data;
|
|
||||||
float3 N = sc->N;
|
float3 N = sc->N;
|
||||||
|
|
||||||
// only one direction is possible
|
// only one direction is possible
|
||||||
|
@ -14,11 +14,11 @@
|
|||||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
float fresnel_dielectric(vector Incoming, normal Normal, float eta)
|
float fresnel_dielectric_cos(float cosi, float eta)
|
||||||
{
|
{
|
||||||
/* compute fresnel reflectance without explicitly computing
|
/* compute fresnel reflectance without explicitly computing
|
||||||
* the refracted direction */
|
* the refracted direction */
|
||||||
float c = fabs(dot(Incoming, Normal));
|
float c = fabs(cosi);
|
||||||
float g = eta * eta - 1 + c * c;
|
float g = eta * eta - 1 + c * c;
|
||||||
float result;
|
float result;
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ shader node_fresnel(
|
|||||||
{
|
{
|
||||||
float f = max(IOR, 1.0 + 1e-5);
|
float f = max(IOR, 1.0 + 1e-5);
|
||||||
float eta = backfacing() ? 1.0 / f: f;
|
float eta = backfacing() ? 1.0 / f: f;
|
||||||
Fac = fresnel_dielectric(I, Normal, eta);
|
float cosi = dot(I, Normal);
|
||||||
|
Fac = fresnel_dielectric_cos(cosi, eta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,8 @@ shader node_glass_bsdf(
|
|||||||
{
|
{
|
||||||
float f = max(IOR, 1.0 + 1e-5);
|
float f = max(IOR, 1.0 + 1e-5);
|
||||||
float eta = backfacing() ? 1.0 / f: f;
|
float eta = backfacing() ? 1.0 / f: f;
|
||||||
float Fr = fresnel_dielectric(I, Normal, eta);
|
float cosi = dot(I, Normal);
|
||||||
|
float Fr = fresnel_dielectric_cos(cosi, eta);
|
||||||
|
|
||||||
if (distribution == "Sharp")
|
if (distribution == "Sharp")
|
||||||
BSDF = Color * (Fr * reflection(Normal) + (1.0 - Fr) * refraction(Normal, eta));
|
BSDF = Color * (Fr * reflection(Normal) + (1.0 - Fr) * refraction(Normal, eta));
|
||||||
|
@ -26,14 +26,15 @@ shader node_layer_weight(
|
|||||||
output float Facing = 0.0)
|
output float Facing = 0.0)
|
||||||
{
|
{
|
||||||
float blend = Blend;
|
float blend = Blend;
|
||||||
|
float cosi = dot(I, Normal);
|
||||||
|
|
||||||
/* Fresnel */
|
/* Fresnel */
|
||||||
float eta = max(1.0 - Blend, 1e-5);
|
float eta = max(1.0 - Blend, 1e-5);
|
||||||
eta = backfacing() ? eta : 1.0 / eta;
|
eta = backfacing() ? eta : 1.0 / eta;
|
||||||
Fresnel = fresnel_dielectric(I, Normal, eta);
|
Fresnel = fresnel_dielectric_cos(cosi, eta);
|
||||||
|
|
||||||
/* Facing */
|
/* Facing */
|
||||||
Facing = abs(dot(I, Normal));
|
Facing = fabs(cosi);
|
||||||
|
|
||||||
if (blend != 0.5) {
|
if (blend != 0.5) {
|
||||||
blend = clamp(blend, 0.0, 1.0 - 1e-5);
|
blend = clamp(blend, 0.0, 1.0 - 1e-5);
|
||||||
|
Loading…
Reference in New Issue
Block a user