al1brn / geonodes

Create Blender geometry nodes with python script
62 stars 4 forks source link

Seeking Help with Noise Texture and Color Ramp Node in Snowman Material #7

Open pterusgithub opened 2 days ago

pterusgithub commented 2 days ago

image Hi there, I'm trying to create a surface material for a snowman (Christmas spirit, of course!). However, I'm struggling to understand why my code isn't working. The links between the noise_texture and mix nodes don't function as expected, although the rest seems to work fine.

While I'm at it, could you provide an example of how to use the color_ramp node? Specifically, how to change the colors, add stops, and so on?

Here’s the relevant part of the code I’m using:

with geon.ShaderNodes("snowman_texture"):
    # ----- Principled BSDF
    textu_coord = geon.snd.texture_coordinate().object
    mapping = geon.snd.mapping(vector=textu_coord)
    texture_01 = geon.snd.noise_texture(vector=mapping,scale=4).color
    texture_02 = geon.snd.noise_texture(vector=mapping,scale=500,roughness=0,detail=0, distortion = 0).color
    mix = geon.snd.mix(factor=0.1, a=texture_01,b=texture_02,data_type="RGBA").result
    colorramp = geon.snd.color_ramp(fac=mix).color
    ped = geon.snd.principled_bsdf(base_color=colorramp)
    # ----- To surface output
    ped.out()  

Thanks in advance!

al1brn commented 1 day ago

Hi,

Thanks for using my module.

However, to make things easier, I just implemented the set_stops method on the color ramp node in order to set up the stops.

When initializing a color ramp node, the key word argument stops has been added:

snd.color_ramp(stops=list of stops)

To make the script work, your need to download the last version.

BR

with geon.ShaderNodes("snowman_texture"):
    # ----- Principled BSDF
    textu_coord = geon.snd.texture_coordinate().object
    mapping = geon.snd.mapping(vector=textu_coord)
    texture_01 = geon.snd.noise_texture(vector=mapping,scale=4).color
    texture_02 = geon.snd.noise_texture(vector=mapping,scale=500,roughness=0,detail=0, distortion = 0).color

    mix = geon.snd.mix(factor=0.1, a=texture_01,b=texture_02,data_type="RGBA").result

    colorramp = geon.snd.color_ramp(fac=mix).color

    colorramp.node.set_stops((0, (0, 0, 1)), (.5, 1), (.9, (1, 0, 0, .5))) 

    ped = geon.snd.principled_bsdf(base_color=colorramp)
    # ----- To surface output
    ped.out()  
pterusgithub commented 1 day ago

Hi al1brn, Thank you so much for this fix and the additional features you’ve provided. I truly appreciate your responsiveness and the effort you put into helping out. Wishing you a wonderful day!