Cycles Baking gives different results than Cycles Render #43388

Closed
opened 2015-01-23 04:05:39 +01:00 by Miki · 33 comments

System Information
Windows 7 x64, NVIDIA GTX970

Blender Version
2.73

Short description of error
Cycles Baking gives different results than Cycles Render, which is particularly visible on procedurally generated materials and it makes them unusable for baking. This issue is probably caused by lack of anti-aliasing or some kind of sampling, which is enabled for Render, but not enabled for Baking. I have found that after enabling certain parts of code in kernel_bake.h, I can get more consistent results from Cycles-Baking (not the same as from Render, but really usable).

Exact steps for others to reproduce the error
I created 2 procedural materials, which I used to test rendering and baking (everything using CPU, 20 samples render, result images 512x512).

The baked images "No AA" come from official release 2.73.

The baked images "AA Enabled" come from my compiled version of Blender (64bit build, no OSL), where I enabled the following parts of code in kernel_bake.h:

ccl_device_inline float bake_clamp_mirror_repeat(float u)
{
	float fu = floorf(u);
	u = u - fu;
	return (((int)fu) & 1)? 1.0f - u: u;
}

uint rng_state = cmj_hash(i, kernel_data.integrator.seed);
float filter_x, filter_y;
path_rng_init(kg, &rng_state, sample, num_samples, &rng, 0, 0, &filter_x, &filter_y);

/* subpixel u/v offset */
if(sample > 0) {
	u = bake_clamp_mirror_repeat(u + dudx*(filter_x - 0.5f) + dudy*(filter_y - 0.5f));
	v = bake_clamp_mirror_repeat(v + dvdx*(filter_x - 0.5f) + dvdy*(filter_y - 0.5f));
}

Test_CyclesBake.png

Test_CyclesBake.blend

**System Information** Windows 7 x64, NVIDIA GTX970 **Blender Version** 2.73 **Short description of error** Cycles Baking gives different results than Cycles Render, which is particularly visible on procedurally generated materials and it makes them unusable for baking. This issue is probably caused by lack of anti-aliasing or some kind of sampling, which is enabled for Render, but not enabled for Baking. I have found that after enabling certain parts of code in kernel_bake.h, I can get more consistent results from Cycles-Baking (not the same as from Render, but really usable). **Exact steps for others to reproduce the error** I created 2 procedural materials, which I used to test rendering and baking (everything using CPU, 20 samples render, result images 512x512). The baked images "No AA" come from official release 2.73. The baked images "AA Enabled" come from my compiled version of Blender (64bit build, no OSL), where I enabled the following parts of code in kernel_bake.h: ``` ccl_device_inline float bake_clamp_mirror_repeat(float u) { float fu = floorf(u); u = u - fu; return (((int)fu) & 1)? 1.0f - u: u; } uint rng_state = cmj_hash(i, kernel_data.integrator.seed); float filter_x, filter_y; path_rng_init(kg, &rng_state, sample, num_samples, &rng, 0, 0, &filter_x, &filter_y); /* subpixel u/v offset */ if(sample > 0) { u = bake_clamp_mirror_repeat(u + dudx*(filter_x - 0.5f) + dudy*(filter_y - 0.5f)); v = bake_clamp_mirror_repeat(v + dvdx*(filter_x - 0.5f) + dvdy*(filter_y - 0.5f)); } ``` ![Test_CyclesBake.png](https://archive.blender.org/developer/F138888/Test_CyclesBake.png) [Test_CyclesBake.blend](https://archive.blender.org/developer/F138892/Test_CyclesBake.blend)
Author

Changed status to: 'Open'

Changed status to: 'Open'
Dalai Felinto was assigned by Miki 2015-01-23 04:05:39 +01:00
Author

Added subscriber: @MikiProxima

Added subscriber: @MikiProxima

#46831 was marked as duplicate of this issue

#46831 was marked as duplicate of this issue

Added subscriber: @brecht

Added subscriber: @brecht

@brecht what do you think? can we uncomment that part of the code? That may fix the #40369 bug, as you mentioned in your original commit.

@brecht what do you think? can we uncomment that part of the code? That may fix the #40369 bug, as you mentioned in your original commit.

It's not the real solution as it does not AA the geometry, but I think it's better than nothing, so seems reasonable to uncomment it.

It's not the real solution as it does not AA the geometry, but I think it's better than nothing, so seems reasonable to uncomment it.

This issue was referenced by 7b16fda379

This issue was referenced by 7b16fda3799d5b7167ef7ffe533d654810f44e36

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Closed by commit 7b16fda379.

Closed by commit 7b16fda379.

This issue was referenced by blender/cycles@b2b79a08c6

This issue was referenced by blender/cycles@b2b79a08c648cc10abd1788a16cb27961472ac98

Added subscriber: @MarcClintDion

Added subscriber: @MarcClintDion

This comment was removed by @MarcClintDion

*This comment was removed by @MarcClintDion*

Some bad news to go with the good news. It seems that this change is only useful for situations that do not involve lighting. For the Emit pass, it appears to offer and improvement of the standard method, when using GI, the resulting bake has very distinct black artifacts across the entire image.

Maybe this should only be used when the pass type is set to Emit since it offers a tremendous benefit there but ruins the Combined bake pass.

comparison.png

Some bad news to go with the good news. It seems that this change is only useful for situations that do not involve lighting. For the Emit pass, it appears to offer and improvement of the standard method, when using GI, the resulting bake has very distinct black artifacts across the entire image. Maybe this should only be used when the pass type is set to Emit since it offers a tremendous benefit there but ruins the Combined bake pass. ![comparison.png](https://archive.blender.org/developer/F139787/comparison.png)
Author

@MarcClintDion I also have tried to bake Combined pass and set Sun as a light source, and it looked very well with my procedural materials (which use mix of diffuse and glossy BSDF shaders). But my mesh geometry wasn't so deformed. Maybe that problem might rise with baking highly deformed meshes?

@MarcClintDion I also have tried to bake Combined pass and set Sun as a light source, and it looked very well with my procedural materials (which use mix of diffuse and glossy BSDF shaders). But my mesh geometry wasn't so deformed. Maybe that problem might rise with baking highly deformed meshes?

Here's another test. The first render is done with 2.73 official. The second is done using a build that has this new change(commit 7b16fda379). Both use identical settings. The usual monkey head, Smart UV Project(default Settings). Direct Lighting, Branched path tracer 256 AA samples, the other samples are all set to default '1'. The material is Diffuse white(1,0, 1,0, 1,0) and the sky is also white(1,0, 1,0, 1,0).

The results for the 2.73 official release are the same as usual, there are no unexpected problems. The first image shows the same results I always get.

AO_273_official.png

And the results from this new change are shown in the next image. Errors like that have not shown up in any build that I've used for the past year, it's specific to this new change.

patch.png

I mentioned earlier that I thought that maybe this change should only be applied to Emit passes but it unfortunately also shows up there as well. It just didn't show up for the test case posted on the other bug report. This next image shows the OSL AO shader that is posted for https://developer.blender.org/T40369 It also shows the errors even though it was baked with an Emission shader and baked using the Emit pass.

monkey_OSL_patch.png

Personally, I'd still like the option of being able to use this feature but only as an option,

Here's another test. The first render is done with 2.73 official. The second is done using a build that has this new change(commit 7b16fda379). Both use identical settings. The usual monkey head, Smart UV Project(default Settings). Direct Lighting, Branched path tracer 256 AA samples, the other samples are all set to default '1'. The material is Diffuse white(1,0, 1,0, 1,0) and the sky is also white(1,0, 1,0, 1,0). The results for the 2.73 official release are the same as usual, there are no unexpected problems. The first image shows the same results I always get. ![AO_273_official.png](https://archive.blender.org/developer/F140504/AO_273_official.png) And the results from this new change are shown in the next image. Errors like that have not shown up in any build that I've used for the past year, it's specific to this new change. ![patch.png](https://archive.blender.org/developer/F140507/patch.png) I mentioned earlier that I thought that maybe this change should only be applied to Emit passes but it unfortunately also shows up there as well. It just didn't show up for the test case posted on the other bug report. This next image shows the OSL AO shader that is posted for https://developer.blender.org/T40369 It also shows the errors even though it was baked with an Emission shader and baked using the Emit pass. ![monkey_OSL_patch.png](https://archive.blender.org/developer/F140510/monkey_OSL_patch.png) Personally, I'd still like the option of being able to use this feature but only as an option,

@MarcClintDion can you share your test file?

@MarcClintDion can you share your test file?

I left out the texture since it's 2048x. monkey.blend

I left out the texture since it's 2048x. [monkey.blend](https://archive.blender.org/developer/F140750/monkey.blend)
Member

Added subscriber: @VilemDuha

Added subscriber: @VilemDuha
Member

Ok, just tried to play with tile size and got rid of artifacts. bigger tiles and odd numbers somehow break up the vertical patterns that appear in the textures.

Ok, just tried to play with tile size and got rid of artifacts. bigger tiles and odd numbers somehow break up the vertical patterns that appear in the textures.
Member

just typing more stuff I found out:

with image 512x512
tile 64x64, - repetitive pattern each 8 pixels vertically
tile 128128 - each 32 pixels
tile 32
32 - each 2 pixels

tile 64x64 and :
image 512*512 - each 8 p
image 1024 - each4 p
image 2048 - each2p

just typing more stuff I found out: with image 512x512 tile 64x64, - repetitive pattern each 8 pixels vertically tile 128*128 - each 32 pixels tile 32*32 - each 2 pixels tile 64x64 and : image 512*512 - each 8 p image 1024 - each4 p image 2048 - each2p
Author

I tested the monkey head (without subsurf mod) and noticed the artifacts appear only along the triangle's edges where the mesh surface gets concave. On convexly curved surfaces and edges there are no artifacts. Hopefully this could be used to fix the problem. I still want to look closer on the filter algorithm.

I tested the monkey head (without subsurf mod) and noticed the artifacts appear only along the triangle's edges where the mesh surface gets concave. On convexly curved surfaces and edges there are no artifacts. Hopefully this could be used to fix the problem. I still want to look closer on the filter algorithm.

Changed status from 'Resolved' to: 'Open'

Changed status from 'Resolved' to: 'Open'
Author

Thank you Lukas Stockner! I compiled Blender with your AA fix and it really works even for concave meshes. I can finally use my procedural wood for my creations :-)
The picture bellow shows the amazing quality of baking with your AA fix compared to result from official Blender release.
Test_ProceduralWood_txt.png

Thank you Lukas Stockner! I compiled Blender with your AA fix and it really works even for concave meshes. I can finally use my procedural wood for my creations :-) The picture bellow shows the amazing quality of baking with your AA fix compared to result from official Blender release. ![Test_ProceduralWood_txt.png](https://archive.blender.org/developer/F167755/Test_ProceduralWood_txt.png)

Added subscriber: @bliblubli

Added subscriber: @bliblubli

maybe integrating the patch as it is for 2.75 would make things not perfect but at least better looking at results form users? A better patch can then be made for 2.76 like for https://developer.blender.org/T44662

maybe integrating the patch as it is for 2.75 would make things not perfect but at least better looking at results form users? A better patch can then be made for 2.76 like for https://developer.blender.org/T44662

Added subscriber: @PawelPohl

Added subscriber: @PawelPohl

Added subscriber: @SebRena

Added subscriber: @SebRena

Added subscribers: @LukasStockner, @YuryBaranov

Added subscribers: @LukasStockner, @YuryBaranov

@LukasStockner any news on that one? maybe your fix can be included in 2.77?

@LukasStockner any news on that one? maybe your fix can be included in 2.77?

This issue was referenced by c359343f8d

This issue was referenced by c359343f8dae6689c955dc1fa700cb26f6cd2e95

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

This issue was referenced by blender/cycles@749c063118

This issue was referenced by blender/cycles@749c0631186b4e54be9114e2718e57441560b6cc

Added subscriber: @GaryRitchie

Added subscriber: @GaryRitchie
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
10 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#43388
No description provided.