POV-Ray / povray

The Persistence of Vision Raytracer: http://www.povray.org/
GNU Affero General Public License v3.0
1.35k stars 282 forks source link

Speckles visible in transparent background #364

Closed mjhorvath closed 6 years ago

mjhorvath commented 6 years ago

Summary

Turning on focal blur in an orthographic render with alpha channel causes artifacts in the scene background. See thread:

http://news.povray.org/povray.general/thread/%3C5b69ffde%241%40news.povray.org%3E/

Environment

Steps to Reproduce

  1. Set the camera to orthographic
  2. Set the camera to do focal blur
  3. Turn on the alpha channel
    1. Remove the background and sky_sphere, and create a new "sky sphere" like this:
sphere
{
    0, 1
    pigment
    {
        gradient y
        color_map
        {
            [0/4 color srgb (<0.6,0.7,1.0>+1)/2]
            [3/4 color srgb (<0.0,0.1,0.8>+1)/2]
        }
    }
    finish
    {
        diffuse        0
        ambient        0
        emission    1
        reflection    0
    }
    scale 2048*16
    no_image
} 

Expected Behavior

Since the custom sky sphere has the no_image tag, it should only be visible in reflections, and the image background should be transparent.

Actual Behavior

There are visible speckles in the scene background.

Render Settings

    Jitter=off
    Display_Gamma=sRGB
    File_Gamma=sRGB
    Preview_Start_Size=32
    Preview_End_Size=16
    Render_Block_Size=16
    Render_Pattern=3
    Output_File_Name="D:\\POVray Images\\"
    Output_File_Type=N
    Output_to_File=on
    Debug_File=on
    Work_Threads=3
    Width=1024
    Height=1024
    Antialias=On
    Antialias_Threshold=0.3
    Output_Alpha=On

Scene

// This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
// To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a
// letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.

#version 3.7;

#include "logo.inc"
#include "transforms.inc"
#include "finish.inc"

global_settings
{
    radiosity
    {
        always_sample   off
        brightness      0.3
    }
    ambient_light   0
    charset         utf8
    assumed_gamma   1
}

sphere
{
    0, 1
    pigment
    {
        gradient y
        color_map
        {
            [0/4 color srgb (<0.6,0.7,1.0>+1)/2]
            [3/4 color srgb (<0.0,0.1,0.8>+1)/2]
        }
    }
    finish
    {
        diffuse     0
        ambient     0
        emission    1
        reflection  0
    }
    scale 2048*16
    no_image
}

plane
{
    y, -1
    texture
    {
        pigment
        {
            checker
            color srgb 1
            color srgb (z+1)/2
        }
        finish
        {
            diffuse 0.8
            ambient 0.1
        }
        scale 1/2
    }
}

camera
{
    orthographic
    location        -z * 4
    direction       +z * 4
    up              +y * 2
    right           +x * 2 * image_width/image_height
//  focal_point     <0,0,0>
//  aperture        1/16
//  blur_samples    512
//  confidence      15/16
//  variance        1/256
}

light_source
{
    <+3,+4,-5,> * +1024,
    2
    parallel
    point_at z
}

light_source
{
    <+3,-4,-5,> * -1024,
    1
    parallel
    point_at z
}

object
{
    Povray_Logo
    pigment
    {
        planar
        color_map
        {
            [0.0, color srgb <2/2,1/2,1/2,>]
            [0.5, color srgb <1/2,2/2,1/2,>]
            [1.0, color srgb <1/2,1/2,2/2,>]
        }
        scale 2
        translate y
    }
    translate -z/4
    no_image
    no_shadow
}

sphere
{
    0, 1
    scale z * 1/4
    pigment {color srgb 0}
    finish
    {
        ambient     1/128
        diffuse     1/128
        reflection  7/8
        phong       1
        phong_size  256
        specular    1/8
    }
    translate +z/4
    no_shadow
}
c-lipka commented 6 years ago

The noise is from the camera picking up pretty much every object in the scene except the pseudo sky sphere.

Note that focal blur is only truly well-behaved in the default camera model. With all other camera models, the behaviour is emergent from the focal blur algorithm originally designed for the default camera, combined with whatever the algorithm for the chosen camera happens to be.

The orthographic camera is particularly poorly suited for combining with focal blur, because the camera model wants light rays to be parallel, whereas the focal blur algorithm wants the rays to converge on a plane of maximum focus. Those two are mutually exclusive, so something has to give.

In other words, combining focal blur with the orthographic camera cannot work properly, as long as nobody comes up with a sane specification of what focal blur should actually do in that camera in the first place.

I'll therefore call this not-a-bug and close it. If you have a clear and precise suggestion how focal blur should work in combination with the orthographic camera, feel free to open a new issue as a kind of feature suggestion.