Using OSL nodes result noisy incorrectly baked maps. #40369

Closed
opened 2014-05-26 21:54:42 +02:00 by Bartosz Moniewski · 28 comments

Many of OSL nodes need sufficient amount of samples to yield proper results in render. Blender bakes them only at one sample so they look noisy. Using sample value in render panel don't do anything in bake of color passes so results from render preview and bake may vary drastically.
I used François Gastaldo's OSL AO node but this problem will be present in significant part of OSL shaders, especially those useful in baking.

AO
First- Color output of OSL AO node used as diffuse color. Results from render preview on 200 samples. Look good.
Second- Baked diffuse_color pass. Texture preview. Noise.
1_AO_render.png 1_AO_bake.png

Mix Factor
First- Color output of OSL AO node used as mixing factor. Render preview, 200 samples. Look Ok.
Second- Baked diffuse_color pass. Texture preview. Noise resulting incorrect color mixing.
2_MIX_render.png 2_MIX_bake.png

Exact steps for others to reproduce the error
Enable render preview too see what artist may want. Then bake diffuse-color map too see what blender will bake.

Blend File
There is a link to pasteAll: http://www.pasteall.org/blend/29275
My test blend file is to big for phabricator size limit but it need some megabytes for hi-poly object. This node works best on that type of geometry. OSL script is included in blendfile.

Many of OSL nodes need sufficient amount of samples to yield proper results in render. Blender bakes them only at one sample so they look noisy. Using sample value in render panel don't do anything in bake of color passes so results from render preview and bake may vary drastically. I used François Gastaldo's OSL AO node but this problem will be present in significant part of OSL shaders, especially those useful in baking. **AO** First- Color output of OSL AO node used as diffuse color. Results from render preview on 200 samples. Look good. Second- Baked diffuse_color pass. Texture preview. Noise. ![1_AO_render.png](https://archive.blender.org/developer/F91178/1_AO_render.png) ![1_AO_bake.png](https://archive.blender.org/developer/F91231/1_AO_bake.png) **Mix Factor** First- Color output of OSL AO node used as mixing factor. Render preview, 200 samples. Look Ok. Second- Baked diffuse_color pass. Texture preview. Noise resulting incorrect color mixing. ![2_MIX_render.png](https://archive.blender.org/developer/F91235/2_MIX_render.png) ![2_MIX_bake.png](https://archive.blender.org/developer/F91237/2_MIX_bake.png) **Exact steps for others to reproduce the error** Enable render preview too see what artist may want. Then bake diffuse-color map too see what blender will bake. **Blend File** There is a link to pasteAll: http://www.pasteall.org/blend/29275 My test blend file is to big for phabricator size limit but it need some megabytes for hi-poly object. This node works best on that type of geometry. OSL script is included in blendfile.

Changed status to: 'Open'

Changed status to: 'Open'
Dalai Felinto was assigned by Bartosz Moniewski 2014-05-26 21:54:42 +02:00

Added subscriber: @BartekMoniewski

Added subscriber: @BartekMoniewski

#42214 was marked as duplicate of this issue

#42214 was marked as duplicate of this issue
Added subscribers: @brecht, @ThomasDinges, @Lockal, @MatthewHeimlich, @marcog

We split the passes in two groups, surface passes (uv, sss/diffuse/glossy/transmission color) and light passes (combined, ao, shadow, sss/diffuse/glossy/transmission direct or indirect).

All the surface passes are baked in one sample. All the light passes are baked with the rendering sample settings.

An OSL Shader can either contribute to the surface or the light passes. In your case you will need to bake combined (or diffuse direct + indirect + color) to get the full contribution of the OSL shader.

In other words I really don't think this is a bug. @brecht do you agree?

We split the passes in two groups, surface passes (uv, sss/diffuse/glossy/transmission color) and light passes (combined, ao, shadow, sss/diffuse/glossy/transmission direct or indirect). All the surface passes are baked in one sample. All the light passes are baked with the rendering sample settings. An OSL Shader can either contribute to the surface or the light passes. In your case you will need to bake combined (or diffuse direct + indirect + color) to get the full contribution of the OSL shader. In other words I really don't think this is a bug. @brecht do you agree?

I just rendered it and realized that indeed the diffuse color is very smooth in the renderlayer pass indeed.
@BartekMoniewski do you build your own Blender? if so can you try this patch: P69 (hack solution)

I just rendered it and realized that indeed the diffuse color is very smooth in the renderlayer pass indeed. @BartekMoniewski do you build your own Blender? if so can you try this patch: [P69](https://archive.blender.org/developer/P69.txt) (hack solution)

"In your case you will need to bake combined (or diffuse direct + indirect + color) to get the full contribution of the OSL shader."

But this not solve anything from my perspective. Combined pass has no significant meaning for people who want create assets for current games. What we need most is diffuse_color, glossy_color and some masks baked also as diffuse_color. OSL nodes can be used as mix shader / mic color factor to create variety of texture effects. But with only one sample majority of this nodes will be worthless, useless for baking purposes.

Right now baking OSL as Combined pass looks like this. 200 samples bake.
combined.png

I also think this is not a bug but unfortunate design decision. But you asked for link to tracker today so I provided it.


edit:
Sadly I don't know how to build blender on my own. I get builds from buildbot.

"In your case you will need to bake combined (or diffuse direct + indirect + color) to get the full contribution of the OSL shader." But this not solve anything from my perspective. Combined pass has no significant meaning for people who want create assets for current games. What we need most is diffuse_color, glossy_color and some masks baked also as diffuse_color. OSL nodes can be used as mix shader / mic color factor to create variety of texture effects. But with only one sample majority of this nodes will be worthless, useless for baking purposes. Right now baking OSL as Combined pass looks like this. 200 samples bake. ![combined.png](https://archive.blender.org/developer/F91260/combined.png) I also think this is not a bug but unfortunate design decision. But you asked for link to tracker today so I provided it. --------------- edit: Sadly I don't know how to build blender on my own. I get builds from buildbot.

for records, the patch P70 produces this result:
AO_OSL_bake.jpg

for records, the patch [P70](https://archive.blender.org/developer/P70.txt) produces this result: ![AO_OSL_bake.jpg](https://archive.blender.org/developer/F91280/AO_OSL_bake.jpg)

This OSL shader here relies on the antialiasing, which baking does not do yet. It uses the shading position as input to a hash to generate a random number. To make this work, for each AA sample the subpixel position should be different and the shader evaluated at that point.

For best quality that should be done on the Blender side, because then you are AA sampling the geometry too and not just the shader.

This OSL shader here relies on the antialiasing, which baking does not do yet. It uses the shading position as input to a hash to generate a random number. To make this work, for each AA sample the subpixel position should be different and the shader evaluated at that point. For best quality that should be done on the Blender side, because then you are AA sampling the geometry too and not just the shader.

Is that mean when baking will have AA user will be able do specify AA sampling number just like samples in render properties? Or that number will be taken from render properties?
In my case render start looking acceptable on about 100 samples. It looks good enough on about 500 samples. But I think 500 samples for AA on normal maps or other passes will be an overkill.

Is that mean when baking will have AA user will be able do specify AA sampling number just like samples in render properties? Or that number will be taken from render properties? In my case render start looking acceptable on about 100 samples. It looks good enough on about 500 samples. But I think 500 samples for AA on normal maps or other passes will be an overkill.

Added subscriber: @mont29

Added subscriber: @mont29

Maybe this should be moved to TODO then?

Maybe this should be moved to TODO then?

I think so, this is just not implemented yet, it's the same for Blender Internal. The workaround would be to modify the OSL script to take more samples.

I think so, this is just not implemented yet, it's the same for Blender Internal. The workaround would be to modify the OSL script to take more samples.

Added subscribers: @MikiProxima, @Sergey, @dfelinto

Added subscribers: @MikiProxima, @Sergey, @dfelinto

I would like to ask if there is a technical reason why anti-aliasing doesn't work in Cycles Bake, when it can work in Render. Always when I create a procedural material, it looks great when rendered, but very crippled when baked. And obviously the current Samples doesn't help it in any way, because Render looks good even at 10 samples, but Bake looks horrible even at 500 samples. I noticed the only task where Samples helps is baking of AO.

I think baking with AA is essential feature for creating 3D graphics if you want to use procedural generators in your materials. So I would like to ask when AA is planed to be working also with baking. And if it is not planned, I offer my programming skills to help with that, because I think we should be able to use the same materials for both render and bake.
Best Regards

I would like to ask if there is a technical reason why anti-aliasing doesn't work in Cycles Bake, when it can work in Render. Always when I create a procedural material, it looks great when rendered, but very crippled when baked. And obviously the current Samples doesn't help it in any way, because Render looks good even at 10 samples, but Bake looks horrible even at 500 samples. I noticed the only task where Samples helps is baking of AO. I think baking with AA is essential feature for creating 3D graphics if you want to use procedural generators in your materials. So I would like to ask when AA is planed to be working also with baking. And if it is not planned, I offer my programming skills to help with that, because I think we should be able to use the same materials for both render and bake. Best Regards

@MikiProxima - Well.... I assume blender devs are not interested in cycles baking anymore. Still there is lack of essential things was described on code.blender.org blog (working OSL, AA, rayblockers) and other obvious things like displacement. We need to wait for some fresh blood developer willing to rewrite cycles baking for proper resources consumption (18 gigs of RAM for baking 15 objects?!) and add missing features.

@MikiProxima - Well.... I assume blender devs are not interested in cycles baking anymore. Still there is lack of essential things was described on code.blender.org blog (working OSL, AA, rayblockers) and other obvious things like displacement. We need to wait for some fresh blood developer willing to rewrite cycles baking for proper resources consumption (18 gigs of RAM for baking 15 objects?!) and add missing features.

You may want to check if 7b16fda379 fixed this issue.

You may want to check if 7b16fda379 fixed this issue.

Added subscriber: @MarcClintDion

Added subscriber: @MarcClintDion

@dfelinto, it does more than just fix the problem, it improves the quality substantially over normal rendering for the same amount of samples.

All three of the following renders were done with 128 samples. The left image is a viewport render, the center image is a bake using 2.73. The image on the right is a bake from the daily build with the new changes. Both images were baked at 2048x2048. I didn't record how long the bakes took but the times seemed close enough to not be noticeable.

new_OSL_BAKING.png

@dfelinto, it does more than just fix the problem, it improves the quality substantially over normal rendering for the same amount of samples. All three of the following renders were done with 128 samples. The left image is a viewport render, the center image is a bake using 2.73. The image on the right is a bake from the daily build with the new changes. Both images were baked at 2048x2048. I didn't record how long the bakes took but the times seemed close enough to not be noticeable. ![new_OSL_BAKING.png](https://archive.blender.org/developer/F139730/new_OSL_BAKING.png)

FINALLY! So we now can consider OSL in Cycles baking as fully working feature! :) Why so long if code was just there? "Better" is the enemy of "good enough".

Anyways, Thanks!

FINALLY! So we now can consider OSL in Cycles baking as fully working feature! :) Why so long if code was just there? "Better" is the enemy of "good enough". Anyways, Thanks!

It seems that the reason this was removed is because it ruins the baked result for the Combined pass. I've posted a test result at https://developer.blender.org/T43388

It seems that the reason this was removed is because it ruins the baked result for the Combined pass. I've posted a test result at https://developer.blender.org/T43388
Member

Changed status from 'Open' to: 'Resolved'

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

Added subscriber: @JulianEisel

Added subscriber: @JulianEisel
Member

Closing as Resolved then :)

Closing as Resolved then :)

Changed status from 'Resolved' to: 'Open'

Changed status from 'Resolved' to: 'Open'

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
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
8 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#40369
No description provided.