Geometry Nodes: Implement Gabor noise node #125718
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
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
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#125718
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "OmarEmaraDev/blender:geometry-nodes-gabor"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This patch ports the Gabor noise shader texture node into Geometry
Nodes.
@ -2040,0 +2077,4 @@
* are sampled using a Bernoulli distribution, as shown in Figure (3). By stratified sampling, they
* mean a constant number of impulses per cell, so the stratification is the grid itself in that
* sense, as described in the supplementary material of the paper. */
static constexpr int IMPULSES_COUNT = 8;
static constexpr int impulses_count = 8;
@ -2040,0 +2104,4 @@
* real part of the phasor, we use the sine part instead, that is, the imaginary part of the
* phasor, as suggested by Tavernier's paper in "Section 3.3. Instance stationarity and
* normalization", to ensure a zero mean, which should help with normalization. */
static float2 compute_2d_gabor_kernel(const float2 position,
No reason for
compute
in the name, this can beconst float2 kernel = 2d_gabor_kernel(...);
, same below.@ -2040,0 +2158,4 @@
* noise while it is random for isotropic noise. The original Gabor noise paper mentions that the
* weights should be uniformly distributed in the [-1, 1] range, however, Tavernier's paper showed
* that using a Bernoulli distribution yields better results, so that is what we do. */
float2 compute_2d_gabor_noise_cell(const float2 cell,
static float2 2d_gabor_noise_cell
Especially note the static. I'm fine with the name, because it's the same in all other implementations.
Same for
compute_3d_orientation
@ -2040,0 +2257,4 @@
/* Computes the orientation of the Gabor kernel such that it is constant for anisotropic
* noise while it is random for isotropic noise. We randomize in spherical coordinates for a
* uniform distribution. */
float3 compute_3d_orientation(float3 orientation, float isotropy, float4 seed)
static float3 3d_orientation
,const orientation
, ...@ -99,0 +142,4 @@
void call(const IndexMask &mask, mf::Params params, mf::Context /*context*/) const override
{
int param = 0;
const VArray<float3> &vector = params.readonly_single_input<float3>(param++, "Vector");
(0, "Vector")
, same below, no reason for counter (+ lines will be shorter - better formatting).@ -99,0 +154,4 @@
MutableSpan<float> r_intensity = params.uninitialized_single_output_if_required<float>(
param++, "Intensity");
if (type_ == SHD_GABOR_TYPE_2D) {
Use switch statment.
@mod_moder I don't really see a good reason to rename functions, mainly because this code is copied from shader code, so it is better to keep code as identical as possible. I am already not happy about existing deviations.
This is bad what we have to do not change the backend code (without user-visible affect) due to such reason.
@ -99,0 +195,4 @@
{
const NodeTexGabor &storage = node_storage(builder.node());
builder.construct_and_set_matching_fn<GaborNoiseFunction>(
static_cast<NodeGaborType>(storage.type));
Use function style cast for trivial/numeric type/
@OmarEmaraDev Based on the previous patch (#125443) I have some further optimisations taken from my original implementation #110802.
These optimisations are especially significant on the 3D variant as this significantly reduces the number of expensive noise::hash calls.
I'll leave it to you to either implement in this patch or I can create a new patch once this patch is accepted.
@CharlieJolly Can you explain how the condition works?
The code looks wrong or incomplete.
@OmarEmaraDev It works because it is potentially skipping edge cells that are over a unit radius away from the current cell position. This is similar to the distance check in the
compute_Xd_gabor_kernel
function but performed earlier.There is also another possible optimisation. The windowed gaussian envelope can be closely approximated using a power curve. In the attached file this is showing about a 10% performance increase. This is possible because the distance value is always in the 0-1 unit range. For artistic uses, this is totally acceptable in my opinion.
@CharlieJolly Sure, but what does
(float3(i > 0, j > 0, k > 0) - local_position) * cell_offset
compute?It's computing the relative position nearest the edge of the cell grid based on the cell offset. If that relative position is too far away it is safe to skip the calculations.
It would be great if you could create a test file that demonstrates that the results are the same in geometry nodes and shader nodes.
I've added a file that can be used for validation.
There are warnings because of missing
static
right now, see inline comment. Generally looks good though.@blender-bot build