mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 09:23:17 +02:00
Friday night build, working on getting the LUT generated on the GPU
This commit is contained in:
parent
ec68eba3cb
commit
a619a142ed
12 changed files with 62 additions and 23 deletions
|
@ -462,7 +462,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
QVector<ExtractedBlendshape> blendshapes;
|
||||
|
||||
QHash<QString, FBXModel> models;
|
||||
QHash<QString, Cluster> clusters;
|
||||
QHash<QString, Cluster> clusters;
|
||||
QHash<QString, AnimationCurve> animationCurves;
|
||||
|
||||
QHash<QString, QString> typeFlags;
|
||||
|
|
|
@ -228,8 +228,8 @@ vec3 evalSkyboxGlobalColorScattering(mat4 invViewMat, float shadowAttenuation, f
|
|||
if ( showBRDF())
|
||||
return brdf;
|
||||
|
||||
vec3 debugNdotL = 0.5 * (NdotLSpectrum + vec3(1.0));
|
||||
return vec3(debugNdotL.z, curvature, 0.0 );
|
||||
//vec3 debugNdotL = 0.5 * (NdotLSpectrum + vec3(1.0));
|
||||
//return vec3(debugNdotL.z, curvature, 0.0 );
|
||||
|
||||
return vec3(color);
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@ public:
|
|||
float curvatureScale{ 0.8f };
|
||||
|
||||
bool enableScattering{ true };
|
||||
bool showScatteringBRDF{ false };
|
||||
bool showScatteringBRDF{ true };
|
||||
|
||||
bool enablePointLights{ true };
|
||||
bool enableSpotLights{ true };
|
||||
|
|
|
@ -401,10 +401,7 @@ void diffuseScatterGPU(gpu::TexturePointer& profileMap, gpu::TexturePointer& lut
|
|||
gpu::Shader::makeProgram(*program, slotBindings);
|
||||
|
||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||
|
||||
// Stencil test the curvature pass for objects pixels only, not the background
|
||||
// state->setStencilTest(true, 0xFF, gpu::State::StencilTest(0, 0xFF, gpu::NOT_EQUAL, gpu::State::STENCIL_OP_KEEP, gpu::State::STENCIL_OP_KEEP, gpu::State::STENCIL_OP_KEEP));
|
||||
|
||||
|
||||
makePipeline = gpu::Pipeline::create(program, state);
|
||||
}
|
||||
|
||||
|
@ -469,8 +466,8 @@ gpu::TexturePointer SubsurfaceScatteringResource::generatePreIntegratedScatterin
|
|||
|
||||
const int WIDTH = 128;
|
||||
const int HEIGHT = 128;
|
||||
auto scatteringLUT = gpu::TexturePointer(gpu::Texture::create2D(gpu::Element::COLOR_RGBA_32, WIDTH, HEIGHT, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR)));
|
||||
diffuseScatter(scatteringLUT);
|
||||
//diffuseScatterGPU(profileMap, scatteringLUT, args);
|
||||
auto scatteringLUT = gpu::TexturePointer(gpu::Texture::create2D(gpu::Element::COLOR_SRGBA_32, WIDTH, HEIGHT, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR)));
|
||||
//diffuseScatter(scatteringLUT);
|
||||
diffuseScatterGPU(profileMap, scatteringLUT, args);
|
||||
return scatteringLUT;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ protected:
|
|||
glm::vec4 normalBentInfo{ 1.5f, 0.8f, 0.3f, 1.5f };
|
||||
glm::vec2 curvatureInfo{ 0.08f, 0.8f };
|
||||
float level{ 1.0f };
|
||||
float showBRDF{ 0.0f };
|
||||
float showBRDF{ 1.0f };
|
||||
|
||||
Parameters() {}
|
||||
};
|
||||
|
|
|
@ -51,4 +51,5 @@ float unpackCurvature(float packedCurvature) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
<@endfunc@>
|
||||
|
|
|
@ -26,7 +26,7 @@ class SurfaceGeometryPassConfig : public render::Job::Config {
|
|||
public:
|
||||
SurfaceGeometryPassConfig() : render::Job::Config(true) {}
|
||||
|
||||
float depthThreshold{ 0.1f };
|
||||
float depthThreshold{ 0.033f };
|
||||
float basisScale{ 1.0f };
|
||||
float curvatureScale{ 10.0f };
|
||||
|
||||
|
|
|
@ -14,9 +14,40 @@ const float _PI = 3.14159265358979523846;
|
|||
|
||||
|
||||
uniform sampler2D profileMap;
|
||||
/*
|
||||
vec3 scatter(float r) {
|
||||
return texture(profileMap, vec2(2.0 * r, 0.5)).xyz;
|
||||
}
|
||||
*/
|
||||
|
||||
float gaussian(float v, float r) {
|
||||
return (1.0 / sqrt(2.0 * _PI * v)) * exp(-(r*r) / (2.0 * v));
|
||||
}
|
||||
|
||||
vec3 scatter(float r) {
|
||||
return texture(profileMap, vec2(r * 0.5, 0.5)).xyz;
|
||||
// Values from GPU Gems 3 "Advanced Skin Rendering".
|
||||
// Originally taken from real life samples.
|
||||
vec4 profile[6] = vec4[6](
|
||||
vec4(0.0064, 0.233, 0.455, 0.649),
|
||||
vec4(0.0484, 0.100, 0.336, 0.344),
|
||||
vec4(0.1870, 0.118, 0.198, 0.000),
|
||||
vec4(0.5670, 0.113, 0.007, 0.007),
|
||||
vec4(1.9900, 0.358, 0.004, 0.000),
|
||||
vec4(7.4100, 0.078, 0.000, 0.000)
|
||||
);
|
||||
//const int profileNum = 6;
|
||||
|
||||
|
||||
|
||||
|
||||
vec3 ret(0.0);
|
||||
for (int i = 0; i < 6; i++) {
|
||||
float v = profile[i].x * 1.414;
|
||||
float g = gaussian(v, r);
|
||||
ret += g * profile[i].yzw;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -32,15 +63,15 @@ vec3 integrate(float cosTheta, float skinRadius) {
|
|||
|
||||
while (a <= (_PI)) {
|
||||
float sampleAngle = theta + a;
|
||||
float diffuse = cos(sampleAngle);
|
||||
if (diffuse < 0.0) diffuse = 0.0;
|
||||
if (diffuse > 1.0) diffuse = 1.0;
|
||||
float diffuse = clamp(cos(sampleAngle), 0.0, 1.0);
|
||||
//if (diffuse < 0.0) diffuse = 0.0;
|
||||
//if (diffuse > 1.0) diffuse = 1.0;
|
||||
|
||||
// Distance.
|
||||
float sampleDist = abs(2.0 * skinRadius * sin(a * 0.5));
|
||||
|
||||
// Profile Weight.
|
||||
vec3 weights = scatter(sampleDist);
|
||||
vec3 weights = scatter( sampleDist);
|
||||
|
||||
totalWeights += weights;
|
||||
totalLight += diffuse * weights;
|
||||
|
@ -48,7 +79,8 @@ vec3 integrate(float cosTheta, float skinRadius) {
|
|||
}
|
||||
|
||||
vec3 result = (totalLight / totalWeights);
|
||||
|
||||
return clamp(result, vec3(0.0), vec3(1.0));
|
||||
|
||||
return min(sqrt(result), vec3(1.0));
|
||||
|
||||
return scatter(skinRadius);
|
||||
|
@ -59,6 +91,10 @@ out vec4 outFragColor;
|
|||
|
||||
void main(void) {
|
||||
|
||||
// Lookup by: x: NDotL y: 1 / r
|
||||
//float y = 2.0 * 1.0 / ((j + 1.0) / (double)height);
|
||||
//float x = ((i / (double)width) * 2.0) - 1.0;
|
||||
|
||||
outFragColor = vec4(integrate(varTexCoord0.x * 2.0 - 1.0, 2.0 / varTexCoord0.y), 1.0);
|
||||
}
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ void main(void) {
|
|||
|
||||
// Calculate dF/du and dF/dv
|
||||
vec2 viewportScale = perspectiveScale * getInvWidthHeight();
|
||||
vec2 du = vec2( viewportScale.x, 0.0f );
|
||||
vec2 du = vec2( viewportScale.x * (stereoSide.w > 0.0 ? 0.5 : 1.0), 0.0f );
|
||||
vec2 dv = vec2( 0.0f, viewportScale.y );
|
||||
|
||||
vec4 dFdu = vec4(getWorldNormalDiff(frameTexcoordPos, du), getEyeDepthDiff(frameTexcoordPos, du));
|
||||
|
|
|
@ -118,7 +118,7 @@ void QmlWindowClass::initQml(QVariantMap properties) {
|
|||
}
|
||||
|
||||
bool visible = !properties.contains(VISIBILE_PROPERTY) || properties[VISIBILE_PROPERTY].toBool();
|
||||
object->setProperty(VISIBILE_PROPERTY, visible);
|
||||
object->setProperty(OFFSCREEN_VISIBILITY_PROPERTY, visible);
|
||||
object->setProperty(SOURCE_PROPERTY, _source);
|
||||
|
||||
// Forward messages received from QML on to the script
|
||||
|
|
|
@ -39,8 +39,8 @@ Item {
|
|||
|
||||
Label {
|
||||
text: sliderControl.value.toFixed(root.integral ? 0 : 2)
|
||||
anchors.left: root.labelControl.right
|
||||
anchors.leftMargin: 8
|
||||
anchors.left: root.left
|
||||
anchors.leftMargin: 200
|
||||
anchors.top: root.top
|
||||
anchors.topMargin: 7
|
||||
}
|
||||
|
|
|
@ -57,6 +57,11 @@ Column {
|
|||
min: 0.0
|
||||
}
|
||||
}
|
||||
CheckBox {
|
||||
text: "Scattering Table"
|
||||
checked: Render.getConfig("Scattering").showLUT
|
||||
onCheckedChanged: { Render.getConfig("Scattering").showLUT = checked }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue