Page 1 of 2 12 LastLast
Results 1 to 15 of 27

Thread: I don't suppose anyone knows how to generate bump vectors for simplex noise...?

  1. #1
    eye kan kode gud jrandom's Avatar
    Join Date
    Dec 2009
    Location
    Seattle, WA
    Posts
    1,143

    I don't suppose anyone knows how to generate bump vectors for simplex noise...?

    I can haz procedural texture!

    Click image for larger version. 

Name:	Simplex Noise Node.png 
Views:	299 
Size:	23.4 KB 
ID:	113766

    It's far from feature complete -- not all the inputs/settings are implemented yet (Function, Octaves and related) and coordinate rotation doesn't work yet, but the thing that really has me stumped is the bump vector. My code is based on the implementation by Stefan Gustavson, and right now I'm just assigning the noise derivatives directly to the bump output after scaling by the bump height setting:

    Code:
        // ---------------------------------------------------------------------------- Evaluate_Bump()
        void Simplex_Noise::Evaluate_Bump ( LWTypes::LWNodalAccess * nodal_access,
                                            LWTypes::NodeValue       node_value )
        {
            // Retrieve noise and bump height
            const Simplex_Result_t simplex    (             Get_Noise( nodal_access ) );
            const double           bump_height( Input_Bump_Height.Get( nodal_access ) );
            
            
            // TODO: Figure out how to actually do this
            LWTypes::LWDVector output_vector( simplex.Noise_dX * bump_height,
                                              simplex.Noise_dY * bump_height,
                                              simplex.Noise_dZ * bump_height );
            
            // Output computed bump map
            Output_Functions->setValue( node_value, output_vector );
        }
    It almost works, but I get all these discontinuities:

    Click image for larger version. 

Name:	Simplex Bump Problem.jpg 
Views:	273 
Size:	34.3 KB 
ID:	113767 Click image for larger version. 

Name:	Simplex Bump Problem Color.jpg 
Views:	306 
Size:	47.1 KB 
ID:	113768

    Any of you experienced procedural texture devs know what causes this and how to avoid it?
    Last edited by jrandom; 04-21-2013 at 10:09 AM.

  2. #2
    eye kan kode gud jrandom's Avatar
    Join Date
    Dec 2009
    Location
    Seattle, WA
    Posts
    1,143
    If it helps, I've attached my version of the simplex noise functions. Ignore the region stuff -- that was just an experiment that didn't work out as well as I'd hoped.
    Attached Files Attached Files

  3. #3
    eye kan kode gud jrandom's Avatar
    Join Date
    Dec 2009
    Location
    Seattle, WA
    Posts
    1,143
    OMG, I'm a moron. Well, sort of.

    Bug in line 531 of Simplex_Noise.h:

    Code:
    const value_t temp_3 = t3_squared * t3 * (x3_gradient * x3 + y2_gradient * y3 + z3_gradient * z3);
    That middle bit needs to be y3_gradient, not y2_gradient:

    Code:
    const value_t temp_3 = t3_squared * t3 * (x3_gradient * x3 + y3_gradient * y3 + z3_gradient * z3);
    Also, the derivatives appear to be in the range [-1, 1] and I get better results rescaling that to [0, 1] and then inverting it so outward bumps match the bright alpha areas.

    Code:
        // ---------------------------------------------------------------------------- Evaluate_Bump()
        void Simplex_Noise::Evaluate_Bump ( LWTypes::LWNodalAccess * nodal_access,
                                            LWTypes::NodeValue       node_value )
        {
            // Retrieve noise and bump height
            const Simplex_Result_t simplex    (             Get_Noise( nodal_access ) );
            const double           bump_height( Input_Bump_Height.Get( nodal_access ) );
            
            
            // Calculate bump vector
            LWTypes::LWDVector output_vector( (1.0 - simplex.Noise_dX_01()) * bump_height,
                                              (1.0 - simplex.Noise_dY_01()) * bump_height,
                                              (1.0 - simplex.Noise_dZ_01()) * bump_height );
            
            // Output computed bump map
            Output_Functions->setValue( node_value, output_vector );
        }
    Whee! Thanks for watching me spazz out on a weekend.
    Click image for larger version. 

Name:	Working_Simplex_Bump.jpg 
Views:	242 
Size:	67.7 KB 
ID:	113770
    Attached Files Attached Files
    Last edited by jrandom; 04-21-2013 at 12:05 PM.

  4. #4
    eye kan kode gud jrandom's Avatar
    Join Date
    Dec 2009
    Location
    Seattle, WA
    Posts
    1,143
    All that remains is Invert, Contrast, Opacity, and Rotation, and this sucker's feature-complete!

    Yeah, okay, it's just bog-standard Simplex noise, but it's my first procedural texture and I can use it as a base for more interesting stuff!

    Click image for larger version. 

Name:	Almost There.png 
Views:	259 
Size:	361.2 KB 
ID:	113781

    I still have no idea how to properly apply Rotation. I'm guessing I need to stuff it, along with Scale and Position, into a matrix (I'm manually applying Scale and Position at the moment), but I was hoping there was some sort of built-in routine that would construct such a thing for me. Can't seem to find one.
    Last edited by jrandom; 04-21-2013 at 09:15 PM.

  5. #5
    eye kan kode gud jrandom's Avatar
    Join Date
    Dec 2009
    Location
    Seattle, WA
    Posts
    1,143
    Bump mixing! I foresee this coming in handy.

    Click image for larger version. 

Name:	Bump Mixing.png 
Views:	271 
Size:	443.4 KB 
ID:	113783

  6. #6
    I have no idea what are you doing but you are on fire and it looks cool so keep it going .
    RAM-Studio
    WS - Dual Xeon E5-2698v4/128GB/Win10x64/x TitanX(M) + 2x GTX 1080Ti + GTX 1080
    My LWM Video Car Modeling Tutorial

  7. #7
    Put in what many of the procedurals don't.. a normal

    Ditto with Lewis, but keep up the good work!

  8. #8
    eye kan kode gud jrandom's Avatar
    Join Date
    Dec 2009
    Location
    Seattle, WA
    Posts
    1,143
    I thought about adding Normal output, but it's no longer strictly necessary with the Bump to Normal node, and I'd have to add two more inputs (Normal Foreground, Normal Background) and then figure out they would interact with the incoming bump vectors, etc. It's a trickier problem than it looks on the surface. (Ha! Punny!)

    So I'll keep it in mind, but I'm not going to add Normals at this juncture.

    What I really need is to get Rotation implemented. I'm flabbergasted that there doesn't seem to be a "generate transformation matrix from Scale, Position, and Rotation vectors" function in the SDK.

  9. #9
    eye kan kode gud jrandom's Avatar
    Join Date
    Dec 2009
    Location
    Seattle, WA
    Posts
    1,143
    Although... well, now that I think about I, I can easily just add a Normal output and not worry about Normal inputs. I'll do that, then.

  10. #10
    eye kan kode gud jrandom's Avatar
    Join Date
    Dec 2009
    Location
    Seattle, WA
    Posts
    1,143
    Fun Fact: this node uses internal caching so the noise algorithm is only ever run once per spot, regardless of how many of the node's outputs are used. When I add a Normal output, I'll add a bump vector cache so both can be used without incurring a doubling up on the mixing calculations.

  11. #11
    Very nice. Does it also have any kind of determinism, to stop it from being different on different CPU's?

  12. #12
    eye kan kode gud jrandom's Avatar
    Join Date
    Dec 2009
    Location
    Seattle, WA
    Posts
    1,143
    Quote Originally Posted by Tobian View Post
    Very nice. Does it also have any kind of determinism, to stop it from being different on different CPU's?
    Yes, Simplex noise is deterministic. It's similer to Perlin noise (designed by the same guy, actually), but exhibits isotropy in all dimensions and is faster to calculate. It also allows for the generation of the bump vector in a single evaluation w/out having to sample multiple nearby locations.

  13. #13
    Having some fun there, it looks.

  14. #14
    eye kan kode gud jrandom's Avatar
    Join Date
    Dec 2009
    Location
    Seattle, WA
    Posts
    1,143
    For nerdy definitions of "fun", yes!

    I have to go write music for a commercial, but after that I'm back on node coding.

  15. #15
    Very encouraging :-)
    I still haven't got around to port my AoN shaders to LW.
    How did you start out? Any recommendations for tutorials or existing code to learn from (apart from the SDK itself?)?

    Cheers and have fun! :-)

    Tom

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •