Strange behavior of Cycles Brick Texture #46030

Closed
opened 2015-09-06 17:30:56 +02:00 by Martin Leurs · 10 comments

Windows 7
Blender 2.75

If I add a Brick Texture in a Cycles Material, the row of bricks on the bottom does not lookas random generated then the other rows. All of the other rows seam to contain randomly choosen brick colors but in the row on the bottom, the bricks look more like colord with a color band.

I hope this gets clearer with an image:
brick_texture_not_random.jpg

And the blend file:
brick_texture_not_random.blend

Best regards
Martin

Windows 7 Blender 2.75 If I add a Brick Texture in a Cycles Material, the row of bricks on the bottom does not lookas random generated then the other rows. All of the other rows seam to contain randomly choosen brick colors but in the row on the bottom, the bricks look more like colord with a color band. I hope this gets clearer with an image: ![brick_texture_not_random.jpg](https://archive.blender.org/developer/F230849/brick_texture_not_random.jpg) And the blend file: [brick_texture_not_random.blend](https://archive.blender.org/developer/F230851/brick_texture_not_random.blend) Best regards Martin
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @martinleurs

Added subscriber: @martinleurs
Sergey Sharybin self-assigned this 2015-09-07 08:52:59 +02:00

Developer note: the issue is caused by poor distribution of random numbers coming from noise() with n close to zero. We can either simply offset n by 1024 (or xor it with some mask) or can simply re-use CMJ's hash, like this P257: Fix for #46030

diff --git a/intern/cycles/kernel/svm/svm_brick.h b/intern/cycles/kernel/svm/svm_brick.h
index fcf8f47..85647d5 100644
--- a/intern/cycles/kernel/svm/svm_brick.h
+++ b/intern/cycles/kernel/svm/svm_brick.h
@@ -18,12 +18,9 @@ CCL_NAMESPACE_BEGIN
 
 /* Brick */
 
-ccl_device_noinline float brick_noise(int n) /* fast integer noise */
+ccl_device_inline float brick_noise(int n)
 {
-	int nn;
-	n = (n >> 13) ^ n;
-	nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff;
-	return 0.5f * ((float)nn / 1073741824.0f);
+	return cmj_randfloat(n, 0xbcd60b1e);
 }
 
 ccl_device_noinline float2 svm_brick(float3 p, float mortar_size, float bias,

In any case this will change distribution of brick colors which we probably better to avoid at this point.

Developer note: the issue is caused by poor distribution of random numbers coming from `noise()` with `n` close to zero. We can either simply offset `n` by 1024 (or xor it with some mask) or can simply re-use CMJ's hash, like this [P257: Fix for #46030](https://archive.blender.org/developer/P257.txt) ```diff diff --git a/intern/cycles/kernel/svm/svm_brick.h b/intern/cycles/kernel/svm/svm_brick.h index fcf8f47..85647d5 100644 --- a/intern/cycles/kernel/svm/svm_brick.h +++ b/intern/cycles/kernel/svm/svm_brick.h @@ -18,12 +18,9 @@ CCL_NAMESPACE_BEGIN /* Brick */ -ccl_device_noinline float brick_noise(int n) /* fast integer noise */ +ccl_device_inline float brick_noise(int n) { - int nn; - n = (n >> 13) ^ n; - nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff; - return 0.5f * ((float)nn / 1073741824.0f); + return cmj_randfloat(n, 0xbcd60b1e); } ccl_device_noinline float2 svm_brick(float3 p, float mortar_size, float bias, ``` In any case this will change distribution of brick colors which we probably better to avoid at this point.

Added subscriber: @ThomasDinges

Added subscriber: @ThomasDinges

The change can be done during 2.8x, as part of some compatibility breaks.

The change can be done during 2.8x, as part of some compatibility breaks.
Member

Added subscriber: @Blendify

Added subscriber: @Blendify
Member

Is there a 2.8 project for Phabricator to keep track of things going into 2.8

Is there a 2.8 project for Phabricator to keep track of things going into 2.8

This issue was referenced by de7b7572c2

This issue was referenced by de7b7572c258c811ad0165f199d59dcef3bafad3

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

This issue was referenced by blender/cycles@5ff61a62e9

This issue was referenced by blender/cycles@5ff61a62e97b63fa097fd4c1f1291be21db0beac
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
5 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#46030
No description provided.