Improve pathtracer
This commit is contained in:
Binary file not shown.
@@ -3,11 +3,11 @@
|
||||
#define _EMISSION
|
||||
#define _SUBSURFACE
|
||||
#define _TRANSLUCENCY
|
||||
#define _FRESNEL
|
||||
#define _ROULETTE
|
||||
#define _TRANSPARENCY
|
||||
#endif
|
||||
#define _FRESNEL
|
||||
#define _RENDER
|
||||
// #define _ROULETTE
|
||||
// #define _TRANSPARENCY
|
||||
|
||||
using namespace metal;
|
||||
using namespace raytracing;
|
||||
@@ -282,7 +282,7 @@ kernel void raytracingKernel(
|
||||
#endif
|
||||
|
||||
#ifdef _FRESNEL
|
||||
float specularChance = fresnel(ray.direction, n);
|
||||
float specularChance = fresnel(n, ray.direction);
|
||||
#else
|
||||
const float specularChance = 0.5;
|
||||
#endif
|
||||
@@ -299,11 +299,20 @@ kernel void raytracingKernel(
|
||||
float dotNV = max(dot(n, v), 0.0);
|
||||
float3 specular = surfaceSpecular(texcolor, texpaint2.b);
|
||||
payload.color.xyz *= envBRDFApprox(specular, texpaint2.g, dotNV);
|
||||
#ifdef _FRESNEL
|
||||
payload.color.xyz /= specularChance;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
payload.ray_dir = diffuseDir;
|
||||
payload.color.xyz *= surfaceAlbedo(texcolor, texpaint2.b);
|
||||
#ifdef _FRESNEL
|
||||
payload.color.xyz /= 1.0 - specularChance;
|
||||
#endif
|
||||
}
|
||||
#ifdef _FRESNEL
|
||||
payload.color.xyz *= 0.5;
|
||||
#endif
|
||||
|
||||
payload.ray_origin = hit_world_position(ray, intersection) + payload.ray_dir * 0.0001f;
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -4,11 +4,11 @@
|
||||
#define _EMISSION
|
||||
#define _SUBSURFACE
|
||||
#define _TRANSLUCENCY
|
||||
#define _FRESNEL
|
||||
#define _ROULETTE
|
||||
#define _TRANSPARENCY
|
||||
#endif
|
||||
#define _FRESNEL
|
||||
#define _RENDER
|
||||
// #define _ROULETTE
|
||||
// #define _TRANSPARENCY
|
||||
|
||||
using namespace metal;
|
||||
using namespace raytracing;
|
||||
@@ -283,7 +283,7 @@ kernel void raytracingKernel(
|
||||
#endif
|
||||
|
||||
#ifdef _FRESNEL
|
||||
float specularChance = fresnel(ray.direction, n);
|
||||
float specularChance = fresnel(n, ray.direction);
|
||||
#else
|
||||
const float specularChance = 0.5;
|
||||
#endif
|
||||
@@ -300,11 +300,20 @@ kernel void raytracingKernel(
|
||||
float dotNV = max(dot(n, v), 0.0);
|
||||
float3 specular = surfaceSpecular(texcolor, texpaint2.b);
|
||||
payload.color.xyz *= envBRDFApprox(specular, texpaint2.g, dotNV);
|
||||
#ifdef _FRESNEL
|
||||
payload.color.xyz /= specularChance;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
payload.ray_dir = diffuseDir;
|
||||
payload.color.xyz *= surfaceAlbedo(texcolor, texpaint2.b);
|
||||
#ifdef _FRESNEL
|
||||
payload.color.xyz /= 1.0 - specularChance;
|
||||
#endif
|
||||
}
|
||||
#ifdef _FRESNEL
|
||||
payload.color.xyz *= 0.5;
|
||||
#endif
|
||||
|
||||
payload.ray_origin = hit_world_position(ray, intersection) + payload.ray_dir * 0.0001f;
|
||||
|
||||
|
||||
Binary file not shown.
@@ -3,11 +3,11 @@
|
||||
#define _EMISSION
|
||||
#define _SUBSURFACE
|
||||
#define _TRANSLUCENCY
|
||||
#define _FRESNEL
|
||||
#define _ROULETTE
|
||||
#define _TRANSPARENCY
|
||||
#endif
|
||||
#define _FRESNEL
|
||||
// #define _RENDER
|
||||
// #define _ROULETTE
|
||||
// #define _TRANSPARENCY
|
||||
|
||||
#include "std/rand.hlsl"
|
||||
#include "std/attrib.hlsl"
|
||||
@@ -211,7 +211,7 @@ void closesthit(inout RayPayload payload, in BuiltInTriangleIntersectionAttribut
|
||||
#endif
|
||||
|
||||
#ifdef _FRESNEL
|
||||
float specularChance = fresnel(WorldRayDirection(), n);
|
||||
float specularChance = fresnel(n, WorldRayDirection());
|
||||
#else
|
||||
const float specularChance = 0.5;
|
||||
#endif
|
||||
@@ -228,11 +228,20 @@ void closesthit(inout RayPayload payload, in BuiltInTriangleIntersectionAttribut
|
||||
float dotNV = max(dot(n, v), 0.0);
|
||||
float3 specular = surfaceSpecular(texcolor, texpaint2.b);
|
||||
payload.color.xyz *= envBRDFApprox(specular, texpaint2.g, dotNV);
|
||||
#ifdef _FRESNEL
|
||||
payload.color.xyz /= specularChance;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
payload.ray_dir = diffuseDir;
|
||||
payload.color.xyz *= surfaceAlbedo(texcolor, texpaint2.b);
|
||||
#ifdef _FRESNEL
|
||||
payload.color.xyz /= 1.0 - specularChance;
|
||||
#endif
|
||||
}
|
||||
#ifdef _FRESNEL
|
||||
payload.color.xyz *= 0.5;
|
||||
#endif
|
||||
|
||||
payload.ray_origin = hit_world_position() + payload.ray_dir * 0.0001f;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user