Merge branch 'blender2.8' into soc-2018-bevel
This commit is contained in:
44
.editorconfig
Normal file
44
.editorconfig
Normal file
@@ -0,0 +1,44 @@
|
||||
# C/C++
|
||||
[*.{c,cc,h,hh,inl,glsl}]
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
max_line_length = 120
|
||||
|
||||
# CMake & Text
|
||||
[*.{cmake,txt}]
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
max_line_length = 120
|
||||
|
||||
# Python
|
||||
[*.py]
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
max_line_length = 120
|
||||
|
||||
# Shell
|
||||
[*.sh]
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
max_line_length = 120
|
||||
|
||||
# reStructuredText
|
||||
[*.rst]
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 3
|
||||
max_line_length = 120
|
||||
@@ -227,8 +227,6 @@ option(WITH_SYSTEM_BULLET "Use the systems bullet library (currently unsupported
|
||||
mark_as_advanced(WITH_SYSTEM_BULLET)
|
||||
option(WITH_OPENCOLORIO "Enable OpenColorIO color management" ${_init_OPENCOLORIO})
|
||||
|
||||
option(WITH_CLAY_ENGINE "Enable Clay engine" ON)
|
||||
|
||||
# Compositor
|
||||
option(WITH_COMPOSITOR "Enable the tile based nodal compositor" ON)
|
||||
|
||||
@@ -460,11 +458,13 @@ endif()
|
||||
|
||||
# OpenGL
|
||||
|
||||
option(WITH_OPENGL "When off limits visibility of the opengl headers to just bf_gpu and gawain (temporary option for development purposes)" ON)
|
||||
option(WITH_GLEW_ES "Switches to experimental copy of GLEW that has support for OpenGL ES. (temporary option for development purposes)" OFF)
|
||||
option(WITH_GL_EGL "Use the EGL OpenGL system library instead of the platform specific OpenGL system library (CGL, glX, or WGL)" OFF)
|
||||
option(WITH_GL_PROFILE_ES20 "Support using OpenGL ES 2.0. (thru either EGL or the AGL/WGL/XGL 'es20' profile)" OFF)
|
||||
|
||||
mark_as_advanced(
|
||||
WITH_OPENGL
|
||||
WITH_GLEW_ES
|
||||
WITH_GL_EGL
|
||||
WITH_GL_PROFILE_ES20
|
||||
@@ -826,11 +826,11 @@ if (NOT CMAKE_BUILD_TYPE MATCHES "Release")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMPILER_ASAN_CXXFLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${COMPILER_ASAN_CXXFLAGS}")
|
||||
if(MSVC)
|
||||
set(COMPILER_ASAN_LINKER_FLAGS "/FUNCTIONPADMIN:6")
|
||||
set(COMPILER_ASAN_LINKER_FLAGS "/FUNCTIONPADMIN:6")
|
||||
endif()
|
||||
set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS};${COMPILER_ASAN_LIBRARY}")
|
||||
set(PLATFORM_LINKFLAGS "${COMPILER_ASAN_LIBRARY} ${COMPILER_ASAN_LINKER_FLAGS}")
|
||||
set(PLATFORM_LINKFLAGS_DEBUG "${COMPILER_ASAN_LIBRARY} ${COMPILER_ASAN_LINKER_FLAGS}")
|
||||
set(PLATFORM_LINKFLAGS_DEBUG "${COMPILER_ASAN_LIBRARY} ${COMPILER_ASAN_LINKER_FLAGS}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -1005,6 +1005,10 @@ endif()
|
||||
find_package(OpenGL)
|
||||
blender_include_dirs_sys("${OPENGL_INCLUDE_DIR}")
|
||||
|
||||
if(WITH_OPENGL)
|
||||
add_definitions(-DWITH_OPENGL)
|
||||
endif()
|
||||
|
||||
if(WITH_SYSTEM_GLES)
|
||||
find_package_wrapper(OpenGLES)
|
||||
endif()
|
||||
|
||||
@@ -75,7 +75,7 @@ macro(PREFIX_FIND_LIB prefix libname libpath_var liblist_var cachelist_var)
|
||||
# Handle new library names for OpenEXR 2.1 build via cmake
|
||||
string(REPLACE "." "_" _ILMBASE_VERSION ${ILMBASE_VERSION})
|
||||
string(SUBSTRING ${_ILMBASE_VERSION} 0 3 _ILMBASE_VERSION )
|
||||
|
||||
|
||||
find_library(${tmp_prefix}_LIBRARY_RELEASE
|
||||
NAMES ${libname} ${libname}-${_ILMBASE_VERSION}
|
||||
HINTS ${${libpath_var}}
|
||||
@@ -177,7 +177,7 @@ if(ILMBASE_INCLUDE_DIR)
|
||||
"\\1" XYZ ${ILMBASE_BUILD_SPECIFICATION})
|
||||
set("ILMBASE_VERSION" ${XYZ} CACHE STRING "Version of ILMBase lib")
|
||||
else()
|
||||
# Old versions (before 2.0?) do not have any version string, just assuming 2.0 should be fine though.
|
||||
# Old versions (before 2.0?) do not have any version string, just assuming 2.0 should be fine though.
|
||||
message(WARNING "Could not determine ILMBase library version, assuming 2.0.")
|
||||
set("ILMBASE_VERSION" "2.0" CACHE STRING "Version of ILMBase lib")
|
||||
endif()
|
||||
|
||||
@@ -175,7 +175,7 @@ if(OPENEXR_INCLUDE_DIR)
|
||||
"\\1" XYZ ${OPENEXR_BUILD_SPECIFICATION})
|
||||
set("OPENEXR_VERSION" ${XYZ} CACHE STRING "Version of OpenEXR lib")
|
||||
else()
|
||||
# Old versions (before 2.0?) do not have any version string, just assuming 2.0 should be fine though.
|
||||
# Old versions (before 2.0?) do not have any version string, just assuming 2.0 should be fine though.
|
||||
message(WARNING "Could not determine ILMBase library version, assuming 2.0.")
|
||||
set("OPENEXR_VERSION" "2.0" CACHE STRING "Version of OpenEXR lib")
|
||||
endif()
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
# basename_LIBRARY_RELEASE is defined, basename_LIBRARY, basename_LIBRARY_DEBUG,
|
||||
# and basename_LIBRARY_RELEASE will be set to the release value. If only
|
||||
# basename_LIBRARY_DEBUG is defined, then basename_LIBRARY,
|
||||
# basename_LIBRARY_DEBUG and basename_LIBRARY_RELEASE will take the debug value.
|
||||
# basename_LIBRARY_DEBUG and basename_LIBRARY_RELEASE will take the debug value.
|
||||
#
|
||||
# If the generator supports configuration types, then basename_LIBRARY and
|
||||
# basename_LIBRARIES will be set with debug and optimized flags specifying the
|
||||
@@ -53,10 +53,10 @@ macro( select_library_configurations basename )
|
||||
# if the generator supports configuration types or CMAKE_BUILD_TYPE
|
||||
# is set, then set optimized and debug options.
|
||||
if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
|
||||
set( ${basename}_LIBRARY
|
||||
set( ${basename}_LIBRARY
|
||||
optimized ${${basename}_LIBRARY_RELEASE}
|
||||
debug ${${basename}_LIBRARY_DEBUG} )
|
||||
set( ${basename}_LIBRARIES
|
||||
set( ${basename}_LIBRARIES
|
||||
optimized ${${basename}_LIBRARY_RELEASE}
|
||||
debug ${${basename}_LIBRARY_DEBUG} )
|
||||
else( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
|
||||
@@ -67,14 +67,14 @@ macro( select_library_configurations basename )
|
||||
endif( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
|
||||
endif( ${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE )
|
||||
|
||||
set( ${basename}_LIBRARY ${${basename}_LIBRARY} CACHE FILEPATH
|
||||
set( ${basename}_LIBRARY ${${basename}_LIBRARY} CACHE FILEPATH
|
||||
"The ${basename} library" )
|
||||
|
||||
if( ${basename}_LIBRARY )
|
||||
set( ${basename}_FOUND TRUE )
|
||||
endif( ${basename}_LIBRARY )
|
||||
|
||||
mark_as_advanced( ${basename}_LIBRARY
|
||||
mark_as_advanced( ${basename}_LIBRARY
|
||||
${basename}_LIBRARY_RELEASE
|
||||
${basename}_LIBRARY_DEBUG
|
||||
)
|
||||
|
||||
@@ -2,6 +2,7 @@ if NOT "%verbose%" == "" (
|
||||
echo Detecting msvc 2017
|
||||
)
|
||||
set BUILD_VS_VER=15
|
||||
set BUILD_VS_YEAR=2017
|
||||
set ProgramFilesX86=%ProgramFiles(x86)%
|
||||
if not exist "%ProgramFilesX86%" set ProgramFilesX86=%ProgramFiles%
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@ if "%GIT%" == "" (
|
||||
goto EOF
|
||||
)
|
||||
cd "%BLENDER_DIR%"
|
||||
for /f "delims=" %%i in ('%GIT% rev-parse HEAD') do echo Branch_hash=%%i
|
||||
for /f "delims=" %%i in ('"%GIT%" rev-parse HEAD') do echo Branch_hash=%%i
|
||||
cd "%BLENDER_DIR%/release/datafiles/locale"
|
||||
for /f "delims=" %%i in ('%GIT% rev-parse HEAD') do echo Locale_hash=%%i
|
||||
for /f "delims=" %%i in ('"%GIT%" rev-parse HEAD') do echo Locale_hash=%%i
|
||||
cd "%BLENDER_DIR%/release/scripts/addons"
|
||||
for /f "delims=" %%i in ('%GIT% rev-parse HEAD') do echo Addons_Hash=%%i
|
||||
for /f "delims=" %%i in ('"%GIT%" rev-parse HEAD') do echo Addons_Hash=%%i
|
||||
cd "%BLENDER_DIR%"
|
||||
:EOF
|
||||
6
extern/audaspace/CMakeLists.txt
vendored
6
extern/audaspace/CMakeLists.txt
vendored
@@ -88,7 +88,7 @@ set(SRC
|
||||
src/fx/Volume.cpp
|
||||
src/fx/VolumeReader.cpp
|
||||
src/fx/VolumeSound.cpp
|
||||
src/fx/VolumeStorage.cpp
|
||||
src/fx/VolumeStorage.cpp
|
||||
src/generator/Sawtooth.cpp
|
||||
src/generator/SawtoothReader.cpp
|
||||
src/generator/Silence.cpp
|
||||
@@ -729,8 +729,8 @@ set(LIB_DESTINATION "lib${LIB_SUFFIX}")
|
||||
# library
|
||||
|
||||
add_library(audaspace ${LIBRARY_TYPE} ${SRC} ${HDR})
|
||||
target_link_libraries(audaspace ${LIBRARIES})
|
||||
set_target_properties(audaspace PROPERTIES SOVERSION ${AUDASPACE_VERSION})
|
||||
target_link_libraries(audaspace ${LIBRARIES})
|
||||
set_target_properties(audaspace PROPERTIES SOVERSION ${AUDASPACE_VERSION})
|
||||
|
||||
if(AUDASPACE_STANDALONE)
|
||||
install(TARGETS audaspace
|
||||
|
||||
8
extern/xdnd/xdnd.c
vendored
8
extern/xdnd/xdnd.c
vendored
@@ -121,10 +121,10 @@ char *xdnd_debug_milliseconds (void)
|
||||
#define dnd_debug3(a,b,c) printf("%s: %d: %s: " a "\n", __FILE__, __LINE__, xdnd_debug_milliseconds (), b, c)
|
||||
#define dnd_debug4(a,b,c,d) printf("%s: %d: %s: " a "\n", __FILE__, __LINE__, xdnd_debug_milliseconds (), b, c, d)
|
||||
#else
|
||||
#define dnd_debug1(a)
|
||||
#define dnd_debug2(a,b)
|
||||
#define dnd_debug3(a,b,c)
|
||||
#define dnd_debug4(a,b,c,d)
|
||||
#define dnd_debug1(a) do {} while (0)
|
||||
#define dnd_debug2(a,b) do {} while (0)
|
||||
#define dnd_debug3(a,b,c) do {} while (0)
|
||||
#define dnd_debug4(a,b,c,d) do {} while (0)
|
||||
#endif
|
||||
|
||||
#define dnd_warning(a) fprintf (stderr, a)
|
||||
|
||||
@@ -326,6 +326,14 @@ if(WITH_CYCLES_NETWORK)
|
||||
add_definitions(-DWITH_NETWORK)
|
||||
endif()
|
||||
|
||||
if(WITH_OPENCOLORIO)
|
||||
add_definitions(-DWITH_OCIO)
|
||||
include_directories(
|
||||
SYSTEM
|
||||
${OPENCOLORIO_INCLUDE_DIRS}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(WITH_CYCLES_STANDALONE OR WITH_CYCLES_NETWORK OR WITH_CYCLES_CUBIN_COMPILER)
|
||||
add_subdirectory(app)
|
||||
endif()
|
||||
|
||||
@@ -80,6 +80,10 @@ macro(cycles_target_link_libraries target)
|
||||
if(WITH_CYCLES_OPENSUBDIV)
|
||||
target_link_libraries(${target} ${OPENSUBDIV_LIBRARIES})
|
||||
endif()
|
||||
if(WITH_OPENCOLORIO)
|
||||
link_directories(${OPENCOLORIO_LIBPATH})
|
||||
target_link_libraries(${target} ${OPENCOLORIO_LIBRARIES})
|
||||
endif()
|
||||
target_link_libraries(
|
||||
${target}
|
||||
${OPENIMAGEIO_LIBRARIES}
|
||||
|
||||
@@ -39,7 +39,7 @@ set(SRC
|
||||
|
||||
set(ADDON_FILES
|
||||
addon/__init__.py
|
||||
addon/engine.py
|
||||
addon/engine.py
|
||||
addon/osl.py
|
||||
addon/presets.py
|
||||
addon/properties.py
|
||||
|
||||
@@ -128,6 +128,12 @@ enum_volume_interpolation = (
|
||||
('CUBIC', "Cubic", "Smoothed high quality interpolation, but slower")
|
||||
)
|
||||
|
||||
enum_world_mis = (
|
||||
('NONE', "None", "Don't sample the background, faster but might cause noise for non-solid backgrounds"),
|
||||
('AUTOMATIC', "Auto", "Automatically try to determine the best setting"),
|
||||
('MANUAL', "Manual", "Manually set the resolution of the sampling map, higher values are slower and require more memory but reduce noise")
|
||||
)
|
||||
|
||||
enum_device_type = (
|
||||
('CPU', "CPU", "CPU", 0),
|
||||
('CUDA', "CUDA", "CUDA", 1),
|
||||
@@ -932,15 +938,15 @@ class CyclesWorldSettings(bpy.types.PropertyGroup):
|
||||
description="Cycles world settings",
|
||||
type=cls,
|
||||
)
|
||||
cls.sample_as_light = BoolProperty(
|
||||
name="Multiple Importance Sample",
|
||||
description="Use multiple importance sampling for the environment, "
|
||||
"enabling for non-solid colors is recommended",
|
||||
default=True,
|
||||
cls.sampling_method = EnumProperty(
|
||||
name="Sampling method",
|
||||
description="How to sample the background light",
|
||||
items=enum_world_mis,
|
||||
default='AUTOMATIC',
|
||||
)
|
||||
cls.sample_map_resolution = IntProperty(
|
||||
name="Map Resolution",
|
||||
description="Importance map size is resolution x resolution; "
|
||||
description="Importance map size is resolution x resolution/2; "
|
||||
"higher values potentially produce less noise, at the cost of memory and speed",
|
||||
min=4, max=8192,
|
||||
default=1024,
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import bpy
|
||||
from bpy_extras.node_utils import find_node_input, find_output_node
|
||||
from bl_operators.presets import PresetMenu
|
||||
|
||||
from bpy.types import (
|
||||
Panel,
|
||||
@@ -26,20 +27,20 @@ from bpy.types import (
|
||||
)
|
||||
|
||||
|
||||
class CYCLES_MT_sampling_presets(Menu):
|
||||
class CYCLES_MT_sampling_presets(PresetMenu):
|
||||
bl_label = "Sampling Presets"
|
||||
preset_subdir = "cycles/sampling"
|
||||
preset_operator = "script.execute_preset"
|
||||
preset_add_operator = "render.cycles_sampling_preset_add"
|
||||
COMPAT_ENGINES = {'CYCLES'}
|
||||
draw = Menu.draw_preset
|
||||
|
||||
|
||||
class CYCLES_MT_integrator_presets(Menu):
|
||||
class CYCLES_MT_integrator_presets(PresetMenu):
|
||||
bl_label = "Integrator Presets"
|
||||
preset_subdir = "cycles/integrator"
|
||||
preset_operator = "script.execute_preset"
|
||||
preset_add_operator = "render.cycles_integrator_preset_add"
|
||||
COMPAT_ENGINES = {'CYCLES'}
|
||||
draw = Menu.draw_preset
|
||||
|
||||
|
||||
class CyclesButtonsPanel:
|
||||
@@ -144,6 +145,9 @@ class CYCLES_RENDER_PT_sampling(CyclesButtonsPanel, Panel):
|
||||
bl_label = "Sampling"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
|
||||
def draw_header_preset(self, context):
|
||||
CYCLES_MT_sampling_presets.draw_panel_header(self.layout)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.use_property_split = False
|
||||
@@ -151,11 +155,6 @@ class CYCLES_RENDER_PT_sampling(CyclesButtonsPanel, Panel):
|
||||
scene = context.scene
|
||||
cscene = scene.cycles
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.menu("CYCLES_MT_sampling_presets", text=bpy.types.CYCLES_MT_sampling_presets.bl_label)
|
||||
row.operator("render.cycles_sampling_preset_add", text="", icon="ZOOMIN")
|
||||
row.operator("render.cycles_sampling_preset_add", text="", icon="ZOOMOUT").remove_active = True
|
||||
|
||||
layout.use_property_split = True
|
||||
|
||||
layout.prop(cscene, "progressive")
|
||||
@@ -315,17 +314,11 @@ class CYCLES_RENDER_PT_light_paths(CyclesButtonsPanel, Panel):
|
||||
bl_label = "Light Paths"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
|
||||
def draw_header_preset(self, context):
|
||||
CYCLES_MT_integrator_presets.draw_panel_header(self.layout)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.use_property_split = True
|
||||
|
||||
scene = context.scene
|
||||
cscene = scene.cycles
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.menu("CYCLES_MT_integrator_presets", text=bpy.types.CYCLES_MT_integrator_presets.bl_label)
|
||||
row.operator("render.cycles_integrator_preset_add", text="", icon="ZOOMIN")
|
||||
row.operator("render.cycles_integrator_preset_add", text="", icon="ZOOMOUT").remove_active = True
|
||||
pass
|
||||
|
||||
|
||||
class CYCLES_RENDER_PT_light_paths_max_bounces(CyclesButtonsPanel, Panel):
|
||||
@@ -1374,11 +1367,13 @@ class CYCLES_WORLD_PT_settings_surface(CyclesButtonsPanel, Panel):
|
||||
cworld = world.cycles
|
||||
|
||||
col = layout.column()
|
||||
col.prop(cworld, "sample_as_light", text="Multiple Importance")
|
||||
col.prop(cworld, "sampling_method", text="Sampling")
|
||||
|
||||
sub = col.column()
|
||||
sub.active = cworld.sample_as_light
|
||||
sub.prop(cworld, "sample_map_resolution")
|
||||
sub.active = cworld.sampling_method != 'NONE'
|
||||
subsub = sub.row(align=True)
|
||||
subsub.active = cworld.sampling_method == 'MANUAL'
|
||||
subsub.prop(cworld, "sample_map_resolution")
|
||||
if use_branched_path(context):
|
||||
subsub = sub.column(align=True)
|
||||
subsub.active = use_sample_all_lights(context)
|
||||
|
||||
@@ -271,6 +271,40 @@ def custom_bake_remap(scene):
|
||||
scene.render.bake.use_pass_indirect = False
|
||||
|
||||
|
||||
def ambient_occlusion_node_relink(material, nodetree, traversed):
|
||||
if nodetree in traversed:
|
||||
return
|
||||
traversed.add(nodetree)
|
||||
|
||||
for node in nodetree.nodes:
|
||||
if node.bl_idname == 'ShaderNodeAmbientOcclusion':
|
||||
node.samples = 1
|
||||
node.only_local = False
|
||||
node.inputs['Distance'].default_value = 0.0
|
||||
elif node.bl_idname == 'ShaderNodeGroup':
|
||||
ambient_occlusion_node_relink(material, node.node_tree, traversed)
|
||||
|
||||
# Gather links to replace
|
||||
ao_links = []
|
||||
for link in nodetree.links:
|
||||
if link.from_node.bl_idname == 'ShaderNodeAmbientOcclusion':
|
||||
ao_links.append(link)
|
||||
|
||||
# Replace links
|
||||
for link in ao_links:
|
||||
from_node = link.from_node
|
||||
to_socket = link.to_socket
|
||||
|
||||
nodetree.links.remove(link)
|
||||
nodetree.links.new(from_node.outputs['Color'], to_socket)
|
||||
|
||||
def ambient_occlusion_nodes_relink():
|
||||
traversed = set()
|
||||
for material in bpy.data.materials:
|
||||
if check_is_new_shading_material(material):
|
||||
ambient_occlusion_node_relink(material, material.node_tree, traversed)
|
||||
|
||||
|
||||
@persistent
|
||||
def do_versions(self):
|
||||
if bpy.context.user_preferences.version <= (2, 78, 1):
|
||||
@@ -377,10 +411,6 @@ def do_versions(self):
|
||||
for world in bpy.data.worlds:
|
||||
cworld = world.cycles
|
||||
|
||||
# World MIS
|
||||
if not cworld.is_property_set("sample_as_light"):
|
||||
cworld.sample_as_light = False
|
||||
|
||||
# World MIS Samples
|
||||
if not cworld.is_property_set("samples"):
|
||||
cworld.samples = 4
|
||||
@@ -444,3 +474,16 @@ def do_versions(self):
|
||||
part.tip_radius = cpart.get("tip_width", 0.0)
|
||||
part.radius_scale = cpart.get("radius_scale", 0.01)
|
||||
part.use_close_tip = cpart.get("use_closetip", True)
|
||||
|
||||
if bpy.data.version <= (2, 79, 4) or \
|
||||
(bpy.data.version >= (2, 80, 0) and bpy.data.version <= (2, 80, 18)):
|
||||
for world in bpy.data.worlds:
|
||||
cworld = world.cycles
|
||||
# World MIS
|
||||
if not cworld.is_property_set("sampling_method"):
|
||||
if cworld.get("sample_as_light", False):
|
||||
cworld.sampling_method = 'MANUAL'
|
||||
else:
|
||||
cworld.sampling_method = 'NONE'
|
||||
|
||||
ambient_occlusion_nodes_relink()
|
||||
|
||||
@@ -770,17 +770,18 @@ static void ExportCurveTriangleVcol(ParticleCurveData *CData,
|
||||
|
||||
for(int curvekey = CData->curve_firstkey[curve]; curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1; curvekey++) {
|
||||
for(int section = 0; section < resol; section++) {
|
||||
cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve]));
|
||||
/* Encode vertex color using the sRGB curve. */
|
||||
cdata[vertexindex] = color_float_to_byte(color_srgb_to_linear_v3(CData->curve_vcol[curve]));
|
||||
vertexindex++;
|
||||
cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve]));
|
||||
cdata[vertexindex] = color_float_to_byte(color_srgb_to_linear_v3(CData->curve_vcol[curve]));
|
||||
vertexindex++;
|
||||
cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve]));
|
||||
cdata[vertexindex] = color_float_to_byte(color_srgb_to_linear_v3(CData->curve_vcol[curve]));
|
||||
vertexindex++;
|
||||
cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve]));
|
||||
cdata[vertexindex] = color_float_to_byte(color_srgb_to_linear_v3(CData->curve_vcol[curve]));
|
||||
vertexindex++;
|
||||
cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve]));
|
||||
cdata[vertexindex] = color_float_to_byte(color_srgb_to_linear_v3(CData->curve_vcol[curve]));
|
||||
vertexindex++;
|
||||
cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve]));
|
||||
cdata[vertexindex] = color_float_to_byte(color_srgb_to_linear_v3(CData->curve_vcol[curve]));
|
||||
vertexindex++;
|
||||
}
|
||||
}
|
||||
@@ -993,9 +994,10 @@ void BlenderSync::sync_curves(Mesh *mesh,
|
||||
if(fdata) {
|
||||
size_t i = 0;
|
||||
|
||||
/* Encode vertex color using the sRGB curve. */
|
||||
for(size_t curve = 0; curve < CData.curve_vcol.size(); curve++)
|
||||
if(!(CData.curve_keynum[curve] <= 1 || CData.curve_length[curve] == 0.0f))
|
||||
fdata[i++] = color_srgb_to_scene_linear_v3(CData.curve_vcol[curve]);
|
||||
fdata[i++] = color_srgb_to_linear_v3(CData.curve_vcol[curve]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,7 +401,8 @@ static void attr_create_vertex_color(Scene *scene,
|
||||
int n = p->loop_total();
|
||||
for(int i = 0; i < n; i++) {
|
||||
float3 color = get_float3(l->data[p->loop_start() + i].color());
|
||||
*(cdata++) = color_float_to_byte(color_srgb_to_scene_linear_v3(color));
|
||||
/* Encode vertex color using the sRGB curve. */
|
||||
*(cdata++) = color_float_to_byte(color_srgb_to_linear_v3(color));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -424,12 +425,13 @@ static void attr_create_vertex_color(Scene *scene,
|
||||
int tri_a[3], tri_b[3];
|
||||
face_split_tri_indices(face_flags[i], tri_a, tri_b);
|
||||
|
||||
/* Encode vertex color using the sRGB curve. */
|
||||
uchar4 colors[4];
|
||||
colors[0] = color_float_to_byte(color_srgb_to_scene_linear_v3(get_float3(c->color1())));
|
||||
colors[1] = color_float_to_byte(color_srgb_to_scene_linear_v3(get_float3(c->color2())));
|
||||
colors[2] = color_float_to_byte(color_srgb_to_scene_linear_v3(get_float3(c->color3())));
|
||||
colors[0] = color_float_to_byte(color_srgb_to_linear_v3(get_float3(c->color1())));
|
||||
colors[1] = color_float_to_byte(color_srgb_to_linear_v3(get_float3(c->color2())));
|
||||
colors[2] = color_float_to_byte(color_srgb_to_linear_v3(get_float3(c->color3())));
|
||||
if(nverts[i] == 4) {
|
||||
colors[3] = color_float_to_byte(color_srgb_to_scene_linear_v3(get_float3(c->color4())));
|
||||
colors[3] = color_float_to_byte(color_srgb_to_linear_v3(get_float3(c->color4())));
|
||||
}
|
||||
|
||||
cdata[0] = colors[tri_a[0]];
|
||||
|
||||
@@ -242,7 +242,15 @@ void BlenderSync::sync_background_light(bool use_portal)
|
||||
if(b_world) {
|
||||
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
|
||||
PointerRNA cworld = RNA_pointer_get(&b_world.ptr, "cycles");
|
||||
bool sample_as_light = get_boolean(cworld, "sample_as_light");
|
||||
|
||||
enum SamplingMethod {
|
||||
SAMPLING_NONE = 0,
|
||||
SAMPLING_AUTOMATIC,
|
||||
SAMPLING_MANUAL,
|
||||
SAMPLING_NUM
|
||||
};
|
||||
int sampling_method = get_enum(cworld, "sampling_method", SAMPLING_NUM, SAMPLING_AUTOMATIC);
|
||||
bool sample_as_light = (sampling_method != SAMPLING_NONE);
|
||||
|
||||
if(sample_as_light || use_portal) {
|
||||
/* test if we need to sync */
|
||||
@@ -254,7 +262,12 @@ void BlenderSync::sync_background_light(bool use_portal)
|
||||
b_world.ptr.data != world_map)
|
||||
{
|
||||
light->type = LIGHT_BACKGROUND;
|
||||
light->map_resolution = get_int(cworld, "sample_map_resolution");
|
||||
if(sampling_method == SAMPLING_MANUAL) {
|
||||
light->map_resolution = get_int(cworld, "sample_map_resolution");
|
||||
}
|
||||
else {
|
||||
light->map_resolution = 0;
|
||||
}
|
||||
light->shader = scene->default_background;
|
||||
light->use_mis = sample_as_light;
|
||||
light->max_bounces = get_int(cworld, "max_bounces");
|
||||
|
||||
@@ -551,7 +551,12 @@ static ShaderNode *add_node(Scene *scene,
|
||||
node = new EmissionNode();
|
||||
}
|
||||
else if(b_node.is_a(&RNA_ShaderNodeAmbientOcclusion)) {
|
||||
node = new AmbientOcclusionNode();
|
||||
BL::ShaderNodeAmbientOcclusion b_ao_node(b_node);
|
||||
AmbientOcclusionNode *ao = new AmbientOcclusionNode();
|
||||
ao->samples = b_ao_node.samples();
|
||||
ao->inside = b_ao_node.inside();
|
||||
ao->only_local = b_ao_node.only_local();
|
||||
node = ao;
|
||||
}
|
||||
else if(b_node.is_a(&RNA_ShaderNodeVolumeScatter)) {
|
||||
node = new ScatterVolumeNode();
|
||||
|
||||
@@ -97,6 +97,12 @@ if(CYCLES_STANDALONE_REPOSITORY)
|
||||
find_package(LLVM REQUIRED)
|
||||
endif()
|
||||
|
||||
####
|
||||
# OpenColorIO
|
||||
if(WITH_OPENCOLORIO)
|
||||
find_package(OpenColorIO REQUIRED)
|
||||
endif()
|
||||
|
||||
####
|
||||
# Boost
|
||||
set(__boost_packages filesystem regex system thread date_time)
|
||||
|
||||
@@ -2425,7 +2425,7 @@ bool device_cuda_init(void)
|
||||
result = true;
|
||||
}
|
||||
else {
|
||||
VLOG(1) << "Neither precompiled kernels nor CUDA compiler wad found,"
|
||||
VLOG(1) << "Neither precompiled kernels nor CUDA compiler was found,"
|
||||
<< " unable to use CUDA";
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -82,6 +82,7 @@ set(SRC_HEADERS
|
||||
kernel_accumulate.h
|
||||
kernel_bake.h
|
||||
kernel_camera.h
|
||||
kernel_color.h
|
||||
kernel_compat_cpu.h
|
||||
kernel_compat_cuda.h
|
||||
kernel_compat_opencl.h
|
||||
@@ -159,6 +160,7 @@ set(SRC_CLOSURE_HEADERS
|
||||
|
||||
set(SRC_SVM_HEADERS
|
||||
svm/svm.h
|
||||
svm/svm_ao.h
|
||||
svm/svm_attribute.h
|
||||
svm/svm_bevel.h
|
||||
svm/svm_blackbody.h
|
||||
|
||||
@@ -203,7 +203,7 @@ ccl_device_intersect bool scene_intersect(KernelGlobals *kg,
|
||||
|
||||
#ifdef __BVH_LOCAL__
|
||||
/* Note: ray is passed by value to work around a possible CUDA compiler bug. */
|
||||
ccl_device_intersect void scene_intersect_local(KernelGlobals *kg,
|
||||
ccl_device_intersect bool scene_intersect_local(KernelGlobals *kg,
|
||||
const Ray ray,
|
||||
LocalIntersection *local_isect,
|
||||
int local_object,
|
||||
|
||||
@@ -41,7 +41,7 @@ ccl_device
|
||||
#else
|
||||
ccl_device_inline
|
||||
#endif
|
||||
void BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
|
||||
bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
|
||||
const Ray *ray,
|
||||
LocalIntersection *local_isect,
|
||||
int local_object,
|
||||
@@ -70,7 +70,11 @@ void BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
|
||||
int object = OBJECT_NONE;
|
||||
float isect_t = ray->t;
|
||||
|
||||
local_isect->num_hits = 0;
|
||||
if(local_isect) {
|
||||
local_isect->num_hits = 0;
|
||||
}
|
||||
|
||||
kernel_assert((local_isect == NULL) == (max_hits == 0));
|
||||
|
||||
const int object_flag = kernel_tex_fetch(__object_flag, local_object);
|
||||
if(!(object_flag & SD_OBJECT_TRANSFORM_APPLIED)) {
|
||||
@@ -194,16 +198,18 @@ void BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
|
||||
/* intersect ray against primitive */
|
||||
for(; prim_addr < prim_addr2; prim_addr++) {
|
||||
kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
|
||||
triangle_intersect_local(kg,
|
||||
local_isect,
|
||||
P,
|
||||
dir,
|
||||
object,
|
||||
local_object,
|
||||
prim_addr,
|
||||
isect_t,
|
||||
lcg_state,
|
||||
max_hits);
|
||||
if(triangle_intersect_local(kg,
|
||||
local_isect,
|
||||
P,
|
||||
dir,
|
||||
object,
|
||||
local_object,
|
||||
prim_addr,
|
||||
isect_t,
|
||||
lcg_state,
|
||||
max_hits)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -212,17 +218,19 @@ void BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
|
||||
/* intersect ray against primitive */
|
||||
for(; prim_addr < prim_addr2; prim_addr++) {
|
||||
kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
|
||||
motion_triangle_intersect_local(kg,
|
||||
local_isect,
|
||||
P,
|
||||
dir,
|
||||
ray->time,
|
||||
object,
|
||||
local_object,
|
||||
prim_addr,
|
||||
isect_t,
|
||||
lcg_state,
|
||||
max_hits);
|
||||
if(motion_triangle_intersect_local(kg,
|
||||
local_isect,
|
||||
P,
|
||||
dir,
|
||||
ray->time,
|
||||
object,
|
||||
local_object,
|
||||
prim_addr,
|
||||
isect_t,
|
||||
lcg_state,
|
||||
max_hits)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -234,9 +242,11 @@ void BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
|
||||
}
|
||||
} while(node_addr != ENTRYPOINT_SENTINEL);
|
||||
} while(node_addr != ENTRYPOINT_SENTINEL);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
ccl_device_inline void BVH_FUNCTION_NAME(KernelGlobals *kg,
|
||||
ccl_device_inline bool BVH_FUNCTION_NAME(KernelGlobals *kg,
|
||||
const Ray *ray,
|
||||
LocalIntersection *local_isect,
|
||||
int local_object,
|
||||
@@ -262,6 +272,7 @@ ccl_device_inline void BVH_FUNCTION_NAME(KernelGlobals *kg,
|
||||
max_hits);
|
||||
}
|
||||
kernel_assert(!"Should not happen");
|
||||
return false;
|
||||
}
|
||||
|
||||
#undef BVH_FUNCTION_NAME
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
# define NODE_INTERSECT qbvh_aligned_node_intersect
|
||||
#endif
|
||||
|
||||
ccl_device void BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
|
||||
ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
|
||||
const Ray *ray,
|
||||
LocalIntersection *local_isect,
|
||||
int local_object,
|
||||
@@ -59,7 +59,11 @@ ccl_device void BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
|
||||
int object = OBJECT_NONE;
|
||||
float isect_t = ray->t;
|
||||
|
||||
local_isect->num_hits = 0;
|
||||
if(local_isect) {
|
||||
local_isect->num_hits = 0;
|
||||
}
|
||||
|
||||
kernel_assert((local_isect == NULL) == (max_hits == 0));
|
||||
|
||||
const int object_flag = kernel_tex_fetch(__object_flag, local_object);
|
||||
if(!(object_flag & SD_OBJECT_TRANSFORM_APPLIED)) {
|
||||
@@ -81,7 +85,7 @@ ccl_device void BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
|
||||
|
||||
#ifndef __KERNEL_SSE41__
|
||||
if(!isfinite(P.x)) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -250,16 +254,18 @@ ccl_device void BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
|
||||
/* Intersect ray against primitive, */
|
||||
for(; prim_addr < prim_addr2; prim_addr++) {
|
||||
kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
|
||||
triangle_intersect_local(kg,
|
||||
local_isect,
|
||||
P,
|
||||
dir,
|
||||
object,
|
||||
local_object,
|
||||
prim_addr,
|
||||
isect_t,
|
||||
lcg_state,
|
||||
max_hits);
|
||||
if(triangle_intersect_local(kg,
|
||||
local_isect,
|
||||
P,
|
||||
dir,
|
||||
object,
|
||||
local_object,
|
||||
prim_addr,
|
||||
isect_t,
|
||||
lcg_state,
|
||||
max_hits)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -268,17 +274,19 @@ ccl_device void BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
|
||||
/* Intersect ray against primitive. */
|
||||
for(; prim_addr < prim_addr2; prim_addr++) {
|
||||
kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
|
||||
motion_triangle_intersect_local(kg,
|
||||
local_isect,
|
||||
P,
|
||||
dir,
|
||||
ray->time,
|
||||
object,
|
||||
local_object,
|
||||
prim_addr,
|
||||
isect_t,
|
||||
lcg_state,
|
||||
max_hits);
|
||||
if(motion_triangle_intersect_local(kg,
|
||||
local_isect,
|
||||
P,
|
||||
dir,
|
||||
ray->time,
|
||||
object,
|
||||
local_object,
|
||||
prim_addr,
|
||||
isect_t,
|
||||
lcg_state,
|
||||
max_hits)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -289,6 +297,8 @@ ccl_device void BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
|
||||
}
|
||||
} while(node_addr != ENTRYPOINT_SENTINEL);
|
||||
} while(node_addr != ENTRYPOINT_SENTINEL);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#undef NODE_INTERSECT
|
||||
|
||||
@@ -218,9 +218,10 @@ ccl_device_inline bool motion_triangle_intersect(
|
||||
/* Special ray intersection routines for local intersections. In that case we
|
||||
* only want to intersect with primitives in the same object, and if case of
|
||||
* multiple hits we pick a single random primitive as the intersection point.
|
||||
* Returns whether traversal should be stopped.
|
||||
*/
|
||||
#ifdef __BVH_LOCAL__
|
||||
ccl_device_inline void motion_triangle_intersect_local(
|
||||
ccl_device_inline bool motion_triangle_intersect_local(
|
||||
KernelGlobals *kg,
|
||||
LocalIntersection *local_isect,
|
||||
float3 P,
|
||||
@@ -237,7 +238,7 @@ ccl_device_inline void motion_triangle_intersect_local(
|
||||
* already know we are only intersecting the right object. */
|
||||
if(object == OBJECT_NONE) {
|
||||
if(kernel_tex_fetch(__prim_object, prim_addr) != local_object) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,7 +259,12 @@ ccl_device_inline void motion_triangle_intersect_local(
|
||||
#endif
|
||||
&u, &v, &t))
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* If no actual hit information is requested, just return here. */
|
||||
if(max_hits == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int hit;
|
||||
@@ -266,7 +272,7 @@ ccl_device_inline void motion_triangle_intersect_local(
|
||||
/* Record up to max_hits intersections. */
|
||||
for(int i = min(max_hits, local_isect->num_hits) - 1; i >= 0; --i) {
|
||||
if(local_isect->hits[i].t == t) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,13 +288,13 @@ ccl_device_inline void motion_triangle_intersect_local(
|
||||
hit = lcg_step_uint(lcg_state) % local_isect->num_hits;
|
||||
|
||||
if(hit >= max_hits)
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Record closest intersection only. */
|
||||
if(local_isect->num_hits && t > local_isect->hits[0].t) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
hit = 0;
|
||||
@@ -307,6 +313,8 @@ ccl_device_inline void motion_triangle_intersect_local(
|
||||
/* Record geometric normal. */
|
||||
local_isect->Ng[hit] = normalize(cross(verts[1] - verts[0],
|
||||
verts[2] - verts[0]));
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif /* __BVH_LOCAL__ */
|
||||
|
||||
|
||||
@@ -73,10 +73,11 @@ ccl_device_inline bool triangle_intersect(KernelGlobals *kg,
|
||||
/* Special ray intersection routines for local intersection. In that case we
|
||||
* only want to intersect with primitives in the same object, and if case of
|
||||
* multiple hits we pick a single random primitive as the intersection point.
|
||||
* Returns whether traversal should be stopped.
|
||||
*/
|
||||
|
||||
#ifdef __BVH_LOCAL__
|
||||
ccl_device_inline void triangle_intersect_local(
|
||||
ccl_device_inline bool triangle_intersect_local(
|
||||
KernelGlobals *kg,
|
||||
LocalIntersection *local_isect,
|
||||
float3 P,
|
||||
@@ -92,7 +93,7 @@ ccl_device_inline void triangle_intersect_local(
|
||||
* already know we are only intersecting the right object. */
|
||||
if(object == OBJECT_NONE) {
|
||||
if(kernel_tex_fetch(__prim_object, prim_addr) != local_object) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +116,12 @@ ccl_device_inline void triangle_intersect_local(
|
||||
#endif
|
||||
&u, &v, &t))
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* If no actual hit information is requested, just return here. */
|
||||
if(max_hits == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int hit;
|
||||
@@ -123,7 +129,7 @@ ccl_device_inline void triangle_intersect_local(
|
||||
/* Record up to max_hits intersections. */
|
||||
for(int i = min(max_hits, local_isect->num_hits) - 1; i >= 0; --i) {
|
||||
if(local_isect->hits[i].t == t) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,13 +144,13 @@ ccl_device_inline void triangle_intersect_local(
|
||||
hit = lcg_step_uint(lcg_state) % local_isect->num_hits;
|
||||
|
||||
if(hit >= max_hits)
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Record closest intersection only. */
|
||||
if(local_isect->num_hits && t > local_isect->hits[0].t) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
hit = 0;
|
||||
@@ -167,6 +173,8 @@ ccl_device_inline void triangle_intersect_local(
|
||||
tri_c = float4_to_float3(kernel_tex_fetch(__prim_tri_verts, tri_vindex+2));
|
||||
#endif
|
||||
local_isect->Ng[hit] = normalize(cross(tri_b - tri_a, tri_c - tri_a));
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif /* __BVH_LOCAL__ */
|
||||
|
||||
|
||||
38
intern/cycles/kernel/kernel_color.h
Normal file
38
intern/cycles/kernel/kernel_color.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2011-2018 Blender Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __KERNEL_COLOR_H__
|
||||
#define __KERNEL_COLOR_H__
|
||||
|
||||
#include "util/util_color.h"
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
ccl_device float3 xyz_to_rgb(KernelGlobals *kg, float3 xyz)
|
||||
{
|
||||
return make_float3(dot(float4_to_float3(kernel_data.film.xyz_to_r), xyz),
|
||||
dot(float4_to_float3(kernel_data.film.xyz_to_g), xyz),
|
||||
dot(float4_to_float3(kernel_data.film.xyz_to_b), xyz));
|
||||
}
|
||||
|
||||
ccl_device float linear_rgb_to_gray(KernelGlobals *kg, float3 c)
|
||||
{
|
||||
return dot(c, float4_to_float3(kernel_data.film.rgb_to_y));
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
#endif /* __KERNEL_COLOR_H__ */
|
||||
@@ -319,9 +319,9 @@ ccl_device_noinline float3 indirect_background(KernelGlobals *kg,
|
||||
|
||||
#ifdef __BACKGROUND_MIS__
|
||||
/* check if background light exists or if we should skip pdf */
|
||||
int res = kernel_data.integrator.pdf_background_res;
|
||||
int res_x = kernel_data.integrator.pdf_background_res_x;
|
||||
|
||||
if(!(state->flag & PATH_RAY_MIS_SKIP) && res) {
|
||||
if(!(state->flag & PATH_RAY_MIS_SKIP) && res_x) {
|
||||
/* multiple importance sampling, get background light pdf for ray
|
||||
* direction, and compute weight with respect to BSDF pdf */
|
||||
float pdf = background_light_pdf(kg, ray->P, ray->D);
|
||||
|
||||
@@ -22,9 +22,9 @@ ccl_device float4 film_map(KernelGlobals *kg, float4 irradiance, float scale)
|
||||
float4 result = irradiance*scale;
|
||||
|
||||
/* conversion to srgb */
|
||||
result.x = color_scene_linear_to_srgb(result.x*exposure);
|
||||
result.y = color_scene_linear_to_srgb(result.y*exposure);
|
||||
result.z = color_scene_linear_to_srgb(result.z*exposure);
|
||||
result.x = color_linear_to_srgb(result.x*exposure);
|
||||
result.y = color_linear_to_srgb(result.y*exposure);
|
||||
result.z = color_linear_to_srgb(result.z*exposure);
|
||||
|
||||
/* clamp since alpha might be > 1.0 due to russian roulette */
|
||||
result.w = saturate(result.w);
|
||||
|
||||
@@ -197,12 +197,13 @@ float3 background_map_sample(KernelGlobals *kg, float randu, float randv, float
|
||||
/* for the following, the CDF values are actually a pair of floats, with the
|
||||
* function value as X and the actual CDF as Y. The last entry's function
|
||||
* value is the CDF total. */
|
||||
int res = kernel_data.integrator.pdf_background_res;
|
||||
int cdf_count = res + 1;
|
||||
int res_x = kernel_data.integrator.pdf_background_res_x;
|
||||
int res_y = kernel_data.integrator.pdf_background_res_y;
|
||||
int cdf_width = res_x + 1;
|
||||
|
||||
/* this is basically std::lower_bound as used by pbrt */
|
||||
int first = 0;
|
||||
int count = res;
|
||||
int count = res_y;
|
||||
|
||||
while(count > 0) {
|
||||
int step = count >> 1;
|
||||
@@ -217,24 +218,24 @@ float3 background_map_sample(KernelGlobals *kg, float randu, float randv, float
|
||||
}
|
||||
|
||||
int index_v = max(0, first - 1);
|
||||
kernel_assert(index_v >= 0 && index_v < res);
|
||||
kernel_assert(index_v >= 0 && index_v < res_y);
|
||||
|
||||
float2 cdf_v = kernel_tex_fetch(__light_background_marginal_cdf, index_v);
|
||||
float2 cdf_next_v = kernel_tex_fetch(__light_background_marginal_cdf, index_v + 1);
|
||||
float2 cdf_last_v = kernel_tex_fetch(__light_background_marginal_cdf, res);
|
||||
float2 cdf_last_v = kernel_tex_fetch(__light_background_marginal_cdf, res_y);
|
||||
|
||||
/* importance-sampled V direction */
|
||||
float dv = inverse_lerp(cdf_v.y, cdf_next_v.y, randv);
|
||||
float v = (index_v + dv) / res;
|
||||
float v = (index_v + dv) / res_y;
|
||||
|
||||
/* this is basically std::lower_bound as used by pbrt */
|
||||
first = 0;
|
||||
count = res;
|
||||
count = res_x;
|
||||
while(count > 0) {
|
||||
int step = count >> 1;
|
||||
int middle = first + step;
|
||||
|
||||
if(kernel_tex_fetch(__light_background_conditional_cdf, index_v * cdf_count + middle).y < randu) {
|
||||
if(kernel_tex_fetch(__light_background_conditional_cdf, index_v * cdf_width + middle).y < randu) {
|
||||
first = middle + 1;
|
||||
count -= step + 1;
|
||||
}
|
||||
@@ -243,15 +244,15 @@ float3 background_map_sample(KernelGlobals *kg, float randu, float randv, float
|
||||
}
|
||||
|
||||
int index_u = max(0, first - 1);
|
||||
kernel_assert(index_u >= 0 && index_u < res);
|
||||
kernel_assert(index_u >= 0 && index_u < res_x);
|
||||
|
||||
float2 cdf_u = kernel_tex_fetch(__light_background_conditional_cdf, index_v * cdf_count + index_u);
|
||||
float2 cdf_next_u = kernel_tex_fetch(__light_background_conditional_cdf, index_v * cdf_count + index_u + 1);
|
||||
float2 cdf_last_u = kernel_tex_fetch(__light_background_conditional_cdf, index_v * cdf_count + res);
|
||||
float2 cdf_u = kernel_tex_fetch(__light_background_conditional_cdf, index_v * cdf_width + index_u);
|
||||
float2 cdf_next_u = kernel_tex_fetch(__light_background_conditional_cdf, index_v * cdf_width + index_u + 1);
|
||||
float2 cdf_last_u = kernel_tex_fetch(__light_background_conditional_cdf, index_v * cdf_width + res_x);
|
||||
|
||||
/* importance-sampled U direction */
|
||||
float du = inverse_lerp(cdf_u.y, cdf_next_u.y, randu);
|
||||
float u = (index_u + du) / res;
|
||||
float u = (index_u + du) / res_x;
|
||||
|
||||
/* compute pdf */
|
||||
float denom = cdf_last_u.x * cdf_last_v.x;
|
||||
@@ -277,19 +278,21 @@ ccl_device
|
||||
float background_map_pdf(KernelGlobals *kg, float3 direction)
|
||||
{
|
||||
float2 uv = direction_to_equirectangular(direction);
|
||||
int res = kernel_data.integrator.pdf_background_res;
|
||||
int res_x = kernel_data.integrator.pdf_background_res_x;
|
||||
int res_y = kernel_data.integrator.pdf_background_res_y;
|
||||
int cdf_width = res_x + 1;
|
||||
|
||||
float sin_theta = sinf(uv.y * M_PI_F);
|
||||
|
||||
if(sin_theta == 0.0f)
|
||||
return 0.0f;
|
||||
|
||||
int index_u = clamp(float_to_int(uv.x * res), 0, res - 1);
|
||||
int index_v = clamp(float_to_int(uv.y * res), 0, res - 1);
|
||||
int index_u = clamp(float_to_int(uv.x * res_x), 0, res_x - 1);
|
||||
int index_v = clamp(float_to_int(uv.y * res_y), 0, res_y - 1);
|
||||
|
||||
/* pdfs in V direction */
|
||||
float2 cdf_last_u = kernel_tex_fetch(__light_background_conditional_cdf, index_v * (res + 1) + res);
|
||||
float2 cdf_last_v = kernel_tex_fetch(__light_background_marginal_cdf, res);
|
||||
float2 cdf_last_u = kernel_tex_fetch(__light_background_conditional_cdf, index_v * cdf_width + res_x);
|
||||
float2 cdf_last_v = kernel_tex_fetch(__light_background_marginal_cdf, res_y);
|
||||
|
||||
float denom = cdf_last_u.x * cdf_last_v.x;
|
||||
|
||||
@@ -297,7 +300,7 @@ float background_map_pdf(KernelGlobals *kg, float3 direction)
|
||||
return 0.0f;
|
||||
|
||||
/* pdfs in U direction */
|
||||
float2 cdf_u = kernel_tex_fetch(__light_background_conditional_cdf, index_v * (res + 1) + index_u);
|
||||
float2 cdf_u = kernel_tex_fetch(__light_background_conditional_cdf, index_v * cdf_width + index_u);
|
||||
float2 cdf_v = kernel_tex_fetch(__light_background_marginal_cdf, index_v);
|
||||
|
||||
return (cdf_u.x * cdf_v.x)/(M_2PI_F * M_PI_F * sin_theta * denom);
|
||||
|
||||
@@ -491,7 +491,7 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
|
||||
|
||||
#ifdef __AO__
|
||||
/* ambient occlusion */
|
||||
if(kernel_data.integrator.use_ambient_occlusion || (sd->flag & SD_AO)) {
|
||||
if(kernel_data.integrator.use_ambient_occlusion) {
|
||||
kernel_path_ao(kg, sd, emission_sd, L, state, throughput, make_float3(0.0f, 0.0f, 0.0f));
|
||||
}
|
||||
#endif /* __AO__ */
|
||||
@@ -661,7 +661,7 @@ ccl_device_forceinline void kernel_path_integrate(
|
||||
|
||||
#ifdef __AO__
|
||||
/* ambient occlusion */
|
||||
if(kernel_data.integrator.use_ambient_occlusion || (sd.flag & SD_AO)) {
|
||||
if(kernel_data.integrator.use_ambient_occlusion) {
|
||||
kernel_path_ao(kg, &sd, emission_sd, L, state, throughput, shader_bsdf_alpha(kg, &sd));
|
||||
}
|
||||
#endif /* __AO__ */
|
||||
|
||||
@@ -526,7 +526,7 @@ ccl_device void kernel_branched_path_integrate(KernelGlobals *kg,
|
||||
|
||||
#ifdef __AO__
|
||||
/* ambient occlusion */
|
||||
if(kernel_data.integrator.use_ambient_occlusion || (sd.flag & SD_AO)) {
|
||||
if(kernel_data.integrator.use_ambient_occlusion) {
|
||||
kernel_branched_path_ao(kg, &sd, emission_sd, L, &state, throughput);
|
||||
}
|
||||
#endif /* __AO__ */
|
||||
|
||||
@@ -914,10 +914,6 @@ ccl_device float3 shader_bsdf_ao(KernelGlobals *kg, ShaderData *sd, float ao_fac
|
||||
eval += sc->weight*ao_factor;
|
||||
N += bsdf->N*fabsf(average(sc->weight));
|
||||
}
|
||||
else if(CLOSURE_IS_AMBIENT_OCCLUSION(sc->type)) {
|
||||
eval += sc->weight;
|
||||
N += sd->N*fabsf(average(sc->weight));
|
||||
}
|
||||
}
|
||||
|
||||
*N_ = (is_zero(N))? sd->N : normalize(N);
|
||||
|
||||
@@ -881,8 +881,6 @@ enum ShaderDataFlag {
|
||||
SD_EXTINCTION = (1 << 6),
|
||||
/* Shader has have volume phase (scatter) closure. */
|
||||
SD_SCATTER = (1 << 7),
|
||||
/* Shader has AO closure. */
|
||||
SD_AO = (1 << 8),
|
||||
/* Shader has transparent closure. */
|
||||
SD_TRANSPARENT = (1 << 9),
|
||||
/* BSDF requires LCG for evaluation. */
|
||||
@@ -895,7 +893,6 @@ enum ShaderDataFlag {
|
||||
SD_HOLDOUT |
|
||||
SD_EXTINCTION |
|
||||
SD_SCATTER |
|
||||
SD_AO |
|
||||
SD_BSDF_NEEDS_LCG),
|
||||
|
||||
/* Shader flags. */
|
||||
@@ -1274,6 +1271,13 @@ typedef struct KernelFilm {
|
||||
|
||||
int pad1, pad2, pad3;
|
||||
|
||||
/* XYZ to rendering color space transform. float4 instead of float3 to
|
||||
* ensure consistent padding/alignment across devices. */
|
||||
float4 xyz_to_r;
|
||||
float4 xyz_to_g;
|
||||
float4 xyz_to_b;
|
||||
float4 rgb_to_y;
|
||||
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
int pass_bvh_traversed_nodes;
|
||||
int pass_bvh_traversed_instances;
|
||||
@@ -1306,7 +1310,8 @@ typedef struct KernelIntegrator {
|
||||
int num_all_lights;
|
||||
float pdf_triangles;
|
||||
float pdf_lights;
|
||||
int pdf_background_res;
|
||||
int pdf_background_res_x;
|
||||
int pdf_background_res_y;
|
||||
float light_inv_rr_threshold;
|
||||
|
||||
/* light portals */
|
||||
@@ -1368,6 +1373,8 @@ typedef struct KernelIntegrator {
|
||||
int start_sample;
|
||||
|
||||
int max_closures;
|
||||
|
||||
int pad1, pad2, pad3;
|
||||
} KernelIntegrator;
|
||||
static_assert_align(KernelIntegrator, 16);
|
||||
|
||||
|
||||
@@ -1172,7 +1172,7 @@ ccl_device void kernel_volume_stack_init(KernelGlobals *kg,
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(need_add) {
|
||||
if(need_add && stack_index < VOLUME_STACK_SIZE - 1) {
|
||||
stack[stack_index].object = stack_sd->object;
|
||||
stack[stack_index].shader = stack_sd->shader;
|
||||
++stack_index;
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
# include "kernel/split/kernel_split_data.h"
|
||||
# include "kernel/kernel_globals.h"
|
||||
|
||||
# include "kernel/kernel_color.h"
|
||||
# include "kernel/kernels/cpu/kernel_cpu_image.h"
|
||||
# include "kernel/kernel_film.h"
|
||||
# include "kernel/kernel_path.h"
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "kernel/kernel_math.h"
|
||||
#include "kernel/kernel_types.h"
|
||||
#include "kernel/kernel_globals.h"
|
||||
#include "kernel/kernel_color.h"
|
||||
#include "kernel/kernels/cuda/kernel_cuda_image.h"
|
||||
#include "kernel/kernel_film.h"
|
||||
#include "kernel/kernel_path.h"
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "kernel/kernel_math.h"
|
||||
#include "kernel/kernel_types.h"
|
||||
#include "kernel/kernel_globals.h"
|
||||
#include "kernel/kernel_color.h"
|
||||
#include "kernel/kernels/opencl/kernel_opencl_image.h"
|
||||
|
||||
#include "kernel/kernel_film.h"
|
||||
|
||||
@@ -74,21 +74,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/// ambient occlusion closure
|
||||
///
|
||||
/// We only have a ambient occlusion closure for the shaders
|
||||
/// to return a color in ambient occlusion shaders. No methods,
|
||||
/// only the weight is taking into account
|
||||
///
|
||||
class AmbientOcclusionClosure : public CClosurePrimitive {
|
||||
public:
|
||||
void setup(ShaderData *sd, int /* path_flag */, float3 weight)
|
||||
{
|
||||
closure_alloc(sd, sizeof(ShaderClosure), CLOSURE_AMBIENT_OCCLUSION_ID, weight);
|
||||
sd->flag |= SD_AO;
|
||||
}
|
||||
};
|
||||
|
||||
ClosureParam *closure_background_params()
|
||||
{
|
||||
static ClosureParam params[] = {
|
||||
@@ -110,16 +95,5 @@ ClosureParam *closure_holdout_params()
|
||||
|
||||
CCLOSURE_PREPARE(closure_holdout_prepare, HoldoutClosure)
|
||||
|
||||
ClosureParam *closure_ambient_occlusion_params()
|
||||
{
|
||||
static ClosureParam params[] = {
|
||||
CLOSURE_STRING_KEYPARAM(AmbientOcclusionClosure, label, "label"),
|
||||
CLOSURE_FINISH_PARAM(AmbientOcclusionClosure)
|
||||
};
|
||||
return params;
|
||||
}
|
||||
|
||||
CCLOSURE_PREPARE(closure_ambient_occlusion_prepare, AmbientOcclusionClosure)
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
|
||||
@@ -310,8 +310,6 @@ void OSLShader::register_closures(OSLShadingSystem *ss_)
|
||||
closure_background_params(), closure_background_prepare);
|
||||
register_closure(ss, "holdout", id++,
|
||||
closure_holdout_params(), closure_holdout_prepare);
|
||||
register_closure(ss, "ambient_occlusion", id++,
|
||||
closure_ambient_occlusion_params(), closure_ambient_occlusion_prepare);
|
||||
register_closure(ss, "diffuse_ramp", id++,
|
||||
closure_bsdf_diffuse_ramp_params(), closure_bsdf_diffuse_ramp_prepare);
|
||||
register_closure(ss, "phong_ramp", id++,
|
||||
|
||||
@@ -45,7 +45,6 @@ CCL_NAMESPACE_BEGIN
|
||||
OSL::ClosureParam *closure_emission_params();
|
||||
OSL::ClosureParam *closure_background_params();
|
||||
OSL::ClosureParam *closure_holdout_params();
|
||||
OSL::ClosureParam *closure_ambient_occlusion_params();
|
||||
OSL::ClosureParam *closure_bsdf_diffuse_ramp_params();
|
||||
OSL::ClosureParam *closure_bsdf_phong_ramp_params();
|
||||
OSL::ClosureParam *closure_bsdf_transparent_params();
|
||||
@@ -65,7 +64,6 @@ OSL::ClosureParam *closure_bsdf_principled_clearcoat_params();
|
||||
void closure_emission_prepare(OSL::RendererServices *, int id, void *data);
|
||||
void closure_background_prepare(OSL::RendererServices *, int id, void *data);
|
||||
void closure_holdout_prepare(OSL::RendererServices *, int id, void *data);
|
||||
void closure_ambient_occlusion_prepare(OSL::RendererServices *, int id, void *data);
|
||||
void closure_bsdf_diffuse_ramp_prepare(OSL::RendererServices *, int id, void *data);
|
||||
void closure_bsdf_phong_ramp_prepare(OSL::RendererServices *, int id, void *data);
|
||||
void closure_bsdf_transparent_prepare(OSL::RendererServices *, int id, void *data);
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "kernel/kernel_compat_cpu.h"
|
||||
#include "kernel/split/kernel_split_data_types.h"
|
||||
#include "kernel/kernel_globals.h"
|
||||
#include "kernel/kernel_color.h"
|
||||
#include "kernel/kernel_random.h"
|
||||
#include "kernel/kernel_projection.h"
|
||||
#include "kernel/kernel_differential.h"
|
||||
@@ -124,6 +125,7 @@ ustring OSLRenderServices::u_u("u");
|
||||
ustring OSLRenderServices::u_v("v");
|
||||
ustring OSLRenderServices::u_empty;
|
||||
ustring OSLRenderServices::u_at_bevel("@bevel");
|
||||
ustring OSLRenderServices::u_at_ao("@ao");
|
||||
|
||||
OSLRenderServices::OSLRenderServices()
|
||||
{
|
||||
@@ -956,6 +958,25 @@ bool OSLRenderServices::texture(ustring filename,
|
||||
status = true;
|
||||
}
|
||||
}
|
||||
else if(filename == u_at_ao) {
|
||||
/* AO shader hack. */
|
||||
PathState *state = sd->osl_path_state;
|
||||
int num_samples = (int)s;
|
||||
float radius = t;
|
||||
float3 N = make_float3(dsdx, dtdx, dsdy);
|
||||
int flags = 0;
|
||||
if((int)dtdy) {
|
||||
flags |= NODE_AO_INSIDE;
|
||||
}
|
||||
if((int)options.sblur) {
|
||||
flags |= NODE_AO_ONLY_LOCAL;
|
||||
}
|
||||
if((int)options.tblur) {
|
||||
flags |= NODE_AO_GLOBAL_RADIUS;
|
||||
}
|
||||
result[0] = svm_ao(kg, sd, N, state, radius, num_samples, flags);
|
||||
status = true;
|
||||
}
|
||||
else if(filename[1] == 'l') {
|
||||
/* IES light. */
|
||||
int slot = atoi(filename.c_str() + 2);
|
||||
|
||||
@@ -182,6 +182,7 @@ public:
|
||||
static ustring u_v;
|
||||
static ustring u_empty;
|
||||
static ustring u_at_bevel;
|
||||
static ustring u_at_ao;
|
||||
|
||||
private:
|
||||
KernelGlobals *kernel_globals;
|
||||
|
||||
@@ -110,7 +110,7 @@ foreach(_file ${SRC_OSL})
|
||||
string(REPLACE ".osl" ".oso" _OSO_FILE ${_OSL_FILE})
|
||||
string(REPLACE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} _OSO_FILE ${_OSO_FILE})
|
||||
add_custom_command(
|
||||
OUTPUT ${_OSO_FILE}
|
||||
OUTPUT ${_OSO_FILE}
|
||||
COMMAND ${OSL_COMPILER} -q -O2 -I"${CMAKE_CURRENT_SOURCE_DIR}" -o ${_OSO_FILE} ${_OSL_FILE}
|
||||
DEPENDS ${_OSL_FILE} ${SRC_OSL_HEADERS} ${OSL_COMPILER})
|
||||
list(APPEND SRC_OSO
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2013 Blender Foundation
|
||||
* Copyright 2011-2018 Blender Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,10 +17,19 @@
|
||||
#include "stdosl.h"
|
||||
|
||||
shader node_ambient_occlusion(
|
||||
normal NormalIn = N,
|
||||
color Color = 0.8,
|
||||
output closure color AO = 0)
|
||||
color ColorIn = color(0.8, 0.8, 0.8),
|
||||
int samples = 8,
|
||||
float Distance = 1.0,
|
||||
normal Normal = N,
|
||||
int inside = 0,
|
||||
int only_local = 1,
|
||||
output color ColorOut = color(0.8, 0.8, 0.8),
|
||||
output float AO = 1.0)
|
||||
{
|
||||
AO = Color * ambient_occlusion();
|
||||
int global_radius = (Distance == 0.0 && !isconnected(Distance));
|
||||
|
||||
/* Abuse texture call with special @ao token. */
|
||||
AO = texture("@ao", samples, Distance, Normal[0], Normal[1], Normal[2], inside, "sblur", only_local, "tblur", global_radius);
|
||||
ColorOut = ColorIn * AO;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* TODO(lukas): Fix colors in OSL. */
|
||||
|
||||
float color_srgb_to_scene_linear(float c)
|
||||
{
|
||||
if (c < 0.04045)
|
||||
|
||||
@@ -149,7 +149,7 @@ ccl_device void kernel_holdout_emission_blurring_pathtermination_ao(
|
||||
#ifdef __AO__
|
||||
if(IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
|
||||
/* ambient occlusion */
|
||||
if(kernel_data.integrator.use_ambient_occlusion || (sd->flag & SD_AO)) {
|
||||
if(kernel_data.integrator.use_ambient_occlusion) {
|
||||
enqueue_flag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "kernel/split/kernel_split_data.h"
|
||||
|
||||
#include "kernel/kernel_globals.h"
|
||||
#include "kernel/kernel_color.h"
|
||||
|
||||
#ifdef __OSL__
|
||||
# include "kernel/osl/osl_shader.h"
|
||||
|
||||
@@ -144,6 +144,7 @@ CCL_NAMESPACE_END
|
||||
#include "kernel/svm/svm_color_util.h"
|
||||
#include "kernel/svm/svm_math_util.h"
|
||||
|
||||
#include "kernel/svm/svm_ao.h"
|
||||
#include "kernel/svm/svm_attribute.h"
|
||||
#include "kernel/svm/svm_gradient.h"
|
||||
#include "kernel/svm/svm_blackbody.h"
|
||||
@@ -243,7 +244,7 @@ ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ccl_a
|
||||
svm_node_geometry(kg, sd, stack, node.y, node.z);
|
||||
break;
|
||||
case NODE_CONVERT:
|
||||
svm_node_convert(sd, stack, node.y, node.z, node.w);
|
||||
svm_node_convert(kg, sd, stack, node.y, node.z, node.w);
|
||||
break;
|
||||
case NODE_TEX_COORD:
|
||||
svm_node_tex_coord(kg, sd, path_flag, stack, node, &offset);
|
||||
@@ -324,9 +325,6 @@ ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ccl_a
|
||||
case NODE_CLOSURE_HOLDOUT:
|
||||
svm_node_closure_holdout(sd, stack, node);
|
||||
break;
|
||||
case NODE_CLOSURE_AMBIENT_OCCLUSION:
|
||||
svm_node_closure_ambient_occlusion(sd, stack, node);
|
||||
break;
|
||||
case NODE_FRESNEL:
|
||||
svm_node_fresnel(sd, stack, node.y, node.z, node.w);
|
||||
break;
|
||||
@@ -465,7 +463,7 @@ ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ccl_a
|
||||
svm_node_wireframe(kg, sd, stack, node);
|
||||
break;
|
||||
case NODE_WAVELENGTH:
|
||||
svm_node_wavelength(sd, stack, node.y, node.z);
|
||||
svm_node_wavelength(kg, sd, stack, node.y, node.z);
|
||||
break;
|
||||
case NODE_BLACKBODY:
|
||||
svm_node_blackbody(kg, sd, stack, node.y, node.z);
|
||||
@@ -480,6 +478,9 @@ ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ccl_a
|
||||
case NODE_BEVEL:
|
||||
svm_node_bevel(kg, sd, state, stack, node);
|
||||
break;
|
||||
case NODE_AMBIENT_OCCLUSION:
|
||||
svm_node_ao(kg, sd, state, stack, node);
|
||||
break;
|
||||
# endif /* __SHADER_RAYTRACE__ */
|
||||
#endif /* NODES_GROUP(NODE_GROUP_LEVEL_3) */
|
||||
case NODE_END:
|
||||
|
||||
111
intern/cycles/kernel/svm/svm_ao.h
Normal file
111
intern/cycles/kernel/svm/svm_ao.h
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright 2011-2018 Blender Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
ccl_device_noinline float svm_ao(KernelGlobals *kg,
|
||||
ShaderData *sd,
|
||||
float3 N,
|
||||
ccl_addr_space PathState *state,
|
||||
float max_dist,
|
||||
int num_samples,
|
||||
int flags)
|
||||
{
|
||||
if(flags & NODE_AO_GLOBAL_RADIUS) {
|
||||
max_dist = kernel_data.background.ao_distance;
|
||||
}
|
||||
|
||||
/* Early out if no sampling needed. */
|
||||
if(max_dist <= 0.0f || num_samples < 1 || sd->object == OBJECT_NONE) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
if(flags & NODE_AO_INSIDE) {
|
||||
N = -N;
|
||||
}
|
||||
|
||||
float3 T, B;
|
||||
make_orthonormals(N, &T, &B);
|
||||
|
||||
int unoccluded = 0;
|
||||
for(int sample = 0; sample < num_samples; sample++) {
|
||||
float disk_u, disk_v;
|
||||
path_branched_rng_2D(kg, state->rng_hash, state, sample, num_samples,
|
||||
PRNG_BEVEL_U, &disk_u, &disk_v);
|
||||
|
||||
float2 d = concentric_sample_disk(disk_u, disk_v);
|
||||
float3 D = make_float3(d.x, d.y, safe_sqrtf(1.0f - dot(d, d)));
|
||||
|
||||
/* Create ray. */
|
||||
Ray ray;
|
||||
ray.P = ray_offset(sd->P, N);
|
||||
ray.D = D.x*T + D.y*B + D.z*N;
|
||||
ray.t = max_dist;
|
||||
ray.time = sd->time;
|
||||
|
||||
if(flags & NODE_AO_ONLY_LOCAL) {
|
||||
if(!scene_intersect_local(kg,
|
||||
ray,
|
||||
NULL,
|
||||
sd->object,
|
||||
NULL,
|
||||
0)) {
|
||||
unoccluded++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Intersection isect;
|
||||
if(!scene_intersect(kg,
|
||||
ray,
|
||||
PATH_RAY_SHADOW_OPAQUE,
|
||||
&isect,
|
||||
NULL,
|
||||
0.0f, 0.0f)) {
|
||||
unoccluded++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ((float) unoccluded) / num_samples;
|
||||
}
|
||||
|
||||
ccl_device void svm_node_ao(KernelGlobals *kg,
|
||||
ShaderData *sd,
|
||||
ccl_addr_space PathState *state,
|
||||
float *stack,
|
||||
uint4 node)
|
||||
{
|
||||
uint flags, dist_offset, normal_offset, out_ao_offset;
|
||||
decode_node_uchar4(node.y, &flags, &dist_offset, &normal_offset, &out_ao_offset);
|
||||
|
||||
uint color_offset, out_color_offset, samples;
|
||||
decode_node_uchar4(node.z, &color_offset, &out_color_offset, &samples, NULL);
|
||||
|
||||
float dist = stack_load_float_default(stack, dist_offset, node.w);
|
||||
float3 normal = stack_valid(normal_offset)? stack_load_float3(stack, normal_offset): sd->N;
|
||||
float ao = svm_ao(kg, sd, normal, state, dist, samples, flags);
|
||||
|
||||
if (stack_valid(out_ao_offset)) {
|
||||
stack_store_float(stack, out_ao_offset, ao);
|
||||
}
|
||||
|
||||
if (stack_valid(out_color_offset)) {
|
||||
float3 color = stack_load_float3(stack, color_offset);
|
||||
stack_store_float3(stack, out_color_offset, ao * color);
|
||||
}
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
@@ -217,7 +217,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
|
||||
|
||||
/* sheen */
|
||||
if(diffuse_weight > CLOSURE_WEIGHT_CUTOFF && sheen > CLOSURE_WEIGHT_CUTOFF) {
|
||||
float m_cdlum = linear_rgb_to_gray(base_color);
|
||||
float m_cdlum = linear_rgb_to_gray(kg, base_color);
|
||||
float3 m_ctint = m_cdlum > 0.0f ? base_color / m_cdlum : make_float3(1.0f, 1.0f, 1.0f); // normalize lum. to isolate hue+sat
|
||||
|
||||
/* color of the sheen component */
|
||||
@@ -996,24 +996,6 @@ ccl_device void svm_node_closure_holdout(ShaderData *sd, float *stack, uint4 nod
|
||||
sd->flag |= SD_HOLDOUT;
|
||||
}
|
||||
|
||||
ccl_device void svm_node_closure_ambient_occlusion(ShaderData *sd, float *stack, uint4 node)
|
||||
{
|
||||
uint mix_weight_offset = node.y;
|
||||
|
||||
if(stack_valid(mix_weight_offset)) {
|
||||
float mix_weight = stack_load_float(stack, mix_weight_offset);
|
||||
|
||||
if(mix_weight == 0.0f)
|
||||
return;
|
||||
|
||||
closure_alloc(sd, sizeof(ShaderClosure), CLOSURE_AMBIENT_OCCLUSION_ID, sd->svm_closure_weight * mix_weight);
|
||||
}
|
||||
else
|
||||
closure_alloc(sd, sizeof(ShaderClosure), CLOSURE_AMBIENT_OCCLUSION_ID, sd->svm_closure_weight);
|
||||
|
||||
sd->flag |= SD_AO;
|
||||
}
|
||||
|
||||
/* Closure Nodes */
|
||||
|
||||
ccl_device_inline void svm_node_closure_store_weight(ShaderData *sd, float3 weight)
|
||||
|
||||
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
|
||||
|
||||
/* Conversion Nodes */
|
||||
|
||||
ccl_device void svm_node_convert(ShaderData *sd, float *stack, uint type, uint from, uint to)
|
||||
ccl_device void svm_node_convert(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint from, uint to)
|
||||
{
|
||||
switch(type) {
|
||||
case NODE_CONVERT_FI: {
|
||||
@@ -33,13 +33,13 @@ ccl_device void svm_node_convert(ShaderData *sd, float *stack, uint type, uint f
|
||||
}
|
||||
case NODE_CONVERT_CF: {
|
||||
float3 f = stack_load_float3(stack, from);
|
||||
float g = linear_rgb_to_gray(f);
|
||||
float g = linear_rgb_to_gray(kg, f);
|
||||
stack_store_float(stack, to, g);
|
||||
break;
|
||||
}
|
||||
case NODE_CONVERT_CI: {
|
||||
float3 f = stack_load_float3(stack, from);
|
||||
int i = (int)linear_rgb_to_gray(f);
|
||||
int i = (int)linear_rgb_to_gray(kg, f);
|
||||
stack_store_int(stack, to, i);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y,
|
||||
}
|
||||
|
||||
if(srgb) {
|
||||
r = color_srgb_to_scene_linear_v4(r);
|
||||
/* TODO(lukas): Implement proper conversion for image textures. */
|
||||
r = color_srgb_to_linear_v4(r);
|
||||
}
|
||||
|
||||
return r;
|
||||
|
||||
@@ -138,6 +138,8 @@ ccl_static_constant float blackbody_table_b[6][4] = {
|
||||
|
||||
ccl_device float3 svm_math_blackbody_color(float t)
|
||||
{
|
||||
/* TODO(lukas): Reimplement in XYZ. */
|
||||
|
||||
if(t >= 12000.0f) {
|
||||
return make_float3(0.826270103f, 0.994478524f, 1.56626022f);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ ccl_device float3 sky_radiance_old(KernelGlobals *kg, float3 dir,
|
||||
|
||||
/* convert to RGB */
|
||||
float3 xyz = xyY_to_xyz(x, y, Y);
|
||||
return xyz_to_rgb(xyz.x, xyz.y, xyz.z);
|
||||
return xyz_to_rgb(kg, xyz);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -102,7 +102,7 @@ ccl_device float3 sky_radiance_new(KernelGlobals *kg, float3 dir,
|
||||
float z = sky_radiance_internal(config_z, theta, gamma) * radiance_z;
|
||||
|
||||
/* convert to RGB and adjust strength */
|
||||
return xyz_to_rgb(x, y, z) * (M_2PI_F/683);
|
||||
return xyz_to_rgb(kg, make_float3(x, y, z)) * (M_2PI_F/683);
|
||||
}
|
||||
|
||||
ccl_device void svm_node_tex_sky(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
|
||||
|
||||
@@ -124,7 +124,7 @@ typedef enum ShaderNodeType {
|
||||
NODE_PARTICLE_INFO,
|
||||
NODE_TEX_BRICK,
|
||||
NODE_CLOSURE_SET_NORMAL,
|
||||
NODE_CLOSURE_AMBIENT_OCCLUSION,
|
||||
NODE_AMBIENT_OCCLUSION,
|
||||
NODE_TANGENT,
|
||||
NODE_NORMAL_MAP,
|
||||
NODE_HAIR_INFO,
|
||||
@@ -386,6 +386,12 @@ typedef enum NodeTexVoxelSpace {
|
||||
NODE_TEX_VOXEL_SPACE_WORLD = 1,
|
||||
} NodeTexVoxelSpace;
|
||||
|
||||
typedef enum NodeAO {
|
||||
NODE_AO_ONLY_LOCAL = (1 << 0),
|
||||
NODE_AO_INSIDE = (1 << 1),
|
||||
NODE_AO_GLOBAL_RADIUS = (1 << 2),
|
||||
} NodeAO;
|
||||
|
||||
typedef enum ShaderType {
|
||||
SHADER_TYPE_SURFACE,
|
||||
SHADER_TYPE_VOLUME,
|
||||
@@ -456,7 +462,6 @@ typedef enum ClosureType {
|
||||
|
||||
/* Other */
|
||||
CLOSURE_HOLDOUT_ID,
|
||||
CLOSURE_AMBIENT_OCCLUSION_ID,
|
||||
|
||||
/* Volume */
|
||||
CLOSURE_VOLUME_ID,
|
||||
@@ -491,7 +496,6 @@ typedef enum ClosureType {
|
||||
#define CLOSURE_IS_VOLUME_SCATTER(type) (type == CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID)
|
||||
#define CLOSURE_IS_VOLUME_ABSORPTION(type) (type == CLOSURE_VOLUME_ABSORPTION_ID)
|
||||
#define CLOSURE_IS_HOLDOUT(type) (type == CLOSURE_HOLDOUT_ID)
|
||||
#define CLOSURE_IS_AMBIENT_OCCLUSION(type) (type == CLOSURE_AMBIENT_OCCLUSION_ID)
|
||||
#define CLOSURE_IS_PHASE(type) (type == CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID)
|
||||
#define CLOSURE_IS_GLASS(type) (type >= CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID && type <= CLOSURE_BSDF_SHARP_GLASS_ID)
|
||||
#define CLOSURE_IS_PRINCIPLED(type) (type == CLOSURE_BSDF_PRINCIPLED_ID)
|
||||
|
||||
@@ -70,7 +70,7 @@ ccl_static_constant float cie_colour_match[81][3] = {
|
||||
{0.0001f,0.0000f,0.0000f}, {0.0001f,0.0000f,0.0000f}, {0.0000f,0.0000f,0.0000f}
|
||||
};
|
||||
|
||||
ccl_device void svm_node_wavelength(ShaderData *sd, float *stack, uint wavelength, uint color_out)
|
||||
ccl_device void svm_node_wavelength(KernelGlobals *kg, ShaderData *sd, float *stack, uint wavelength, uint color_out)
|
||||
{
|
||||
float lambda_nm = stack_load_float(stack, wavelength);
|
||||
float ii = (lambda_nm-380.0f) * (1.0f/5.0f); // scaled 0..80
|
||||
@@ -86,7 +86,7 @@ ccl_device void svm_node_wavelength(ShaderData *sd, float *stack, uint wavelengt
|
||||
color = interp(make_float3(c[0], c[1], c[2]), make_float3(c[3], c[4], c[5]), ii);
|
||||
}
|
||||
|
||||
color = xyz_to_rgb(color.x, color.y, color.z);
|
||||
color = xyz_to_rgb(kg, color);
|
||||
color *= 1.0f/2.52f; // Empirical scale from lg to make all comps <= 1
|
||||
|
||||
/* Clamp to zero if values are smaller */
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
ConstantFolder::ConstantFolder(ShaderGraph *graph, ShaderNode *node, ShaderOutput *output)
|
||||
: graph(graph), node(node), output(output)
|
||||
ConstantFolder::ConstantFolder(ShaderGraph *graph, ShaderNode *node, ShaderOutput *output, Scene *scene)
|
||||
: graph(graph), node(node), output(output), scene(scene)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
class Scene;
|
||||
class ShaderGraph;
|
||||
class ShaderInput;
|
||||
class ShaderNode;
|
||||
@@ -33,7 +34,9 @@ public:
|
||||
ShaderNode *const node;
|
||||
ShaderOutput *const output;
|
||||
|
||||
ConstantFolder(ShaderGraph *graph, ShaderNode *node, ShaderOutput *output);
|
||||
Scene *scene;
|
||||
|
||||
ConstantFolder(ShaderGraph *graph, ShaderNode *node, ShaderOutput *output, Scene *scene);
|
||||
|
||||
bool all_inputs_constant() const;
|
||||
|
||||
|
||||
@@ -232,8 +232,8 @@ void ShaderGraph::connect(ShaderOutput *from, ShaderInput *to)
|
||||
}
|
||||
|
||||
if(from->type() != to->type()) {
|
||||
/* for closures we can't do automatic conversion */
|
||||
if(from->type() == SocketType::CLOSURE || to->type() == SocketType::CLOSURE) {
|
||||
/* can't do automatic conversion from closure */
|
||||
if(from->type() == SocketType::CLOSURE) {
|
||||
fprintf(stderr, "Cycles shader graph connect: can only connect closure to closure "
|
||||
"(%s.%s to %s.%s).\n",
|
||||
from->parent->name.c_str(), from->name().c_str(),
|
||||
@@ -242,9 +242,28 @@ void ShaderGraph::connect(ShaderOutput *from, ShaderInput *to)
|
||||
}
|
||||
|
||||
/* add automatic conversion node in case of type mismatch */
|
||||
ShaderNode *convert = add(new ConvertNode(from->type(), to->type(), true));
|
||||
ShaderNode *convert;
|
||||
ShaderInput *convert_in;
|
||||
|
||||
connect(from, convert->inputs[0]);
|
||||
if (to->type() == SocketType::CLOSURE) {
|
||||
EmissionNode *emission = new EmissionNode();
|
||||
emission->color = make_float3(1.0f, 1.0f, 1.0f);
|
||||
emission->strength = 1.0f;
|
||||
convert = add(emission);
|
||||
/* Connect float inputs to Strength to save an additional Falue->Color conversion. */
|
||||
if(from->type() == SocketType::FLOAT) {
|
||||
convert_in = convert->input("Strength");
|
||||
}
|
||||
else {
|
||||
convert_in = convert->input("Color");
|
||||
}
|
||||
}
|
||||
else {
|
||||
convert = add(new ConvertNode(from->type(), to->type(), true));
|
||||
convert_in = convert->inputs[0];
|
||||
}
|
||||
|
||||
connect(from, convert_in);
|
||||
connect(convert->outputs[0], to);
|
||||
}
|
||||
else {
|
||||
@@ -477,7 +496,7 @@ void ShaderGraph::remove_proxy_nodes()
|
||||
* Try to constant fold some nodes, and pipe result directly to
|
||||
* the input socket of connected nodes.
|
||||
*/
|
||||
void ShaderGraph::constant_fold()
|
||||
void ShaderGraph::constant_fold(Scene *scene)
|
||||
{
|
||||
ShaderNodeSet done, scheduled;
|
||||
queue<ShaderNode*> traverse_queue;
|
||||
@@ -517,7 +536,7 @@ void ShaderGraph::constant_fold()
|
||||
}
|
||||
}
|
||||
/* Optimize current node. */
|
||||
ConstantFolder folder(this, node, output);
|
||||
ConstantFolder folder(this, node, output, scene);
|
||||
node->constant_fold(folder);
|
||||
}
|
||||
}
|
||||
@@ -715,7 +734,7 @@ void ShaderGraph::clean(Scene *scene)
|
||||
/* Graph simplification */
|
||||
|
||||
/* NOTE: Remove proxy nodes was already done. */
|
||||
constant_fold();
|
||||
constant_fold(scene);
|
||||
simplify_settings(scene);
|
||||
deduplicate_nodes();
|
||||
verify_volume_output();
|
||||
|
||||
@@ -285,7 +285,7 @@ protected:
|
||||
|
||||
/* Graph simplification routines. */
|
||||
void clean(Scene *scene);
|
||||
void constant_fold();
|
||||
void constant_fold(Scene *scene);
|
||||
void simplify_settings(Scene *scene);
|
||||
void deduplicate_nodes();
|
||||
void verify_volume_output();
|
||||
|
||||
@@ -94,6 +94,25 @@ device_memory *ImageManager::image_memory(int flat_slot)
|
||||
return img->mem;
|
||||
}
|
||||
|
||||
bool ImageManager::get_image_metadata(int flat_slot,
|
||||
ImageMetaData& metadata)
|
||||
{
|
||||
if(flat_slot == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ImageDataType type;
|
||||
int slot = flattened_slot_to_type_index(flat_slot, &type);
|
||||
|
||||
Image *img = images[type][slot];
|
||||
if(img) {
|
||||
metadata = img->metadata;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ImageManager::get_image_metadata(const string& filename,
|
||||
void *builtin_data,
|
||||
ImageMetaData& metadata)
|
||||
@@ -329,7 +348,7 @@ int ImageManager::add_image(const string& filename,
|
||||
img = new Image();
|
||||
img->filename = filename;
|
||||
img->builtin_data = builtin_data;
|
||||
img->builtin_free_cache = metadata.builtin_free_cache;
|
||||
img->metadata = metadata;
|
||||
img->need_load = true;
|
||||
img->animated = animated;
|
||||
img->frame = frame;
|
||||
@@ -417,11 +436,7 @@ void ImageManager::tag_reload_image(const string& filename,
|
||||
}
|
||||
|
||||
bool ImageManager::file_load_image_generic(Image *img,
|
||||
ImageInput **in,
|
||||
int &width,
|
||||
int &height,
|
||||
int &depth,
|
||||
int &components)
|
||||
ImageInput **in)
|
||||
{
|
||||
if(img->filename == "")
|
||||
return false;
|
||||
@@ -449,28 +464,15 @@ bool ImageManager::file_load_image_generic(Image *img,
|
||||
*in = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
width = spec.width;
|
||||
height = spec.height;
|
||||
depth = spec.depth;
|
||||
components = spec.nchannels;
|
||||
}
|
||||
else {
|
||||
/* load image using builtin images callbacks */
|
||||
if(!builtin_image_info_cb || !builtin_image_pixels_cb)
|
||||
return false;
|
||||
|
||||
ImageMetaData metadata;
|
||||
builtin_image_info_cb(img->filename, img->builtin_data, metadata);
|
||||
|
||||
width = metadata.width;
|
||||
height = metadata.height;
|
||||
depth = metadata.depth;
|
||||
components = metadata.channels;
|
||||
}
|
||||
|
||||
/* we only handle certain number of components */
|
||||
if(!(components >= 1 && components <= 4)) {
|
||||
if(!(img->metadata.channels >= 1 && img->metadata.channels <= 4)) {
|
||||
if(*in) {
|
||||
(*in)->close();
|
||||
delete *in;
|
||||
@@ -493,10 +495,16 @@ bool ImageManager::file_load_image(Image *img,
|
||||
{
|
||||
const StorageType alpha_one = (FileFormat == TypeDesc::UINT8)? 255 : 1;
|
||||
ImageInput *in = NULL;
|
||||
int width, height, depth, components;
|
||||
if(!file_load_image_generic(img, &in, width, height, depth, components)) {
|
||||
if(!file_load_image_generic(img, &in)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Get metadata. */
|
||||
int width = img->metadata.width;
|
||||
int height = img->metadata.height;
|
||||
int depth = img->metadata.depth;
|
||||
int components = img->metadata.channels;
|
||||
|
||||
/* Read RGBA pixels. */
|
||||
vector<StorageType> pixels_storage;
|
||||
StorageType *pixels;
|
||||
@@ -557,14 +565,14 @@ bool ImageManager::file_load_image(Image *img,
|
||||
img->builtin_data,
|
||||
(float*)&pixels[0],
|
||||
num_pixels * components,
|
||||
img->builtin_free_cache);
|
||||
img->metadata.builtin_free_cache);
|
||||
}
|
||||
else if(FileFormat == TypeDesc::UINT8) {
|
||||
builtin_image_pixels_cb(img->filename,
|
||||
img->builtin_data,
|
||||
(uchar*)&pixels[0],
|
||||
num_pixels * components,
|
||||
img->builtin_free_cache);
|
||||
img->metadata.builtin_free_cache);
|
||||
}
|
||||
else {
|
||||
/* TODO(dingto): Support half for ImBuf. */
|
||||
|
||||
@@ -71,6 +71,8 @@ public:
|
||||
bool get_image_metadata(const string& filename,
|
||||
void *builtin_data,
|
||||
ImageMetaData& metadata);
|
||||
bool get_image_metadata(int flat_slot,
|
||||
ImageMetaData& metadata);
|
||||
|
||||
void device_update(Device *device,
|
||||
Scene *scene,
|
||||
@@ -114,7 +116,7 @@ public:
|
||||
struct Image {
|
||||
string filename;
|
||||
void *builtin_data;
|
||||
bool builtin_free_cache;
|
||||
ImageMetaData metadata;
|
||||
|
||||
bool use_alpha;
|
||||
bool need_load;
|
||||
@@ -141,11 +143,7 @@ private:
|
||||
void *osl_texture_system;
|
||||
|
||||
bool file_load_image_generic(Image *img,
|
||||
ImageInput **in,
|
||||
int &width,
|
||||
int &height,
|
||||
int &depth,
|
||||
int &components);
|
||||
ImageInput **in);
|
||||
|
||||
template<TypeDesc::BASETYPE FileFormat,
|
||||
typename StorageType,
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
#include "device/device.h"
|
||||
#include "render/integrator.h"
|
||||
#include "render/film.h"
|
||||
#include "render/graph.h"
|
||||
#include "render/light.h"
|
||||
#include "render/mesh.h"
|
||||
#include "render/nodes.h"
|
||||
#include "render/object.h"
|
||||
#include "render/scene.h"
|
||||
#include "render/shader.h"
|
||||
@@ -32,12 +34,9 @@
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
static void shade_background_pixels(Device *device, DeviceScene *dscene, int res, vector<float3>& pixels, Progress& progress)
|
||||
static void shade_background_pixels(Device *device, DeviceScene *dscene, int width, int height, vector<float3>& pixels, Progress& progress)
|
||||
{
|
||||
/* create input */
|
||||
int width = res;
|
||||
int height = res;
|
||||
|
||||
device_vector<uint4> d_input(device, "background_input", MEM_READ_ONLY);
|
||||
device_vector<float4> d_output(device, "background_output", MEM_READ_WRITE);
|
||||
|
||||
@@ -121,7 +120,7 @@ NODE_DEFINE(Light)
|
||||
SOCKET_FLOAT(sizev, "Size V", 1.0f);
|
||||
SOCKET_BOOLEAN(round, "Round", false);
|
||||
|
||||
SOCKET_INT(map_resolution, "Map Resolution", 512);
|
||||
SOCKET_INT(map_resolution, "Map Resolution", 0);
|
||||
|
||||
SOCKET_FLOAT(spot_angle, "Spot Angle", M_PI_4_F);
|
||||
SOCKET_FLOAT(spot_smooth, "Spot Smooth", 0.0f);
|
||||
@@ -482,40 +481,41 @@ void LightManager::device_update_distribution(Device *, DeviceScene *dscene, Sce
|
||||
|
||||
static void background_cdf(int start,
|
||||
int end,
|
||||
int res,
|
||||
int cdf_count,
|
||||
int res_x,
|
||||
int res_y,
|
||||
const vector<float3> *pixels,
|
||||
float2 *cond_cdf)
|
||||
{
|
||||
int cdf_width = res_x+1;
|
||||
/* Conditional CDFs (rows, U direction). */
|
||||
for(int i = start; i < end; i++) {
|
||||
float sin_theta = sinf(M_PI_F * (i + 0.5f) / res);
|
||||
float3 env_color = (*pixels)[i * res];
|
||||
float sin_theta = sinf(M_PI_F * (i + 0.5f) / res_y);
|
||||
float3 env_color = (*pixels)[i * res_x];
|
||||
float ave_luminance = average(env_color);
|
||||
|
||||
cond_cdf[i * cdf_count].x = ave_luminance * sin_theta;
|
||||
cond_cdf[i * cdf_count].y = 0.0f;
|
||||
cond_cdf[i * cdf_width].x = ave_luminance * sin_theta;
|
||||
cond_cdf[i * cdf_width].y = 0.0f;
|
||||
|
||||
for(int j = 1; j < res; j++) {
|
||||
env_color = (*pixels)[i * res + j];
|
||||
for(int j = 1; j < res_x; j++) {
|
||||
env_color = (*pixels)[i * res_x + j];
|
||||
ave_luminance = average(env_color);
|
||||
|
||||
cond_cdf[i * cdf_count + j].x = ave_luminance * sin_theta;
|
||||
cond_cdf[i * cdf_count + j].y = cond_cdf[i * cdf_count + j - 1].y + cond_cdf[i * cdf_count + j - 1].x / res;
|
||||
cond_cdf[i * cdf_width + j].x = ave_luminance * sin_theta;
|
||||
cond_cdf[i * cdf_width + j].y = cond_cdf[i * cdf_width + j - 1].y + cond_cdf[i * cdf_width + j - 1].x / res_x;
|
||||
}
|
||||
|
||||
float cdf_total = cond_cdf[i * cdf_count + res - 1].y + cond_cdf[i * cdf_count + res - 1].x / res;
|
||||
float cdf_total = cond_cdf[i * cdf_width + res_x - 1].y + cond_cdf[i * cdf_width + res_x - 1].x / res_x;
|
||||
float cdf_total_inv = 1.0f / cdf_total;
|
||||
|
||||
/* stuff the total into the brightness value for the last entry, because
|
||||
* we are going to normalize the CDFs to 0.0 to 1.0 afterwards */
|
||||
cond_cdf[i * cdf_count + res].x = cdf_total;
|
||||
cond_cdf[i * cdf_width + res_x].x = cdf_total;
|
||||
|
||||
if(cdf_total > 0.0f)
|
||||
for(int j = 1; j < res; j++)
|
||||
cond_cdf[i * cdf_count + j].y *= cdf_total_inv;
|
||||
for(int j = 1; j < res_x; j++)
|
||||
cond_cdf[i * cdf_width + j].y *= cdf_total_inv;
|
||||
|
||||
cond_cdf[i * cdf_count + res].y = 1.0f;
|
||||
cond_cdf[i * cdf_width + res_x].y = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -537,7 +537,8 @@ void LightManager::device_update_background(Device *device,
|
||||
|
||||
/* no background light found, signal renderer to skip sampling */
|
||||
if(!background_light || !background_light->is_enabled) {
|
||||
kintegrator->pdf_background_res = 0;
|
||||
kintegrator->pdf_background_res_x = 0;
|
||||
kintegrator->pdf_background_res_y = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -546,41 +547,62 @@ void LightManager::device_update_background(Device *device,
|
||||
assert(kintegrator->use_direct_light);
|
||||
|
||||
/* get the resolution from the light's size (we stuff it in there) */
|
||||
int res = background_light->map_resolution;
|
||||
kintegrator->pdf_background_res = res;
|
||||
|
||||
assert(res > 0);
|
||||
int2 res = make_int2(background_light->map_resolution, background_light->map_resolution/2);
|
||||
/* If the resolution isn't set manually, try to find an environment texture. */
|
||||
if (res.x == 0) {
|
||||
Shader *shader = (scene->background->shader) ? scene->background->shader : scene->default_background;
|
||||
foreach(ShaderNode *node, shader->graph->nodes) {
|
||||
if(node->type == EnvironmentTextureNode::node_type) {
|
||||
EnvironmentTextureNode *env = (EnvironmentTextureNode*) node;
|
||||
ImageMetaData metadata;
|
||||
if(env->image_manager && env->image_manager->get_image_metadata(env->slot, metadata)) {
|
||||
res.x = max(res.x, metadata.width);
|
||||
res.y = max(res.y, metadata.height);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (res.x > 0 && res.y > 0) {
|
||||
VLOG(2) << "Automatically set World MIS resolution to " << res.x << " by " << res.y << "\n";
|
||||
}
|
||||
}
|
||||
/* If it's still unknown, just use the default. */
|
||||
if (res.x == 0 || res.y == 0) {
|
||||
res = make_int2(1024, 512);
|
||||
VLOG(2) << "Setting World MIS resolution to default\n";
|
||||
}
|
||||
kintegrator->pdf_background_res_x = res.x;
|
||||
kintegrator->pdf_background_res_y = res.y;
|
||||
|
||||
vector<float3> pixels;
|
||||
shade_background_pixels(device, dscene, res, pixels, progress);
|
||||
shade_background_pixels(device, dscene, res.x, res.y, pixels, progress);
|
||||
|
||||
if(progress.get_cancel())
|
||||
return;
|
||||
|
||||
/* build row distributions and column distribution for the infinite area environment light */
|
||||
int cdf_count = res + 1;
|
||||
float2 *marg_cdf = dscene->light_background_marginal_cdf.alloc(cdf_count);
|
||||
float2 *cond_cdf = dscene->light_background_conditional_cdf.alloc(cdf_count * cdf_count);
|
||||
int cdf_width = res.x+1;
|
||||
float2 *marg_cdf = dscene->light_background_marginal_cdf.alloc(res.y + 1);
|
||||
float2 *cond_cdf = dscene->light_background_conditional_cdf.alloc(cdf_width * res.y);
|
||||
|
||||
double time_start = time_dt();
|
||||
if(res < 512) {
|
||||
if(max(res.x, res.y) < 512) {
|
||||
/* Small enough resolution, faster to do single-threaded. */
|
||||
background_cdf(0, res, res, cdf_count, &pixels, cond_cdf);
|
||||
background_cdf(0, res.x, res.x, res.y, &pixels, cond_cdf);
|
||||
}
|
||||
else {
|
||||
/* Threaded evaluation for large resolution. */
|
||||
const int num_blocks = TaskScheduler::num_threads();
|
||||
const int chunk_size = res / num_blocks;
|
||||
const int chunk_size = res.y / num_blocks;
|
||||
int start_row = 0;
|
||||
TaskPool pool;
|
||||
for(int i = 0; i < num_blocks; ++i) {
|
||||
const int current_chunk_size =
|
||||
(i != num_blocks - 1) ? chunk_size
|
||||
: (res - i * chunk_size);
|
||||
: (res.y - i * chunk_size);
|
||||
pool.push(function_bind(&background_cdf,
|
||||
start_row, start_row + current_chunk_size,
|
||||
res,
|
||||
cdf_count,
|
||||
res.x,
|
||||
res.y,
|
||||
&pixels,
|
||||
cond_cdf));
|
||||
start_row += current_chunk_size;
|
||||
@@ -589,22 +611,22 @@ void LightManager::device_update_background(Device *device,
|
||||
}
|
||||
|
||||
/* marginal CDFs (column, V direction, sum of rows) */
|
||||
marg_cdf[0].x = cond_cdf[res].x;
|
||||
marg_cdf[0].x = cond_cdf[res.x].x;
|
||||
marg_cdf[0].y = 0.0f;
|
||||
|
||||
for(int i = 1; i < res; i++) {
|
||||
marg_cdf[i].x = cond_cdf[i * cdf_count + res].x;
|
||||
marg_cdf[i].y = marg_cdf[i - 1].y + marg_cdf[i - 1].x / res;
|
||||
for(int i = 1; i < res.y; i++) {
|
||||
marg_cdf[i].x = cond_cdf[i * cdf_width + res.x].x;
|
||||
marg_cdf[i].y = marg_cdf[i - 1].y + marg_cdf[i - 1].x / res.y;
|
||||
}
|
||||
|
||||
float cdf_total = marg_cdf[res - 1].y + marg_cdf[res - 1].x / res;
|
||||
marg_cdf[res].x = cdf_total;
|
||||
float cdf_total = marg_cdf[res.y - 1].y + marg_cdf[res.y - 1].x / res.y;
|
||||
marg_cdf[res.y].x = cdf_total;
|
||||
|
||||
if(cdf_total > 0.0f)
|
||||
for(int i = 1; i < res; i++)
|
||||
for(int i = 1; i < res.y; i++)
|
||||
marg_cdf[i].y /= cdf_total;
|
||||
|
||||
marg_cdf[res].y = 1.0f;
|
||||
marg_cdf[res.y].y = 1.0f;
|
||||
|
||||
VLOG(2) << "Background MIS build time " << time_dt() - time_start << "\n";
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "render/film.h"
|
||||
#include "render/image.h"
|
||||
#include "render/integrator.h"
|
||||
#include "render/light.h"
|
||||
@@ -1670,7 +1671,8 @@ RGBToBWNode::RGBToBWNode()
|
||||
void RGBToBWNode::constant_fold(const ConstantFolder& folder)
|
||||
{
|
||||
if(folder.all_inputs_constant()) {
|
||||
folder.make_constant(linear_rgb_to_gray(color));
|
||||
float val = folder.scene->shader_manager->linear_rgb_to_gray(color);
|
||||
folder.make_constant(val);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1766,7 +1768,8 @@ void ConvertNode::constant_fold(const ConstantFolder& folder)
|
||||
if(to == SocketType::FLOAT) {
|
||||
if(from == SocketType::COLOR) {
|
||||
/* color to float */
|
||||
folder.make_constant(linear_rgb_to_gray(value_color));
|
||||
float val = folder.scene->shader_manager->linear_rgb_to_gray(value_color);
|
||||
folder.make_constant(val);
|
||||
}
|
||||
else {
|
||||
/* vector/point/normal to float */
|
||||
@@ -2789,11 +2792,17 @@ NODE_DEFINE(AmbientOcclusionNode)
|
||||
{
|
||||
NodeType* type = NodeType::add("ambient_occlusion", create, NodeType::SHADER);
|
||||
|
||||
SOCKET_IN_NORMAL(normal_osl, "NormalIn", make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_NORMAL | SocketType::OSL_INTERNAL);
|
||||
SOCKET_IN_COLOR(color, "Color", make_float3(0.8f, 0.8f, 0.8f));
|
||||
SOCKET_IN_FLOAT(surface_mix_weight, "SurfaceMixWeight", 0.0f, SocketType::SVM_INTERNAL);
|
||||
SOCKET_INT(samples, "Samples", 8);
|
||||
|
||||
SOCKET_OUT_CLOSURE(AO, "AO");
|
||||
SOCKET_IN_COLOR(color, "Color", make_float3(0.8f, 0.8f, 0.8f));
|
||||
SOCKET_IN_FLOAT(distance, "Distance", 1.0f);
|
||||
SOCKET_IN_NORMAL(normal, "Normal", make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_NORMAL);
|
||||
|
||||
SOCKET_BOOLEAN(inside, "Inside", false);
|
||||
SOCKET_BOOLEAN(only_local, "Only Local", true);
|
||||
|
||||
SOCKET_OUT_COLOR(color, "Color");
|
||||
SOCKET_OUT_FLOAT(ao, "AO");
|
||||
|
||||
return type;
|
||||
}
|
||||
@@ -2806,17 +2815,33 @@ AmbientOcclusionNode::AmbientOcclusionNode()
|
||||
void AmbientOcclusionNode::compile(SVMCompiler& compiler)
|
||||
{
|
||||
ShaderInput *color_in = input("Color");
|
||||
ShaderInput *distance_in = input("Distance");
|
||||
ShaderInput *normal_in = input("Normal");
|
||||
ShaderOutput *color_out = output("Color");
|
||||
ShaderOutput *ao_out = output("AO");
|
||||
|
||||
if(color_in->link)
|
||||
compiler.add_node(NODE_CLOSURE_WEIGHT, compiler.stack_assign(color_in));
|
||||
else
|
||||
compiler.add_node(NODE_CLOSURE_SET_WEIGHT, color);
|
||||
int flags = (inside? NODE_AO_INSIDE : 0) | (only_local? NODE_AO_ONLY_LOCAL : 0);
|
||||
|
||||
compiler.add_node(NODE_CLOSURE_AMBIENT_OCCLUSION, compiler.closure_mix_weight_offset());
|
||||
if (!distance_in->link && distance == 0.0f) {
|
||||
flags |= NODE_AO_GLOBAL_RADIUS;
|
||||
}
|
||||
|
||||
compiler.add_node(NODE_AMBIENT_OCCLUSION,
|
||||
compiler.encode_uchar4(flags,
|
||||
compiler.stack_assign_if_linked(distance_in),
|
||||
compiler.stack_assign_if_linked(normal_in),
|
||||
compiler.stack_assign(ao_out)),
|
||||
compiler.encode_uchar4(compiler.stack_assign(color_in),
|
||||
compiler.stack_assign(color_out),
|
||||
samples),
|
||||
__float_as_uint(distance));
|
||||
}
|
||||
|
||||
void AmbientOcclusionNode::compile(OSLCompiler& compiler)
|
||||
{
|
||||
compiler.parameter(this, "samples");
|
||||
compiler.parameter(this, "inside");
|
||||
compiler.parameter(this, "only_local");
|
||||
compiler.add(this, "node_ambient_occlusion");
|
||||
}
|
||||
|
||||
|
||||
@@ -540,12 +540,16 @@ public:
|
||||
SHADER_NODE_CLASS(AmbientOcclusionNode)
|
||||
|
||||
bool has_spatial_varying() { return true; }
|
||||
virtual int get_group() { return NODE_GROUP_LEVEL_1; }
|
||||
virtual ClosureType get_closure_type() { return CLOSURE_AMBIENT_OCCLUSION_ID; }
|
||||
virtual int get_group() { return NODE_GROUP_LEVEL_3; }
|
||||
virtual bool has_raytrace() { return true; }
|
||||
|
||||
float3 normal_osl;
|
||||
float3 color;
|
||||
float surface_mix_weight;
|
||||
float distance;
|
||||
float3 normal;
|
||||
int samples;
|
||||
|
||||
bool only_local;
|
||||
bool inside;
|
||||
};
|
||||
|
||||
class VolumeNode : public ShaderNode {
|
||||
|
||||
@@ -31,6 +31,11 @@
|
||||
|
||||
#include "util/util_foreach.h"
|
||||
|
||||
#ifdef WITH_OCIO
|
||||
# include <OpenColorIO/OpenColorIO.h>
|
||||
namespace OCIO = OCIO_NAMESPACE;
|
||||
#endif
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
thread_mutex ShaderManager::lookup_table_mutex;
|
||||
@@ -339,6 +344,40 @@ ShaderManager::ShaderManager()
|
||||
{
|
||||
need_update = true;
|
||||
beckmann_table_offset = TABLE_OFFSET_INVALID;
|
||||
|
||||
xyz_to_r = make_float3( 3.2404542f, -1.5371385f, -0.4985314f);
|
||||
xyz_to_g = make_float3(-0.9692660f, 1.8760108f, 0.0415560f);
|
||||
xyz_to_b = make_float3( 0.0556434f, -0.2040259f, 1.0572252f);
|
||||
rgb_to_y = make_float3( 0.2126729f, 0.7151522f, 0.0721750f);
|
||||
|
||||
#ifdef WITH_OCIO
|
||||
OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
|
||||
if(config) {
|
||||
if(config->hasRole("XYZ") && config->hasRole("scene_linear")) {
|
||||
OCIO::ConstProcessorRcPtr to_rgb_processor = config->getProcessor("XYZ", "scene_linear");
|
||||
OCIO::ConstProcessorRcPtr to_xyz_processor = config->getProcessor("scene_linear", "XYZ");
|
||||
if(to_rgb_processor && to_xyz_processor) {
|
||||
float r[] = {1.0f, 0.0f, 0.0f};
|
||||
float g[] = {0.0f, 1.0f, 0.0f};
|
||||
float b[] = {0.0f, 0.0f, 1.0f};
|
||||
to_xyz_processor->applyRGB(r);
|
||||
to_xyz_processor->applyRGB(g);
|
||||
to_xyz_processor->applyRGB(b);
|
||||
rgb_to_y = make_float3(r[1], g[1], b[1]);
|
||||
|
||||
float x[] = {1.0f, 0.0f, 0.0f};
|
||||
float y[] = {0.0f, 1.0f, 0.0f};
|
||||
float z[] = {0.0f, 0.0f, 1.0f};
|
||||
to_rgb_processor->applyRGB(x);
|
||||
to_rgb_processor->applyRGB(y);
|
||||
to_rgb_processor->applyRGB(z);
|
||||
xyz_to_r = make_float3(x[0], y[0], z[0]);
|
||||
xyz_to_g = make_float3(x[1], y[1], z[1]);
|
||||
xyz_to_b = make_float3(x[2], y[2], z[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
ShaderManager::~ShaderManager()
|
||||
@@ -519,6 +558,14 @@ void ShaderManager::device_update_common(Device *device,
|
||||
kintegrator->use_volumes = has_volumes;
|
||||
/* TODO(sergey): De-duplicate with flags set in integrator.cpp. */
|
||||
kintegrator->transparent_shadows = has_transparent_shadow;
|
||||
|
||||
/* film */
|
||||
KernelFilm *kfilm = &dscene->data.film;
|
||||
/* color space, needs to be here because e.g. displacement shaders could depend on it */
|
||||
kfilm->xyz_to_r = float3_to_float4(xyz_to_r);
|
||||
kfilm->xyz_to_g = float3_to_float4(xyz_to_g);
|
||||
kfilm->xyz_to_b = float3_to_float4(xyz_to_b);
|
||||
kfilm->rgb_to_y = float3_to_float4(rgb_to_y);
|
||||
}
|
||||
|
||||
void ShaderManager::device_free_common(Device *, DeviceScene *dscene, Scene *scene)
|
||||
@@ -644,5 +691,10 @@ void ShaderManager::free_memory()
|
||||
beckmann_table.free_memory();
|
||||
}
|
||||
|
||||
float ShaderManager::linear_rgb_to_gray(float3 c)
|
||||
{
|
||||
return dot(c, rgb_to_y);
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
|
||||
@@ -196,6 +196,8 @@ public:
|
||||
|
||||
static void free_memory();
|
||||
|
||||
float linear_rgb_to_gray(float3 c);
|
||||
|
||||
protected:
|
||||
ShaderManager();
|
||||
|
||||
@@ -212,6 +214,11 @@ protected:
|
||||
DeviceRequestedFeatures *requested_features);
|
||||
|
||||
thread_spin_lock attribute_lock_;
|
||||
|
||||
float3 xyz_to_r;
|
||||
float3 xyz_to_g;
|
||||
float3 xyz_to_b;
|
||||
float3 rgb_to_y;
|
||||
};
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
@@ -42,6 +42,11 @@ if(WITH_CYCLES_OSL)
|
||||
${LLVM_LIBRARIES}
|
||||
)
|
||||
endif()
|
||||
if(WITH_OPENCOLORIO)
|
||||
list(APPEND ALL_CYCLES_LIBRARIES
|
||||
${OPENCOLORIO_LIBRARIES}
|
||||
)
|
||||
endif()
|
||||
if(WITH_IMAGE_OPENJPEG)
|
||||
if(WITH_SYSTEM_OPENJPEG)
|
||||
list(APPEND ALL_CYCLES_LIBRARIES ${OPENJPEG_LIBRARIES})
|
||||
|
||||
@@ -47,7 +47,7 @@ ccl_device_inline float3 color_byte_to_float(uchar4 c)
|
||||
return make_float3(c.x*(1.0f/255.0f), c.y*(1.0f/255.0f), c.z*(1.0f/255.0f));
|
||||
}
|
||||
|
||||
ccl_device float color_srgb_to_scene_linear(float c)
|
||||
ccl_device float color_srgb_to_linear(float c)
|
||||
{
|
||||
if(c < 0.04045f)
|
||||
return (c < 0.0f)? 0.0f: c * (1.0f/12.92f);
|
||||
@@ -55,7 +55,7 @@ ccl_device float color_srgb_to_scene_linear(float c)
|
||||
return powf((c + 0.055f) * (1.0f / 1.055f), 2.4f);
|
||||
}
|
||||
|
||||
ccl_device float color_scene_linear_to_srgb(float c)
|
||||
ccl_device float color_linear_to_srgb(float c)
|
||||
{
|
||||
if(c < 0.0031308f)
|
||||
return (c < 0.0f)? 0.0f: c * 12.92f;
|
||||
@@ -150,13 +150,6 @@ ccl_device float3 xyY_to_xyz(float x, float y, float Y)
|
||||
return make_float3(X, Y, Z);
|
||||
}
|
||||
|
||||
ccl_device float3 xyz_to_rgb(float x, float y, float z)
|
||||
{
|
||||
return make_float3(3.240479f * x + -1.537150f * y + -0.498535f * z,
|
||||
-0.969256f * x + 1.875991f * y + 0.041556f * z,
|
||||
0.055648f * x + -0.204043f * y + 1.057311f * z);
|
||||
}
|
||||
|
||||
#ifdef __KERNEL_SSE2__
|
||||
/*
|
||||
* Calculate initial guess for arg^exp based on float representation
|
||||
@@ -204,7 +197,7 @@ ccl_device_inline ssef fastpow24(const ssef &arg)
|
||||
return x * (x * x);
|
||||
}
|
||||
|
||||
ccl_device ssef color_srgb_to_scene_linear(const ssef &c)
|
||||
ccl_device ssef color_srgb_to_linear(const ssef &c)
|
||||
{
|
||||
sseb cmp = c < ssef(0.04045f);
|
||||
ssef lt = max(c * ssef(1.0f/12.92f), ssef(0.0f));
|
||||
@@ -214,42 +207,37 @@ ccl_device ssef color_srgb_to_scene_linear(const ssef &c)
|
||||
}
|
||||
#endif /* __KERNEL_SSE2__ */
|
||||
|
||||
ccl_device float3 color_srgb_to_scene_linear_v3(float3 c)
|
||||
ccl_device float3 color_srgb_to_linear_v3(float3 c)
|
||||
{
|
||||
return make_float3(color_srgb_to_scene_linear(c.x),
|
||||
color_srgb_to_scene_linear(c.y),
|
||||
color_srgb_to_scene_linear(c.z));
|
||||
return make_float3(color_srgb_to_linear(c.x),
|
||||
color_srgb_to_linear(c.y),
|
||||
color_srgb_to_linear(c.z));
|
||||
}
|
||||
|
||||
ccl_device float3 color_scene_linear_to_srgb_v3(float3 c)
|
||||
ccl_device float3 color_linear_to_srgb_v3(float3 c)
|
||||
{
|
||||
return make_float3(color_scene_linear_to_srgb(c.x),
|
||||
color_scene_linear_to_srgb(c.y),
|
||||
color_scene_linear_to_srgb(c.z));
|
||||
return make_float3(color_linear_to_srgb(c.x),
|
||||
color_linear_to_srgb(c.y),
|
||||
color_linear_to_srgb(c.z));
|
||||
}
|
||||
|
||||
ccl_device float4 color_srgb_to_scene_linear_v4(float4 c)
|
||||
ccl_device float4 color_srgb_to_linear_v4(float4 c)
|
||||
{
|
||||
#ifdef __KERNEL_SSE2__
|
||||
ssef r_ssef;
|
||||
float4 &r = (float4 &)r_ssef;
|
||||
r = c;
|
||||
r_ssef = color_srgb_to_scene_linear(r_ssef);
|
||||
r_ssef = color_srgb_to_linear(r_ssef);
|
||||
r.w = c.w;
|
||||
return r;
|
||||
#else
|
||||
return make_float4(color_srgb_to_scene_linear(c.x),
|
||||
color_srgb_to_scene_linear(c.y),
|
||||
color_srgb_to_scene_linear(c.z),
|
||||
return make_float4(color_srgb_to_linear(c.x),
|
||||
color_srgb_to_linear(c.y),
|
||||
color_srgb_to_linear(c.z),
|
||||
c.w);
|
||||
#endif
|
||||
}
|
||||
|
||||
ccl_device float linear_rgb_to_gray(float3 c)
|
||||
{
|
||||
return c.x*0.2126f + c.y*0.7152f + c.z*0.0722f;
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
#endif /* __UTIL_COLOR_H__ */
|
||||
|
||||
@@ -30,7 +30,7 @@ set(SRC
|
||||
intern/marching_cubes_table.cpp
|
||||
intern/octree.cpp
|
||||
intern/Projections.cpp
|
||||
|
||||
|
||||
intern/cubes.h
|
||||
intern/GeoCommon.h
|
||||
intern/manifold_table.h
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
# WITH_OPENGL limits the visibility of the opengl headers to just gawain and bg_gpu,
|
||||
# to more easily highlight codepadths in other libraries that need to be refactored,
|
||||
# bf_intern_gawain is allowed to have opengl regardless of this option.
|
||||
|
||||
if(NOT WITH_OPENGL)
|
||||
add_definitions(-DWITH_OPENGL)
|
||||
endif()
|
||||
|
||||
set(INC
|
||||
gawain
|
||||
|
||||
@@ -31,11 +31,11 @@ typedef struct Gwn_Batch {
|
||||
Gwn_VertBuf* verts[GWN_BATCH_VBO_MAX_LEN]; // verts[0] is required, others can be NULL
|
||||
Gwn_VertBuf* inst; // instance attribs
|
||||
Gwn_IndexBuf* elem; // NULL if element list not needed
|
||||
GLenum gl_prim_type;
|
||||
uint32_t gl_prim_type;
|
||||
|
||||
// cached values (avoid dereferencing later)
|
||||
GLuint vao_id;
|
||||
GLuint program;
|
||||
uint32_t vao_id;
|
||||
uint32_t program;
|
||||
const struct Gwn_ShaderInterface* interface;
|
||||
|
||||
// book-keeping
|
||||
@@ -52,13 +52,13 @@ typedef struct Gwn_Batch {
|
||||
// Static handle count
|
||||
struct {
|
||||
const struct Gwn_ShaderInterface* interfaces[GWN_BATCH_VAO_STATIC_LEN];
|
||||
GLuint vao_ids[GWN_BATCH_VAO_STATIC_LEN];
|
||||
uint32_t vao_ids[GWN_BATCH_VAO_STATIC_LEN];
|
||||
} static_vaos;
|
||||
// Dynamic handle count
|
||||
struct {
|
||||
unsigned count;
|
||||
const struct Gwn_ShaderInterface** interfaces;
|
||||
GLuint* vao_ids;
|
||||
uint32_t* vao_ids;
|
||||
} dynamic_vaos;
|
||||
};
|
||||
|
||||
@@ -95,8 +95,8 @@ int GWN_batch_vertbuf_add_ex(Gwn_Batch*, Gwn_VertBuf*, bool own_vbo);
|
||||
#define GWN_batch_vertbuf_add(batch, verts) \
|
||||
GWN_batch_vertbuf_add_ex(batch, verts, false)
|
||||
|
||||
void GWN_batch_program_set_no_use(Gwn_Batch*, GLuint program, const Gwn_ShaderInterface*);
|
||||
void GWN_batch_program_set(Gwn_Batch*, GLuint program, const Gwn_ShaderInterface*);
|
||||
void GWN_batch_program_set_no_use(Gwn_Batch*, uint32_t program, const Gwn_ShaderInterface*);
|
||||
void GWN_batch_program_set(Gwn_Batch*, uint32_t program, const Gwn_ShaderInterface*);
|
||||
// Entire batch draws with one shader program, but can be redrawn later with another program.
|
||||
// Vertex shader's inputs must be compatible with the batch's vertex format.
|
||||
|
||||
|
||||
@@ -20,7 +20,10 @@
|
||||
#define TRUST_NO_ONE 1
|
||||
#endif
|
||||
|
||||
#include <GL/glew.h>
|
||||
#if defined(WITH_OPENGL)
|
||||
#include <GL/glew.h>
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
@@ -27,12 +27,12 @@ typedef struct Gwn_IndexBuf {
|
||||
unsigned index_ct;
|
||||
#if GWN_TRACK_INDEX_RANGE
|
||||
Gwn_IndexBufType index_type;
|
||||
GLenum gl_index_type;
|
||||
uint32_t gl_index_type;
|
||||
unsigned min_index;
|
||||
unsigned max_index;
|
||||
unsigned base_index;
|
||||
#endif
|
||||
GLuint vbo_id; // 0 indicates not yet sent to VRAM
|
||||
uint32_t vbo_id; // 0 indicates not yet sent to VRAM
|
||||
bool use_prim_restart;
|
||||
} Gwn_IndexBuf;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
Gwn_VertFormat* immVertexFormat(void); // returns a cleared vertex format, ready for add_attrib
|
||||
|
||||
void immBindProgram(GLuint program, const Gwn_ShaderInterface*); // every immBegin must have a program bound first
|
||||
void immBindProgram(uint32_t program, const Gwn_ShaderInterface*); // every immBegin must have a program bound first
|
||||
void immUnbindProgram(void); // call after your last immEnd, or before binding another program
|
||||
|
||||
void immBegin(Gwn_PrimType, unsigned vertex_ct); // must supply exactly vertex_ct vertices
|
||||
|
||||
@@ -48,16 +48,16 @@ typedef struct Gwn_ShaderInput {
|
||||
uint32_t name_offset;
|
||||
unsigned name_hash;
|
||||
Gwn_UniformBuiltin builtin_type; // only for uniform inputs
|
||||
GLenum gl_type; // only for attrib inputs
|
||||
GLint size; // only for attrib inputs
|
||||
GLint location;
|
||||
uint32_t gl_type; // only for attrib inputs
|
||||
int32_t size; // only for attrib inputs
|
||||
int32_t location;
|
||||
} Gwn_ShaderInput;
|
||||
|
||||
#define GWN_NUM_SHADERINTERFACE_BUCKETS 257
|
||||
#define GWN_SHADERINTERFACE_REF_ALLOC_COUNT 16
|
||||
|
||||
typedef struct Gwn_ShaderInterface {
|
||||
GLint program;
|
||||
int32_t program;
|
||||
uint32_t name_buffer_offset;
|
||||
Gwn_ShaderInput* attrib_buckets[GWN_NUM_SHADERINTERFACE_BUCKETS];
|
||||
Gwn_ShaderInput* uniform_buckets[GWN_NUM_SHADERINTERFACE_BUCKETS];
|
||||
@@ -68,7 +68,7 @@ typedef struct Gwn_ShaderInterface {
|
||||
unsigned batches_ct;
|
||||
} Gwn_ShaderInterface;
|
||||
|
||||
Gwn_ShaderInterface* GWN_shaderinterface_create(GLint program_id);
|
||||
Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program_id);
|
||||
void GWN_shaderinterface_discard(Gwn_ShaderInterface*);
|
||||
|
||||
const Gwn_ShaderInput* GWN_shaderinterface_uniform(const Gwn_ShaderInterface*, const char* name);
|
||||
|
||||
@@ -34,8 +34,8 @@ typedef struct Gwn_VertBuf {
|
||||
unsigned vertex_ct; // number of verts we want to draw
|
||||
unsigned vertex_alloc; // number of verts data
|
||||
bool dirty;
|
||||
GLubyte* data; // NULL indicates data in VRAM (unmapped)
|
||||
GLuint vbo_id; // 0 indicates not yet allocated
|
||||
unsigned char* data; // NULL indicates data in VRAM (unmapped)
|
||||
uint32_t vbo_id; // 0 indicates not yet allocated
|
||||
Gwn_UsageType usage; // usage hint for GL optimisation
|
||||
} Gwn_VertBuf;
|
||||
|
||||
@@ -71,17 +71,17 @@ void GWN_vertbuf_attr_fill_stride(Gwn_VertBuf*, unsigned a_idx, unsigned stride,
|
||||
typedef struct Gwn_VertBufRaw {
|
||||
unsigned size;
|
||||
unsigned stride;
|
||||
GLubyte* data;
|
||||
GLubyte* data_init;
|
||||
unsigned char* data;
|
||||
unsigned char* data_init;
|
||||
#if TRUST_NO_ONE
|
||||
// Only for overflow check
|
||||
GLubyte* _data_end;
|
||||
unsigned char* _data_end;
|
||||
#endif
|
||||
} Gwn_VertBufRaw;
|
||||
|
||||
GWN_INLINE void *GWN_vertbuf_raw_step(Gwn_VertBufRaw *a)
|
||||
{
|
||||
GLubyte* data = a->data;
|
||||
unsigned char* data = a->data;
|
||||
a->data += a->stride;
|
||||
#if TRUST_NO_ONE
|
||||
assert(data < a->_data_end);
|
||||
|
||||
@@ -283,7 +283,7 @@ static GLuint batch_vao_get(Gwn_Batch *batch)
|
||||
return new_vao;
|
||||
}
|
||||
|
||||
void GWN_batch_program_set_no_use(Gwn_Batch* batch, GLuint program, const Gwn_ShaderInterface* shaderface)
|
||||
void GWN_batch_program_set_no_use(Gwn_Batch* batch, uint32_t program, const Gwn_ShaderInterface* shaderface)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(glIsProgram(shaderface->program));
|
||||
@@ -295,7 +295,7 @@ void GWN_batch_program_set_no_use(Gwn_Batch* batch, GLuint program, const Gwn_Sh
|
||||
batch->vao_id = batch_vao_get(batch);
|
||||
}
|
||||
|
||||
void GWN_batch_program_set(Gwn_Batch* batch, GLuint program, const Gwn_ShaderInterface* shaderface)
|
||||
void GWN_batch_program_set(Gwn_Batch* batch, uint32_t program, const Gwn_ShaderInterface* shaderface)
|
||||
{
|
||||
GWN_batch_program_set_no_use(batch, program, shaderface);
|
||||
GWN_batch_program_use_begin(batch); // hack! to make Batch_Uniform* simpler
|
||||
|
||||
@@ -193,7 +193,7 @@ static const Gwn_ShaderInput* add_uniform(Gwn_ShaderInterface* shaderface, const
|
||||
return input;
|
||||
}
|
||||
|
||||
Gwn_ShaderInterface* GWN_shaderinterface_create(GLint program)
|
||||
Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program)
|
||||
{
|
||||
Gwn_ShaderInterface* shaderface = calloc(1, sizeof(Gwn_ShaderInterface));
|
||||
shaderface->program = program;
|
||||
|
||||
@@ -72,7 +72,8 @@ GHOST_ContextGLX::GHOST_ContextGLX(
|
||||
m_contextMinorVersion(contextMinorVersion),
|
||||
m_contextFlags(contextFlags),
|
||||
m_contextResetNotificationStrategy(contextResetNotificationStrategy),
|
||||
m_context(None)
|
||||
m_context(None),
|
||||
m_init(false)
|
||||
{
|
||||
assert(m_display != NULL);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@ GHOST_ContextWGL::GHOST_ContextWGL(
|
||||
int contextFlags,
|
||||
int contextResetNotificationStrategy)
|
||||
: GHOST_Context(stereoVisual, numOfAASamples),
|
||||
m_dummyPbuffer(NULL),
|
||||
m_hWnd(hWnd),
|
||||
m_hDC(hDC),
|
||||
m_contextProfileMask(contextProfileMask),
|
||||
@@ -71,7 +70,8 @@ GHOST_ContextWGL::GHOST_ContextWGL(
|
||||
m_contextFlags(contextFlags),
|
||||
m_alphaBackground(alphaBackground),
|
||||
m_contextResetNotificationStrategy(contextResetNotificationStrategy),
|
||||
m_hGLRC(NULL)
|
||||
m_hGLRC(NULL),
|
||||
m_init(false)
|
||||
#ifndef NDEBUG
|
||||
,
|
||||
m_dummyVendor(NULL),
|
||||
@@ -79,6 +79,7 @@ GHOST_ContextWGL::GHOST_ContextWGL(
|
||||
m_dummyVersion(NULL)
|
||||
#endif
|
||||
{
|
||||
assert(m_hDC != NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -98,12 +99,6 @@ GHOST_ContextWGL::~GHOST_ContextWGL()
|
||||
|
||||
WIN32_CHK(::wglDeleteContext(m_hGLRC));
|
||||
}
|
||||
if (m_dummyPbuffer) {
|
||||
if (m_hDC != NULL)
|
||||
WIN32_CHK(::wglReleasePbufferDCARB(m_dummyPbuffer, m_hDC));
|
||||
|
||||
WIN32_CHK(::wglDestroyPbufferARB(m_dummyPbuffer));
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
@@ -327,38 +322,10 @@ static HWND clone_window(HWND hWnd, LPVOID lpParam)
|
||||
return hwndCloned;
|
||||
}
|
||||
|
||||
/* It can happen that glew has not been init yet but we need some wgl functions.
|
||||
* This create a dummy context on the screen window and init glew to have correct
|
||||
* functions pointers. */
|
||||
static GHOST_TSuccess forceInitWGLEW(int iPixelFormat, PIXELFORMATDESCRIPTOR &chosenPFD)
|
||||
{
|
||||
HDC dummyHDC = GetDC(NULL);
|
||||
|
||||
if (!WIN32_CHK(::SetPixelFormat(dummyHDC, iPixelFormat, &chosenPFD)))
|
||||
return GHOST_kFailure;
|
||||
|
||||
HGLRC dummyHGLRC = ::wglCreateContext(dummyHDC);
|
||||
|
||||
if (!WIN32_CHK(dummyHGLRC != NULL))
|
||||
return GHOST_kFailure;
|
||||
|
||||
if (!WIN32_CHK(::wglMakeCurrent(dummyHDC, dummyHGLRC)))
|
||||
return GHOST_kFailure;
|
||||
|
||||
if (GLEW_CHK(glewInit()) != GLEW_OK)
|
||||
return GHOST_kFailure;
|
||||
|
||||
WIN32_CHK(::wglDeleteContext(dummyHGLRC));
|
||||
|
||||
WIN32_CHK(ReleaseDC(NULL, dummyHDC));
|
||||
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
|
||||
void GHOST_ContextWGL::initContextWGLEW(PIXELFORMATDESCRIPTOR &preferredPFD)
|
||||
{
|
||||
HWND dummyHWND = NULL;
|
||||
HPBUFFERARB dummyhBuffer = NULL;
|
||||
|
||||
HDC dummyHDC = NULL;
|
||||
HGLRC dummyHGLRC = NULL;
|
||||
@@ -393,19 +360,6 @@ void GHOST_ContextWGL::initContextWGLEW(PIXELFORMATDESCRIPTOR &preferredPFD)
|
||||
|
||||
dummyHDC = GetDC(dummyHWND);
|
||||
}
|
||||
else {
|
||||
int iAttribList[] = {0};
|
||||
|
||||
if (wglCreatePbufferARB == NULL) {
|
||||
/* This should only happen in background mode when rendering with opengl engine. */
|
||||
if (forceInitWGLEW(iPixelFormat, chosenPFD) != GHOST_kSuccess) {
|
||||
goto finalize;
|
||||
}
|
||||
}
|
||||
|
||||
dummyhBuffer = wglCreatePbufferARB(m_hDC, iPixelFormat, 1, 1, iAttribList);
|
||||
dummyHDC = wglGetPbufferDCARB(dummyhBuffer);
|
||||
}
|
||||
|
||||
if (!WIN32_CHK(dummyHDC != NULL))
|
||||
goto finalize;
|
||||
@@ -448,12 +402,6 @@ finalize:
|
||||
|
||||
WIN32_CHK(::DestroyWindow(dummyHWND));
|
||||
}
|
||||
else if (dummyhBuffer != NULL) {
|
||||
if (dummyHDC != NULL)
|
||||
WIN32_CHK(::wglReleasePbufferDCARB(dummyhBuffer, dummyHDC));
|
||||
|
||||
WIN32_CHK(::wglDestroyPbufferARB(dummyhBuffer));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -815,9 +763,7 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
|
||||
HDC prevHDC = ::wglGetCurrentDC();
|
||||
WIN32_CHK(GetLastError() == NO_ERROR);
|
||||
|
||||
const bool create_hDC = m_hDC == NULL;
|
||||
|
||||
if (!WGLEW_ARB_create_context || create_hDC || ::GetPixelFormat(m_hDC) == 0) {
|
||||
if (!WGLEW_ARB_create_context || ::GetPixelFormat(m_hDC) == 0) {
|
||||
const bool needAlpha = m_alphaBackground;
|
||||
|
||||
#ifdef GHOST_OPENGL_STENCIL
|
||||
@@ -834,14 +780,6 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
|
||||
int iPixelFormat;
|
||||
int lastPFD;
|
||||
|
||||
if (create_hDC) {
|
||||
/* get a handle to a device context with graphics accelerator enabled */
|
||||
m_hDC = wglGetCurrentDC();
|
||||
if (m_hDC == NULL) {
|
||||
m_hDC = GetDC(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
PIXELFORMATDESCRIPTOR chosenPFD;
|
||||
|
||||
iPixelFormat = choose_pixel_format(m_stereoVisual, m_numOfAASamples, needAlpha, needStencil, sRGB);
|
||||
@@ -850,13 +788,6 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (create_hDC) {
|
||||
/* create an off-screen pixel buffer (Pbuffer) */
|
||||
int iAttribList[] = {0};
|
||||
m_dummyPbuffer = wglCreatePbufferARB(m_hDC, iPixelFormat, 1, 1, iAttribList);
|
||||
m_hDC = wglGetPbufferDCARB(m_dummyPbuffer);
|
||||
}
|
||||
|
||||
lastPFD = ::DescribePixelFormat(m_hDC, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &chosenPFD);
|
||||
|
||||
if (!WIN32_CHK(lastPFD != 0)) {
|
||||
@@ -962,22 +893,13 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Only init the non-offscreen context directly */
|
||||
if (!create_hDC) {
|
||||
initContext();
|
||||
initContext();
|
||||
|
||||
initClearGL();
|
||||
::SwapBuffers(m_hDC);
|
||||
}
|
||||
initClearGL();
|
||||
::SwapBuffers(m_hDC);
|
||||
|
||||
return GHOST_kSuccess;
|
||||
error:
|
||||
if (m_dummyPbuffer) {
|
||||
if (m_hDC != NULL)
|
||||
WIN32_CHK(::wglReleasePbufferDCARB(m_dummyPbuffer, m_hDC));
|
||||
|
||||
WIN32_CHK(::wglDestroyPbufferARB(m_dummyPbuffer));
|
||||
}
|
||||
::wglMakeCurrent(prevHDC, prevHGLRC);
|
||||
return GHOST_kFailure;
|
||||
|
||||
|
||||
@@ -144,10 +144,6 @@ private:
|
||||
|
||||
void initContextWGLEW(PIXELFORMATDESCRIPTOR &preferredPFD);
|
||||
|
||||
/* offscreen buffer with size of 1x1 pixel,
|
||||
* kept here to release the device constext when closing the program. */
|
||||
HPBUFFERARB m_dummyPbuffer;
|
||||
|
||||
HWND m_hWnd;
|
||||
HDC m_hDC;
|
||||
bool m_init;
|
||||
|
||||
@@ -316,11 +316,21 @@ GHOST_IContext *GHOST_SystemWin32::createOffscreenContext()
|
||||
|
||||
GHOST_Context *context;
|
||||
|
||||
HWND wnd = CreateWindowA("STATIC",
|
||||
"BlenderGLEW",
|
||||
WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
|
||||
0, 0, 64, 64,
|
||||
NULL, NULL,
|
||||
GetModuleHandle(NULL), NULL
|
||||
);
|
||||
|
||||
HDC mHDC = GetDC(wnd);
|
||||
|
||||
#if defined(WITH_GL_PROFILE_CORE)
|
||||
for (int minor = 5; minor >= 0; --minor) {
|
||||
context = new GHOST_ContextWGL(
|
||||
false, true, 0,
|
||||
NULL, NULL,
|
||||
wnd, mHDC,
|
||||
WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
4, minor,
|
||||
(debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
|
||||
@@ -336,7 +346,7 @@ GHOST_IContext *GHOST_SystemWin32::createOffscreenContext()
|
||||
|
||||
context = new GHOST_ContextWGL(
|
||||
false, true, 0,
|
||||
NULL, NULL,
|
||||
wnd, mHDC,
|
||||
WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
3, 3,
|
||||
(debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
|
||||
|
||||
@@ -125,6 +125,7 @@ GHOST_SystemX11(
|
||||
m_xkb_descr(NULL),
|
||||
m_start_time(0)
|
||||
{
|
||||
XInitThreads();
|
||||
m_display = XOpenDisplay(NULL);
|
||||
|
||||
if (!m_display) {
|
||||
|
||||
@@ -35,7 +35,7 @@ set(INC
|
||||
)
|
||||
|
||||
set(INC_SYS
|
||||
|
||||
|
||||
)
|
||||
|
||||
set(SRC
|
||||
|
||||
@@ -31,7 +31,7 @@ set(INC_SYS
|
||||
|
||||
set(SRC
|
||||
rb_bullet_api.cpp
|
||||
|
||||
|
||||
RBI_api.h
|
||||
)
|
||||
|
||||
|
||||
21
make.bat
21
make.bat
@@ -16,6 +16,11 @@ if errorlevel 1 goto EOF
|
||||
call "%BLENDER_DIR%\build_files\windows\find_dependencies.cmd"
|
||||
if errorlevel 1 goto EOF
|
||||
|
||||
if "%BUILD_SHOW_HASHES%" == "1" (
|
||||
call "%BLENDER_DIR%\build_files\windows\show_hashes.cmd"
|
||||
goto EOF
|
||||
)
|
||||
|
||||
if "%SHOW_HELP%" == "1" (
|
||||
call "%BLENDER_DIR%\build_files\windows\show_help.cmd"
|
||||
goto EOF
|
||||
@@ -26,7 +31,7 @@ if "%BUILD_UPDATE%" == "1" (
|
||||
goto EOF
|
||||
)
|
||||
|
||||
call "%BLENDER_DIR%\build_files\windows\detect_architecture.cmd"
|
||||
call "%BLENDER_DIR%\build_files\windows\detect_architecture.cmd"
|
||||
|
||||
if "%BUILD_VS_YEAR%" == "" (
|
||||
call "%BLENDER_DIR%\build_files\windows\autodetect_msvc.cmd"
|
||||
@@ -42,27 +47,27 @@ if "%BUILD_VS_YEAR%" == "" (
|
||||
)
|
||||
)
|
||||
|
||||
call "%BLENDER_DIR%\build_files\windows\set_build_dir.cmd"
|
||||
call "%BLENDER_DIR%\build_files\windows\set_build_dir.cmd"
|
||||
|
||||
echo Building blender with VS%BUILD_VS_YEAR% for %BUILD_ARCH% in %BUILD_DIR%
|
||||
|
||||
call "%BLENDER_DIR%\build_files\windows\check_libraries.cmd"
|
||||
call "%BLENDER_DIR%\build_files\windows\check_libraries.cmd"
|
||||
if errorlevel 1 goto EOF
|
||||
|
||||
call "%BLENDER_DIR%\build_files\windows\check_submodules.cmd"
|
||||
call "%BLENDER_DIR%\build_files\windows\check_submodules.cmd"
|
||||
if errorlevel 1 goto EOF
|
||||
|
||||
if "%BUILD_WITH_NINJA%" == "" (
|
||||
call "%BLENDER_DIR%\build_files\windows\configure_msbuild.cmd"
|
||||
call "%BLENDER_DIR%\build_files\windows\configure_msbuild.cmd"
|
||||
if errorlevel 1 goto EOF
|
||||
|
||||
call "%BLENDER_DIR%\build_files\windows\build_msbuild.cmd"
|
||||
call "%BLENDER_DIR%\build_files\windows\build_msbuild.cmd"
|
||||
if errorlevel 1 goto EOF
|
||||
) else (
|
||||
call "%BLENDER_DIR%\build_files\windows\configure_ninja.cmd"
|
||||
call "%BLENDER_DIR%\build_files\windows\configure_ninja.cmd"
|
||||
if errorlevel 1 goto EOF
|
||||
|
||||
call "%BLENDER_DIR%\build_files\windows\build_ninja.cmd"
|
||||
call "%BLENDER_DIR%\build_files\windows\build_ninja.cmd"
|
||||
if errorlevel 1 goto EOF
|
||||
)
|
||||
|
||||
|
||||
@@ -31910,6 +31910,117 @@
|
||||
id="radialGradient16215"
|
||||
xlink:href="#linearGradient18134"
|
||||
inkscape:collect="always" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient27277-1-8"
|
||||
id="linearGradient18811"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="4.1933641"
|
||||
y1="199.12067"
|
||||
x2="17.16466"
|
||||
y2="211.01585" />
|
||||
<mask
|
||||
maskUnits="userSpaceOnUse"
|
||||
id="mask25369-1">
|
||||
<g
|
||||
id="g25371-3"
|
||||
transform="translate(-21,-21)">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:url(#linearGradient25381);fill-rule:evenodd;stroke:none"
|
||||
d="m 341,302 8,8 -8,8 z"
|
||||
id="path25373-1"
|
||||
sodipodi:nodetypes="cccc"
|
||||
inkscape:transform-center-x="4" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
inkscape:transform-center-y="-4"
|
||||
sodipodi:nodetypes="cccc"
|
||||
id="path25375-1"
|
||||
d="m 357,302 -8,8 -8,-8 z"
|
||||
style="fill:url(#linearGradient25383-9);fill-rule:evenodd;stroke:none" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
inkscape:transform-center-x="-4"
|
||||
sodipodi:nodetypes="cccc"
|
||||
id="path25377-0"
|
||||
d="m 357,318 -8,-8 8,-8 z"
|
||||
style="fill:url(#linearGradient25385-1);fill-rule:evenodd;stroke:none" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
inkscape:transform-center-y="4"
|
||||
sodipodi:nodetypes="cccc"
|
||||
id="path25379-3"
|
||||
d="m 341,318 8,-8 8,8 z"
|
||||
style="fill:url(#linearGradient25387-9);fill-rule:evenodd;stroke:none" />
|
||||
</g>
|
||||
</mask>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient16595"
|
||||
id="linearGradient25383-9"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="rotate(90,339,299)"
|
||||
x1="342"
|
||||
y1="288.5"
|
||||
x2="344.5"
|
||||
y2="288.5" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient16595"
|
||||
id="linearGradient25385-1"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="rotate(180,349.5,299.5)"
|
||||
x1="342"
|
||||
y1="288.5"
|
||||
x2="344.5"
|
||||
y2="288.5" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient16595"
|
||||
id="linearGradient25387-9"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="rotate(-90,360,300)"
|
||||
x1="342"
|
||||
y1="288.5"
|
||||
x2="344.5"
|
||||
y2="288.5" />
|
||||
<mask
|
||||
maskUnits="userSpaceOnUse"
|
||||
id="mask25369-1-6">
|
||||
<g
|
||||
id="g25371-3-4"
|
||||
transform="translate(-21,-21)">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:url(#linearGradient25381);fill-rule:evenodd;stroke:none"
|
||||
d="m 341,302 8,8 -8,8 z"
|
||||
id="path25373-1-0"
|
||||
sodipodi:nodetypes="cccc"
|
||||
inkscape:transform-center-x="4" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
inkscape:transform-center-y="-4"
|
||||
sodipodi:nodetypes="cccc"
|
||||
id="path25375-1-0"
|
||||
d="m 357,302 -8,8 -8,-8 z"
|
||||
style="fill:url(#linearGradient25383-9);fill-rule:evenodd;stroke:none" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
inkscape:transform-center-x="-4"
|
||||
sodipodi:nodetypes="cccc"
|
||||
id="path25377-0-4"
|
||||
d="m 357,318 -8,-8 8,-8 z"
|
||||
style="fill:url(#linearGradient25385-1);fill-rule:evenodd;stroke:none" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
inkscape:transform-center-y="4"
|
||||
sodipodi:nodetypes="cccc"
|
||||
id="path25379-3-6"
|
||||
d="m 341,318 8,-8 8,8 z"
|
||||
style="fill:url(#linearGradient25387-9);fill-rule:evenodd;stroke:none" />
|
||||
</g>
|
||||
</mask>
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
@@ -92657,6 +92768,135 @@
|
||||
y="75.5" />
|
||||
</g>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(461.71013,377.29483)"
|
||||
style="display:inline;enable-background:new"
|
||||
id="ICON_SOLO_OFF-7">
|
||||
<rect
|
||||
y="198.9792"
|
||||
x="4.9506397"
|
||||
height="16"
|
||||
width="16"
|
||||
id="rect23018-5-4-5"
|
||||
style="display:inline;overflow:visible;visibility:visible;opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;enable-background:accumulate" />
|
||||
<g
|
||||
transform="matrix(0.94058502,0,0,0.94058502,0.9128606,12.74924)"
|
||||
id="g56716-3" />
|
||||
</g>
|
||||
<g
|
||||
transform="translate(461.99301,376.87052)"
|
||||
style="display:inline;enable-background:new"
|
||||
id="ICON_SOLO_OFF-1">
|
||||
<rect
|
||||
y="198.9792"
|
||||
x="4.9506397"
|
||||
height="16"
|
||||
width="16"
|
||||
id="rect23018-5-4-2"
|
||||
style="display:inline;overflow:visible;visibility:visible;opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;enable-background:accumulate" />
|
||||
<g
|
||||
transform="matrix(0.94058502,0,0,0.94058502,0.9128606,12.74924)"
|
||||
id="g56716-7">
|
||||
<path
|
||||
sodipodi:type="star"
|
||||
style="fill:url(#linearGradient18811);fill-opacity:1.0;stroke:#000000;stroke-width:0.96882826;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.80000001"
|
||||
id="path15855-0"
|
||||
sodipodi:sides="5"
|
||||
sodipodi:cx="13.700194"
|
||||
sodipodi:cy="207.20645"
|
||||
sodipodi:r1="7.1873641"
|
||||
sodipodi:r2="3.3158474"
|
||||
sodipodi:arg1="0.94697287"
|
||||
sodipodi:arg2="1.5618338"
|
||||
inkscape:flatsided="false"
|
||||
inkscape:rounded="0"
|
||||
inkscape:randomized="0"
|
||||
d="m 17.898641,213.04008 -4.168729,-2.51791 -4.280439,2.47993 1.106473,-4.74277 -3.6812884,-3.3046 4.8525664,-0.41328 2.005278,-4.52229 1.892578,4.48735 4.920618,0.50967 -3.682889,3.18662 z"
|
||||
inkscape:transform-center-x="-0.010954063"
|
||||
inkscape:transform-center-y="-0.74285516"
|
||||
transform="matrix(1.0972098,0,0,1.0975406,-2.0923019,-19.740595)" />
|
||||
<path
|
||||
style="fill:none;stroke:#ffffff;stroke-width:1.06316817;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:0.51147538"
|
||||
d="m 12.931855,202.51514 -1.201334,2.70994 c -0.137665,0.32193 -0.454082,0.55986 -0.800889,0.60222 l -2.9032248,0.26765 2.2358168,1.97391 c 0.261321,0.2395 0.380487,0.62447 0.300333,0.97022 l -0.667408,2.81032"
|
||||
id="path15869-9"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccccccc" />
|
||||
</g>
|
||||
</g>
|
||||
<g
|
||||
style="display:inline;enable-background:new"
|
||||
transform="translate(168.01766,170.03707)"
|
||||
id="ICON_GRID-3"
|
||||
mask="url(#mask25369-1)">
|
||||
<rect
|
||||
y="281"
|
||||
x="320"
|
||||
height="16"
|
||||
width="16"
|
||||
id="rect36193-3"
|
||||
style="display:inline;overflow:visible;visibility:visible;opacity:0.01000001;fill:#cccccc;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.70000005;marker:none;enable-background:accumulate" />
|
||||
<path
|
||||
sodipodi:nodetypes="cccc"
|
||||
d="m 324.5,295.75 v -13.5 m 7,13.5 v -13.5"
|
||||
style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path36195-8"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
id="path36197-0"
|
||||
style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="M 321.25001,285.50001 334.75,285.5 M 321.25001,292.50001 334.75,292.5"
|
||||
sodipodi:nodetypes="cccc"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
id="path36199-5"
|
||||
style="fill:none;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 324.5,296.5 v -14.99999 m 7,14.99999 v -14.99999"
|
||||
sodipodi:nodetypes="cccc"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
sodipodi:nodetypes="cccc"
|
||||
d="m 320.5,285.50001 h 15 m -15,6.99999 h 15"
|
||||
style="fill:none;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path36201-6"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
<g
|
||||
style="display:inline;enable-background:new;opacity:0.25"
|
||||
transform="translate(188.9552,170.08067)"
|
||||
id="ICON_GRID-3-7"
|
||||
mask="url(#mask25369-1-6)">
|
||||
<rect
|
||||
y="281"
|
||||
x="320"
|
||||
height="16"
|
||||
width="16"
|
||||
id="rect36193-3-2"
|
||||
style="display:inline;overflow:visible;visibility:visible;opacity:0.01000001;fill:#cccccc;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.70000005;marker:none;enable-background:accumulate" />
|
||||
<path
|
||||
sodipodi:nodetypes="cccc"
|
||||
d="m 324.5,295.75 v -13.5 m 7,13.5 v -13.5"
|
||||
style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path36195-8-8"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
id="path36197-0-2"
|
||||
style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="M 321.25001,285.50001 334.75,285.5 M 321.25001,292.50001 334.75,292.5"
|
||||
sodipodi:nodetypes="cccc"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
id="path36199-5-9"
|
||||
style="fill:none;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 324.5,296.5 v -14.99999 m 7,14.99999 v -14.99999"
|
||||
sodipodi:nodetypes="cccc"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
sodipodi:nodetypes="cccc"
|
||||
d="m 320.5,285.50001 h 15 m -15,6.99999 h 15"
|
||||
style="fill:none;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path36201-6-9"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
</g>
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
|
||||
|
Before Width: | Height: | Size: 4.4 MiB After Width: | Height: | Size: 4.4 MiB |
BIN
release/datafiles/blender_icons16/icon16_hide_off.dat
Normal file
BIN
release/datafiles/blender_icons16/icon16_hide_off.dat
Normal file
Binary file not shown.
BIN
release/datafiles/blender_icons16/icon16_hide_on.dat
Normal file
BIN
release/datafiles/blender_icons16/icon16_hide_on.dat
Normal file
Binary file not shown.
BIN
release/datafiles/blender_icons16/icon16_preset.dat
Normal file
BIN
release/datafiles/blender_icons16/icon16_preset.dat
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
release/datafiles/blender_icons32/icon32_hide_off.dat
Normal file
BIN
release/datafiles/blender_icons32/icon32_hide_off.dat
Normal file
Binary file not shown.
BIN
release/datafiles/blender_icons32/icon32_hide_on.dat
Normal file
BIN
release/datafiles/blender_icons32/icon32_hide_on.dat
Normal file
Binary file not shown.
BIN
release/datafiles/blender_icons32/icon32_preset.dat
Normal file
BIN
release/datafiles/blender_icons32/icon32_preset.dat
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user