mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 15:09:24 +02:00
save current state
This commit is contained in:
parent
7bd686167e
commit
0b873365ed
3 changed files with 35 additions and 5 deletions
|
@ -301,6 +301,7 @@ void DebugDeferredBuffer::run(const SceneContextPointer& sceneContext, const Ren
|
||||||
|
|
||||||
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
|
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
|
||||||
batch.enableStereo(false);
|
batch.enableStereo(false);
|
||||||
|
batch.setViewportTransform(args->_viewport);
|
||||||
|
|
||||||
const auto geometryBuffer = DependencyManager::get<GeometryCache>();
|
const auto geometryBuffer = DependencyManager::get<GeometryCache>();
|
||||||
const auto framebufferCache = DependencyManager::get<FramebufferCache>();
|
const auto framebufferCache = DependencyManager::get<FramebufferCache>();
|
||||||
|
|
|
@ -144,9 +144,7 @@ vec3 integrate(double cosTheta, double skinRadius) {
|
||||||
|
|
||||||
double a = -(_PI);
|
double a = -(_PI);
|
||||||
|
|
||||||
double inc = 0.001;
|
double inc = 0.1;
|
||||||
if (cosTheta > 0)
|
|
||||||
inc = 0.01;
|
|
||||||
|
|
||||||
while (a <= (_PI)) {
|
while (a <= (_PI)) {
|
||||||
double sampleAngle = theta + a;
|
double sampleAngle = theta + a;
|
||||||
|
@ -304,7 +302,7 @@ gpu::TexturePointer SubsurfaceScattering::generatePreIntegratedScattering(Render
|
||||||
const int WIDTH = 128;
|
const int WIDTH = 128;
|
||||||
const int HEIGHT = 128;
|
const int HEIGHT = 128;
|
||||||
auto scatteringLUT = gpu::TexturePointer(gpu::Texture::create2D(gpu::Element::COLOR_RGBA_32, WIDTH, HEIGHT));
|
auto scatteringLUT = gpu::TexturePointer(gpu::Texture::create2D(gpu::Element::COLOR_RGBA_32, WIDTH, HEIGHT));
|
||||||
// diffuseScatter(scatteringLUT);
|
// diffuseScatter(scatteringLUT);
|
||||||
diffuseScatterGPU(profileMap, scatteringLUT, args);
|
diffuseScatterGPU(profileMap, scatteringLUT, args);
|
||||||
return scatteringLUT;
|
return scatteringLUT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,11 +20,42 @@ vec3 scatter(float r) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vec3 integrate(float cosTheta, float skinRadius) {
|
||||||
|
// Angle from lighting direction.
|
||||||
|
float theta = acos(cosTheta);
|
||||||
|
vec3 totalWeights = vec3(0.0);
|
||||||
|
vec3 totalLight= vec3(0.0);
|
||||||
|
vec3 skinColour = vec3(1.0);
|
||||||
|
|
||||||
|
float a = -(_PI);
|
||||||
|
|
||||||
|
float inc = 0.1;
|
||||||
|
|
||||||
|
while (a <= (_PI)) {
|
||||||
|
float sampleAngle = theta + a;
|
||||||
|
float diffuse = clamp(cos(sampleAngle), 0.0, 1.0);
|
||||||
|
|
||||||
|
// Distance.
|
||||||
|
float sampleDist = abs(2.0 * skinRadius * sin(a * 0.5));
|
||||||
|
|
||||||
|
// Profile Weight.
|
||||||
|
vec3 weights = scatter(sampleDist);
|
||||||
|
|
||||||
|
totalWeights += weights;
|
||||||
|
totalLight += diffuse * weights /** (skinColour * skinColour)*/;
|
||||||
|
a += inc;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 result = sqrt(totalLight / totalWeights);
|
||||||
|
|
||||||
|
return min(result, vec3(1.0));
|
||||||
|
}
|
||||||
|
|
||||||
in vec2 varTexCoord0;
|
in vec2 varTexCoord0;
|
||||||
out vec4 outFragColor;
|
out vec4 outFragColor;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
|
|
||||||
outFragColor = vec4(scatter(varTexCoord0.x * 2.0), 1.0);
|
outFragColor = vec4(integrate(varTexCoord0.x * 2.0 - 1, 2.0 * varTexCoord0.y), 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue