-
Notifications
You must be signed in to change notification settings - Fork 2
/
gradientbg.cu
67 lines (53 loc) · 2.34 KB
/
gradientbg.cu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved.
*
* NVIDIA Corporation and its licensors retain all intellectual property and proprietary
* rights in and to this software, related documentation and any modifications thereto.
* Any use, reproduction, disclosure or distribution of this software and related
* documentation without an express license agreement from NVIDIA Corporation is strictly
* prohibited.
*
* TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS*
* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED,
* INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY
* SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT
* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF
* BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
* INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGES
*/
#include <optix.h>
#include <optixu/optixu_math_namespace.h>
using namespace optix;
rtDeclareVariable(float3, background_light, , ); // horizon color
rtDeclareVariable(float3, background_dark, , ); // zenith color
rtDeclareVariable(float3, up, , ); // global up vector
rtDeclareVariable(optix::Ray, ray, rtCurrentRay, );
struct PerRayData_radiance
{
float3 result;
float importance;
int depth;
};
rtDeclareVariable(PerRayData_radiance, prd_radiance, rtPayload, );
// -----------------------------------------------------------------------------
RT_PROGRAM void miss()
{
/*
const float t = max(dot(ray.direction, up), 0.0f);
const float3 result = lerp(background_light, background_dark, t);
prd_radiance.result = result;
*/
// for the kitchen scene at night
// prd_radiance.result = make_float3(0, 0, 0.06);
prd_radiance.result = make_float3(0.2);
}
rtTextureSampler<float4, 2> envmap;
RT_PROGRAM void envmap_miss() {
float theta = atan2f( ray.direction.x, ray.direction.z );
float phi = M_PIf * 0.5f - acosf( ray.direction.y );
float u = (theta + M_PIf) * (0.5f * M_1_PIf);
float v = 0.5f * ( 1.0f + sin(phi) );
prd_radiance.result = make_float3( tex2D(envmap, u, v) );
}