-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
switch brdf and phase function by normal magnitude
- Loading branch information
孙万捷
authored and
孙万捷
committed
May 25, 2016
1 parent
c7d5445
commit 52333b1
Showing
8 changed files
with
147 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// Created by 孙万捷 on 16/5/25. | ||
// | ||
|
||
#ifndef SUNVOLUMERENDER_FRESNEL_H | ||
#define SUNVOLUMERENDER_FRESNEL_H | ||
|
||
#include <cuda_runtime.h> | ||
|
||
__inline__ __device__ float schlick_fresnel(float ni, float no, float cosin) | ||
{ | ||
float R0 = (ni - no) * (ni - no) / ((ni + no) * (ni + no)); | ||
float c = 1.f - cosin; | ||
return R0 + (1.f - R0) * c * c * c * c * c; | ||
} | ||
|
||
#endif //SUNVOLUMERENDER_FRESNEL_H |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// Created by 孙万捷 on 16/5/24. | ||
// | ||
|
||
#ifndef SUNVOLUMERENDER_PHONG_H | ||
#define SUNVOLUMERENDER_PHONG_H | ||
|
||
#define GLM_FORCE_INLINE | ||
#include <glm/glm.hpp> | ||
|
||
#include <cuda_runtime.h> | ||
#include <curand_kernel.h> | ||
|
||
#include "../sampling.h" | ||
|
||
__inline__ __device__ float phong_brdf_f(const glm::vec3& wo, const glm::vec3& wi, const glm::vec3& normal, float e) | ||
{ | ||
auto r = glm::reflect(-wo, normal); | ||
float cosTerm = fmaxf(0.f, glm::dot(r, wi)); | ||
|
||
return powf(cosTerm, e); | ||
} | ||
|
||
__inline__ __device__ float phong_brdf_pdf(const glm::vec3& r, const glm::vec3& wi, float e) | ||
{ | ||
float cosTerm = glm::dot(r, wi); | ||
if(cosTerm <= 0.f) | ||
return 0.f; | ||
|
||
return (e + 1.f) * 0.5f * M_1_PI * powf(cosTerm, e); | ||
} | ||
|
||
__inline__ __device__ void phong_brdf_sample_f(float e, const glm::vec3& normal, const glm::vec3& wo, glm::vec3* wi, float* pdf, curandState& rng) | ||
{ | ||
auto r = glm::reflect(-wo, normal); | ||
*wi = sample_phong(rng, e, r); | ||
|
||
if(pdf) | ||
*pdf = phong_brdf_pdf(r, *wi, e); | ||
} | ||
|
||
#endif //SUNVOLUMERENDER_PHONG_H |
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