Commit b226a945 authored by MURRAY David's avatar MURRAY David
Browse files

fix for ggx

parent 42dc7378
......@@ -191,11 +191,6 @@ optix::Material OptixMaterialHandler::createMaterialFromMRF(
variable_values.push_back(fresnel_mirror->kappa());
#ifdef MRF_RENDERING_MODE_SPECTRAL
//Only needed in spectral mode
variable_names.push_back("_inv_transmittance_PDF");
variable_values.push_back(mrf::materials::COLOR(0.f));
optix_mat["_trans_cdf_tex_id"]->setInt(-1);
setCustomRadianceVariables(optix_mat, material, variable_values, variable_names, wavelengths);
#else
setCustomRadianceVariables(optix_mat, variable_values, variable_names);
......@@ -204,7 +199,6 @@ optix::Material OptixMaterialHandler::createMaterialFromMRF(
optix_mat["_alpha_g"]->setFloat(0.f); //Fresnel mirror is perfectly flat microfacet
optix_mat["_sqr_alpha_g"]->setFloat(0.f);
optix_mat["_distribution"]->setInt(0); //HARDCODED FOR NOW: 0 = GGX distribution.
optix_mat["_is_conductor"]->setInt(1); //HARDCODED FOR NOW: 1 = true.
compile_options.push_back("-DMICROFACET_CONDUCTOR");
compileBRDF(optix_mat, compile_options);
......@@ -296,7 +290,6 @@ optix::Material OptixMaterialHandler::createMaterialFromMRF(
optix_mat["_alpha_g"]->setFloat(alpha_g); //Fresnel glass is smooth glass
optix_mat["_sqr_alpha_g"]->setFloat(alpha_g * alpha_g);
optix_mat["_distribution"]->setInt(0); //HARDCODED FOR NOW: 0 = GGX distribution.
optix_mat["_is_conductor"]->setInt(0); //HARDCODED FOR NOW: 0 = false.
optix_mat["_thickness"]->setFloat(0.f);
compile_options.push_back("-DMICROFACET_DIELECTRIC");
......@@ -316,11 +309,6 @@ optix::Material OptixMaterialHandler::createMaterialFromMRF(
variable_values.push_back(mrf::materials::COLOR(0.f));
#ifdef MRF_RENDERING_MODE_SPECTRAL
//Only needed in spectral mode
variable_names.push_back("_inv_transmittance_PDF");
variable_values.push_back(mrf::materials::COLOR(0.f));
optix_mat["_trans_cdf_tex_id"]->setInt(-1);
setCustomRadianceVariables(optix_mat, material, variable_values, variable_names, wavelengths);
#else
setCustomRadianceVariables(optix_mat, variable_values, variable_names);
......@@ -329,7 +317,6 @@ optix::Material OptixMaterialHandler::createMaterialFromMRF(
optix_mat["_alpha_g"]->setFloat(0.f); //Fresnel mirror is perfectly flat microfacet
optix_mat["_sqr_alpha_g"]->setFloat(0.f);
optix_mat["_distribution"]->setInt(0); //HARDCODED FOR NOW: 0 = GGX distribution.
optix_mat["_is_conductor"]->setInt(1); //HARDCODED FOR NOW: 1 = true.
compile_options.push_back("-DMICROFACET_CONDUCTOR");
compileBRDF(optix_mat, compile_options);
......@@ -345,14 +332,8 @@ optix::Material OptixMaterialHandler::createMaterialFromMRF(
std::vector<mrf::materials::RADIANCE_TYPE> variable_values;
variable_values.push_back(ggx->eta());
variable_values.push_back(ggx->k());
variable_values.push_back(mrf::materials::COLOR(0.f));
#ifdef MRF_RENDERING_MODE_SPECTRAL
//Only needed in spectral mode
variable_names.push_back("_inv_transmittance_PDF");
variable_values.push_back(mrf::materials::COLOR(0.f));
optix_mat["_trans_cdf_tex_id"]->setInt(-1);
setCustomRadianceVariables(optix_mat, material, variable_values, variable_names, wavelengths);
#else
setCustomRadianceVariables(optix_mat, variable_values, variable_names);
......@@ -361,7 +342,6 @@ optix::Material OptixMaterialHandler::createMaterialFromMRF(
optix_mat["_alpha_g"]->setFloat(ggx->alpha_g());
optix_mat["_sqr_alpha_g"]->setFloat(ggx->alpha_g() * ggx->alpha_g());
optix_mat["_distribution"]->setInt(0); //HARDCODED FOR NOW: 0 = GGX distribution.
optix_mat["_is_conductor"]->setInt(1); //HARDCODED FOR NOW: 1 = true.
compile_options.push_back("-DMICROFACET_CONDUCTOR");
compileBRDF(optix_mat, compile_options);
......@@ -1177,11 +1157,6 @@ void OptixMaterialHandler::updateMaterials()
std::vector<mrf::materials::RADIANCE_TYPE> radiances;
radiances.push_back(ggx->eta());
radiances.push_back(ggx->k());
radiances.push_back(mrf::materials::COLOR(0.f));
# ifdef MRF_RENDERING_MODE_SPECTRAL
radiances.push_back(mrf::materials::COLOR(0.f));
# endif
updateRadianceGPUBuffer(material, radiances, wavelengths);
continue;
......@@ -1199,6 +1174,7 @@ void OptixMaterialHandler::updateMaterials()
# ifdef MRF_RENDERING_MODE_SPECTRAL
radiances.push_back(walter->getInvTransPDF(wavelengths));
# endif
updateRadianceGPUBuffer(material, radiances, wavelengths);
continue;
}
......@@ -1209,11 +1185,6 @@ void OptixMaterialHandler::updateMaterials()
std::vector<mrf::materials::RADIANCE_TYPE> radiances;
radiances.push_back(fresnel_mirror->eta());
radiances.push_back(fresnel_mirror->kappa());
radiances.push_back(mrf::materials::COLOR(0.f));
# ifdef MRF_RENDERING_MODE_SPECTRAL
radiances.push_back(mrf::materials::COLOR(0.f));
# endif
updateRadianceGPUBuffer(material, radiances, wavelengths);
continue;
......
......@@ -46,6 +46,7 @@ rtBuffer<int3> index_buffer;
rtBuffer<uint> material_buffer;
rtDeclareVariable(float3, tangent, attribute tangent, );
rtDeclareVariable(float3, bitangent, attribute bitangent, );
rtDeclareVariable(float3, texcoord, attribute texcoord, );
rtDeclareVariable(float3, geometric_normal, attribute geometric_normal, );
rtDeclareVariable(float3, shading_normal, attribute shading_normal, );
......@@ -99,7 +100,16 @@ static __device__ void meshIntersect(int primIdx)
if (tangent_buffer.size() == 0)
{
tangent = make_float3(0.0f, 0.0f, 0.0f);
const float3 n = geometric_normal;
if (n.z < -0.9999f) //Singularity
{
tangent = make_float3(0.f, 1.f, 0.f);
}
else
{
tangent = normalize(cross(make_float3(0.f, 1.f, 0.f), n));
}
bitangent = normalize(cross(n, tangent));
}
else
{
......@@ -107,6 +117,7 @@ static __device__ void meshIntersect(int primIdx)
float3 t1 = tangent_buffer[v_idx.y];
float3 t2 = tangent_buffer[v_idx.z];
tangent = normalize(t1 * beta + t2 * gamma + t0 * (1.0f - beta - gamma));
bitangent = cross(geometric_normal, tangent);
}
if (DO_REFINE)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment