Color ramp, texture and Blender hacking

After watching the development for so long, I finally decided to download the source for Blender and see if I could do anything with it.

I’ve added:

Under Textures:

Pattern: A new texture type with dots and checks. There is a frequency variable which adjusts the size.

Blend Modes: Added Dissolve, Negation, Exclusion blend modes and a new one called Replace which ignores the input and blends against nothing. Also added Dodge and Burn to the menu but the code for these was already in Blender.

Under Color Ramps:

Added some additional variables which adjust the input/output of the color ramp.

Repeat: This repeats the ramp over and over again.
Pingpong: If the ramp repeats more than once, this will alternate every other ramp.
Shift: This remaps the input along the ramp.
Reverse: This changes the direction of the ramp.
Posterize: This limits the ramp to X number of values.

I’ve added experimental py buttons for the color ramp. This is why it is a little messy and some of the buttons are repeated. I think the ramp still needs converting to the new 2.5 stuff but an experienced dev could confirm this.

Misc notes:
The patch for 2.5 is a little messy since it contains a few other tweaks, experiments and has not been reviewed.
Added a texture factor influence for Asymmetry for volumetric materials.
Repeat Node which repeats a value X number of times within a 0-1 range.
Textures and ramps are not designed to be anti-aliased. Use the oversampling option in the material settings.

Tested under scons for both Windows mingw32 and Linux Karmic 32bit. Most of the patch is pretty straight forward.

See images and video (H264 encoded from 2.49,runs very quick!!).

http://homepage.ntlworld.com/charlie.jolly/blender/color_ramp_tex.png
http://homepage.ntlworld.com/charlie.jolly/blender/ramp_tex_4nov.diff
http://homepage.ntlworld.com/charlie.jolly/blender/vid0001_0521.avi

Wow, it’s great. Colorramps are very useful, especially for motion design. I hope this patch will be included.

indeed. i luv it!

wow, that sounds great… pretty cool!

Such “bread and butter” features are much appreciated! But be advised that, at least in my impression, getting your patches accepted can be more work than the actual coding (which is not a bad thing, quality of code is important)

And here ladies and gentleman we have a clear cut case of why open source rocks. Someone downloads the source, decides to add several useful thing and that is it. Your favourite program becomes even better.

Thank you friend , very much.

Thanks for contributing!

That looks quite nice. Some of those options seem fairly useful.

Just to clarify, the plan is not to expose the Ramp parameters (position, color, current etc) in the Python layout. Instead these are inside the ramp UI template, which can then be reused throughout the UI. Certain UI elements that work as a unit (like ramp, lists, preview etc) are implemented as templates, either because it is more feasible or because it allows for some extra trickery not available through the Python UI API.

As you can see in the screenshots, the template version is a lot more compact and arguably also clearer, with the items above the ramp controlling the general ramp options and the items below it controlling the individual color stops.

Get the colors to blend together softly (like the colorband itself suggests) and this would be a great patch.

Remember to make sure your code isn’t hacky, the devs. do not like hacky code, if you can implement something it should be done without just hacking it into the existing code.

Quality/Proper implementation >>>>>>>>> Hacky/Hacked in

sounds good!

CD: The colours don’t blend because the example picture is showing the effect of the posterize setting. Otherwise it would blend as the original ramp. The reason I call it hacking is because it is really extending or adding to the existing codebase rather than a new implementation. Most of the code is altering the ramp input. I’m not an erudite coder!!!

William: Yep, the buttons are duplicated because I was looking to expose the color ramp options so that they could be keyframed etc… The existing UI doesn’t allow this. The options below the ramp can be added in python but the remaining color ramp UI could do with some tweaking and or updating. The add/delete buttons could use icons for instance.

In fact there are issues with animating the color elements. See https://projects.blender.org/tracker/index.php?func=detail&aid=19729&group_id=9&atid=498

I’ve added the patch to the tracker and we’ll see what happens. :slight_smile:

https://projects.blender.org/tracker/index.php?func=detail&aid=19808&group_id=9&atid=127

Image showing new blend types:
http://homepage.ntlworld.com/charlie.jolly/blender/example_blend_dissolve.png

Replace blend mode:
http://homepage.ntlworld.com/charlie.jolly/blender/replace_texture__alpha.png

Older patch showing some of the new blends:
http://homepage.ntlworld.com/charlie.jolly/blender/textures_ramps.png

Some additional images.
http://homepage.ntlworld.com/charlie.jolly/blender/shader_ramps.png
http://homepage.ntlworld.com/charlie.jolly/blender/monkey.png

Really neat stuff!!!..now if we could get slope in there(ala lightwave)…

The reason I call it hacking is because it is really extending or adding to the existing codebase rather than a new implementation.

I don’t know if extensions is considered hacking in all respects, especially if the code extending it is readable and follows quality guidelines.

Really good additions
I’m pleased you stopped watching and did something :wink:
looking forward to more activity from you LOL :smiley:

from wikipedia on hacking:

Hack has several related meanings in the technology and computer science fields. It may refer to a clever or quick fix to a computer program problem, or to what may be perceived to be a clumsy or inelegant (but usually relatively quick) solution to a problem. The term is also used to refer to a modification of a program or device to give the user access to features that were otherwise unavailable, such as DIY circuit bending.

:smiley: