cakeller

Synthetic Nature Shaders

26 posts in this topic

I have a few shaders I'd like to share...

Some of them will just be Simple PicMat shaders with effects like brushed metal,

but some will actually be new shaders with options not currently implemented within the default set of shaders.

For the naming convention, I will use:

SN_<Material Type>_<Description> as a general naming convention...

this is just a simple way to keep things somewhat organized wink.gif, and SN (Synthetic Nature, that's me wink.gif )

simply download and unzip in the custom folder and make sure it's

...\3D-Coat-V3\Shaders\Custom\SN_Metal_Bronze_Brushed

Cheers drinks.gif

2009.11.05 -----------------------------------

Name: SN_Metal_Bronze_Brushed:

post-2065-12574667901129_thumb.jpg

Material: Metal, Bronze

Surface: Brushed Finish

Color: Dark Brown.

Compatibility: GL and DirectX

SN_Metal_Bronze_Brushed.zip

2 people like this

Share this post


Link to post
Share on other sites

Thank you!

Nice work over shaders!

Thanks Andrew! :)

I have several I've been working on.

Looking forward to uploading more.

Share this post


Link to post
Share on other sites

2009.11.10 -----------------------------------

Name: SN_Utility_Voxel_Grid:

post-2065-12578869353149_thumb.jpg

Note that from left to right is the same model with clone and degrade, once in the middle model, and twice in the right model.

The bronze model behind them, shows the relative detail levels.

Material: Utility

Surface: surface is derived from XYZ position in actual voxel grid.

Color: Red is X voxel grid lines, Green is Y, and Blue is Z

Compatibility: ONLY GL version*

Download Shader Here

HAS BUG, WILL FIX SHORTLY! :) or you can download and apply Akira's fix (GL VERSION)

*If I get enough requests,

I will develop the Direct X versions of any GL-Only versions sooner

I plan on doing it sooner or later anyway.

1 person likes this

Share this post


Link to post
Share on other sites

Can you give an example of the 'utility' of this shader?

Cheers,

Robbie

Share this post


Link to post
Share on other sites

Can you give an example of the 'utility' of this shader?

Cheers,

Robbie

when I call it a "utility shader" what I mean is, that it gives some type of information. another example of a utility shader would be one that shows the UVs as a color, or Normal Direction.

this Voxel Grid utility shader, shows a visual representation of the voxels themselves.

it's like preojecting a 3 dimensional grid onto the object. the default spacing is 1 voxel, so each line represents one voxel spacing.

One thing it could be useful for is visually estimating how big an extrude operation would need to be, because you can guestimate... oh ok, there's 2 voxels in that direction, if I extrude by 2 voxels it will be that much bigger.

It is a "visualizer" of the data, more than anything... and it's fun :) Tron like!

let me know if you're more curious.

BTW, there is a thumbnail sample of the shader in use above.

Share this post


Link to post
Share on other sites

Thanks. I look forward to learning new methods of shader-use. Just thought it would be useful to myself & others to hear a bit more about your ideas.

Nice one

Share this post


Link to post
Share on other sites

Thanks. I look forward to learning new methods of shader-use. Just thought it would be useful to myself & others to hear a bit more about your ideas.

Nice one

Thanks I have a few more...

here's another example of the utility, or visualization, use of the SN_Utility_Voxel_Grid shader.

From right to left, the original shape, then after rotating the object, notice the grid follows the rotation because the voxels are actually rotated as a group.. then the last one is that the object has been converted to the global voxel space.

You can think of it like in photoshop, when you rotate a selection, then apply it. when you are rotating the selected layer of the image, it is still the original image until you apply it.

so while the voxel object is being transformed, it is the same as it was before the transform. When you click "to global space" it is the same idea as when you apply a transform in photoshop. the old rotated image is overlaid on the image's pixel grid.

anyway, the point is, the image, in a way, helps with understanding what is happening with voxels when they are stretched, rotated, clone+degraded, etc... and to global spaced.

post-2065-1257936116711_thumb.jpg

1 person likes this

Share this post


Link to post
Share on other sites

Awesome work man... Really glad to see someone working on and sharing shaders. I have mine piling up and will share them all in the near future.

Cheers;

AJ

Share this post


Link to post
Share on other sites

OK, YAY! I've just sat down and learned HLSL shading language (at least enough to translate the GLSL shaders)

so... with that said, take a look at what I'm referring to as a "Super Shader" meaning, it's got lots of controls and adjustments and should be extremely flexible!

The controls may (or may not) be super intuitive, but once you get the hang of it, you can do some really cool things with this shader.

I've set it up to use 2 PicMat images, one for Diffuse color, and one for Specular color.

These each have controls for brightness, and a special control to allow colorizing them based on a single color chooser. The colorizing can accept negative values to invert the color, for cool complimentary color effects. if you choose a cool sky-blue color, then ambient and diffuse can be set to positive colorization, while the specular colors can be set to negative which makes the hot-spot of the light a perfect yellowish compliment to the ambient/diffuse blue tinge.

In addition there are 3 Planar projections

(similar to the Tree Texture shader, but one each for X, Y, and Z) with Controls for Offset, and Scale of these projections. The scale is relative to voxel units. So 256 = 256 voxel units. e.g. if you create a 50x50x50 voxel cube, and set the scaling to 50, the projections will map 1:1 across the cube... if the cube's resolution is increased 2x, then the image will map across the cube 2x. This is simply a limitation of not having UVs, and having to make due with physical space or other methods. These 3 projections are blended with the diffuse PicMat, and can be invisible, or 50% blended, or be 100% of the diffuse contribution (although no lighting response at this point - although I might add that as well... later)

The "Base Color" is the color with which all adjustments are made. I chose to do this for some internal simplicity reasons, but also as a UI thing, since the color chooser doesn't update the model in real time, I thought it would be cooler to use a multiplier which DOES update in real time.

Ambient Color control is simply how much of this "base color" is used flat out. Sorta like self illumination.

There is a "System Ambient Override" control, which either gives, or takes control for this shader only, the ambient light contribution. The reason for this is so that you can use the Ambient lighting control so that it either obeys the system ambient amount, or can be used as a light source (self illumination) without needing other shaders to be bright as well.

There is also a separate brightness control for how bright the 3 projections are. This allows for a little bit of color correction if the maps are dark or light, and allows you to blend their look with the scene better.

I have 2 controls which allow you to selectively use the Top, or Front, or Side images. a Front to Side blender which goes from 0.0 - 0.5 - 1.0... 0.0 shows ONLY Front, 0.5 shows 100% Front AND Side, and 1.0 shows ONLY Side.

Similarly the Top or NOT, control blends between 0.0 - 0.5 - 1.0... where 0.0 shows no TOP and 100% of the result of the Front to Side blender, 0.5 shows 100% Top AND Front+Side, and 1.0 shows ONLY TOP.

The rest of the controls should be completely self explanatory, but feel free to drop off a question if you have ANY trouble with the shader.

If the question seems like an important one, I'll probably post the question here and answer it. So if you want your name left off - please let me know.

[PAUSE... unfinished post - will get back to it in a little bit] [Continue]

ok without further ado - here's the shader... ok ok, next post (I can't attach to this one)

post-2065-12587600420745_thumb.jpg

Share this post


Link to post
Share on other sites

Please bear in mind this is a rather complex shader - and I just finished it, so there may be problems with it. However, I have tested it heavily on my own. But, you never know, different OS, different versions of 3DC... etc.

Anyway, Please try exploring illegal values in the settings. It's cool because you can achieve effects that vary wildly within the same shader.

It's not a perfect monolithic shader like the MIA_X material, but it is an attempt to build a highly flexible shader for use in 3DC.

You can make materials from jade, translucent glass, to stone, to metals to plastics. All without even changing the 2 picmat images.

When you start changing the picmats, and the texture maps, the possibilities are vast.

The two picmats are diffuse and specular, although you can use whatever picmat you want, but the specular picmat has an exponent setting to choke the highlights down for lower contrast images.

You can also colorize the picmats using a single base color, which is also used for ambient lighting. There is a slider that goes from -1 to 1 for colorizing each. While a value of 1... well colorizes the picmat completely using the base color.a value of -1 does the same, but inverts the base color's effect. This can be used to create a nice complimentary coloring scheme. Warm hot spots of light, and a cool diffuse ambient lighting. or similar.

There are 3 texture maps that are projected along each axis. Each of these images can be scaled (again you may need to enter values above the maximum of 100, if you want to span large voxel models, I just have no way to expand the slider beyond 100) these can also be offset from 0.0 to 1.0. where 0.5 means offset by half the image... in other words, the scaling units are in voxel units, and the offset is relative to the image coordinates (u, v)

Finally there is also a group of settings that affect the way selections and freezeing is displayed...

...OK I just worked out a bug that fixed it so now Specular highlights show even if the shader is transparent! (like reflections should!... no back faces, but that's outside the scope of shaders in 3DC actually... I think)

:) I hope you all enjoy this shader - it is basically my vehicle to explore GPU shading, using HLSL and GLSL :) fun treat! Since I'm going to call this "beta", please let me know if you have any problems with it. It runs just fine on my machine - but I'm not with CUDA, or mac or linux. I'm on Windows XP x64 and don't have another way of checking. thanks for any constructive feedback.

I attached the shader, and then a few images to show how the pose-tool's selections can look...

With the selection set to Frz&Sel Object Opacity

(transparent freeze and selection) 1.0: post-2065-12603839825446_thumb.jpg

With the selection set to Frz&Sel Solid or Rainbow - at 0.0

(solid color selection, freeze ignores the color): post-2065-12603839813212_thumb.jpg

With the selection set to Frz&Sel Solid or Rainbow - at 1.0

(rainbow color selection, freeze ignores the color): post-2065-12603839987764_thumb.jpg

Here's sorta what the shader looks like - although it can look like a great many more things than this

(NOTE THIS IS ONLY ONE SINGLE SHADER WITH DIFFERENT SETTNIGS, NOT COPIED OR DUPLICATED IN ANY WAY!!!):

post-2065-12603839969447_thumb.jpg

2009.12.06 -----------------------------------

Name: SN_BETA_SUPERSHADER:

SN_Beta_SUPERSHADER.zip removed due to bug...

see below for SN_Beta2_SUPERSHADER.zip - updated

Material: Advanced Dual PicMat Material

Surface: it's Comlicated :D

Color: Whatever you want it to be...

Compatibility: GL and DirectX

1 person likes this

Share this post


Link to post
Share on other sites

I've run into some odd problems with both the SM_Utility and SM_SUPERSHADER under Mac. Both seem to have rendering problems where the object's voxels wind up transformed almost entirely off-screen, where the SM_Bronze shader appears to render the voxels in the expected location. I've included a screenshot of what happens with the SM_Bronze (good) and SM_Utility shader below (SM_SUPERSHADER has same visual outcome as SM_Utility shader).

post-899-12603989779625_thumb.png

post-899-12603989934599_thumb.png

Share this post


Link to post
Share on other sites

I've run into some odd problems with both the SM_Utility and SM_SUPERSHADER under Mac. Both seem to have rendering problems where the object's voxels wind up transformed almost entirely off-screen, where the SM_Bronze shader appears to render the voxels in the expected location. I've included a screenshot of what happens with the SM_Bronze (good) and SM_Utility shader below (SM_SUPERSHADER has same visual outcome as SM_Utility shader).

interesting... I dont' have a way to test on the mac... is it open GL version then?

sorry to hear that it doesn't work on mac. I can't test it easily on mac.. but I have asked for assistance to try and resolve this issue. If anyone has this problem on mac also, or linux or pc, please let me know.

It's possible, because I don't actually know what version of the GLSL spec is the lowest supported by 3DC.

So it's possible since the shader was written to support GLSL Spec 1.40, if your graphics card only supports 1.2 - maybe that is the culprit.

I will look into this more, but it would be of great help to know all the pertinent info of your system... OS version, graphics card, etc. version of 3DC you're using.

this shader is only tested on 3.1.18 Non-CUDA, GL and DX

thanks

immediately after starting up 3DC, when start splash (what do you want to do dialog) comes up... press CTRL + ~ (probably command + ~ on mac? ) to bring up the 3DC Log File... copy and paste the following information about your graphics card - thanks.

this is an example - (mine, when running the GL version)

------------------------------------------------------------

Graphics card and driver info

------------------------------------------------------------

OpenGL Renderer

Vendor: NVIDIA Corporation

Renderer: Quadro FX 3450/4000 SDI/PCI/SSE2

OpenGL Version: 2.1.2

Supported:

Pixel format

Multisample

Multitexture (units: 4)

Anisotropic filtering (level: 16)

Texture Compression

Stencil two side (Multivendor)

Vertex Buffer Object

Vertex Attributes (count: 16)

OpenGL Shading Language

Frame Buffer Object (max size: 4096 X 4096)

MRT (targets: 4)

Float texture

Non power of two

[EDIT] Thanks to Akira, all my speculation above - well... never mind.

Share this post


Link to post
Share on other sites

interesting... I dont' have a way to test on the mac... is it open GL version then?

sorry to hear that it doesn't work on mac. I can't test it easily on mac.. but I have asked for assistance to try and resolve this issue. If anyone has this problem on mac also, or linux or pc, please let me know.

It's possible, because I don't actually know what version of the GLSL spec is the lowest supported by 3DC.

So it's possible since the shader was written to support GLSL Spec 1.40, if your graphics card only supports 1.2 - maybe that is the culprit.

I will look into this more, but it would be of great help to know all the pertinent info of your system... OS version, graphics card, etc. version of 3DC you're using.

this shader is only tested on 3.1.18 Non-CUDA, GL and DX

thanks

immediately after starting up 3DC, when start splash (what do you want to do dialog) comes up... press CTRL + ~ (probably command + ~ on mac? ) to bring up the 3DC Log File... copy and paste the following information about your graphics card - thanks.

this is an example - (mine, when running the GL version)

------------------------------------------------------------

Graphics card and driver info

------------------------------------------------------------

OpenGL Renderer

Vendor: NVIDIA Corporation

Renderer: Quadro FX 3450/4000 SDI/PCI/SSE2

OpenGL Version: 2.1.2

Supported:

Pixel format

Multisample

Multitexture (units: 4)

Anisotropic filtering (level: 16)

Texture Compression

Stencil two side (Multivendor)

Vertex Buffer Object

Vertex Attributes (count: 16)

OpenGL Shading Language

Frame Buffer Object (max size: 4096 X 4096)

MRT (targets: 4)

Float texture

Non power of two

There are some errors when compiling the shaders with my ATI 3870 in GL mode, you need to fix these lines in the shader code:

[sN_Utility_Voxel_Grid]

mcubes.glsl:

line 41:

original

C = pow(C, LineSharpness);

corrected

C = pow(C, vec4(LineSharpness));

[sN_Beta_SUPERSHADER]

mcubes.glsl:

line 424:

original:

kDiff = multi_blender(kDiff, kDiff * lerp( 1.0 ,kProjX, kProjX.w ) * vec4(2.0), kProjX, BlendProjection ) ;

corrected:

kDiff = multi_blender(kDiff, kDiff * lerp( vec4(1.0) ,kProjX, kProjX.w ) * vec4(2.0), kProjX, BlendProjection ) ;

line 429:

original:

vec4 cSpecular = pow(kSpec, SpecPower) * SpecStrength * lerp(vec4(1.0), nrmBaseColor, ColorizeSpec);

corrected:

vec4 cSpecular = pow(kSpec, vec4(SpecPower)) * SpecStrength * lerp(vec4(1.0), nrmBaseColor, ColorizeSpec);

everything works fine after this correction, hope this helps.

akira.

1 person likes this

Share this post


Link to post
Share on other sites

NICE! thanks Akira...EXCELLENT :) I guess that's an nVidia vs ATI thing... nVidia spec says pow will affect component-wise if you use float on float3 or 4... I guess ATI doesn't. I will be careful not to take that for granted! :D

I will fix this ASAP, and hopefully it will fix it for anyone who has ATI card.

thanks Akira!

Share this post


Link to post
Share on other sites

Great work over shaders! Really worth to be included in distributive.

I will fix the issue that you have sent me by e-mail soon.

Share this post


Link to post
Share on other sites

Great work over shaders! Really worth to be included in distributive.

I will fix the issue that you have sent me by e-mail soon.

Thanks :)

Here is the fixed Shader... hopefully it takes care of the problem that was reported on mac (but probably is due to ATI graphics)

SN_Beta2_SUPERSHADER.zip

fixed a bug! (fixed some bugz... see below)

Share this post


Link to post
Share on other sites

Hello cakeller,

I just want to say thanks. While I have not yet tested your shader it looks very useful indeed!

Share this post


Link to post
Share on other sites

cakeller,

I might be missing something, but I keep noticing you're using the lerp() function in the GLSL version of the fragment program. While I believe Nvidia just invisibly translates lerp() to mix(), technically there is no lerp() function in GLSL, the proper function you want is mix(). The ATI 4870 OSX drivers do not appear to invisibly translate lerp() to mix(). Another problem is that you use trunc(), which is only supported in the most recent releases of GLSL (and not those provided by ATI on Mac, as far as I can tell).

Replacing all instances of lerp() with mix(), and trunc() with floor() appears to get both the SM_Utility and SM_SUPERSHADER shaders to work as expected on my Mac (MacPro running 10.6.2) and ATI card (Apple ATI 4870).

Share this post


Link to post
Share on other sites

cakeller,

I might be missing something, but I keep noticing you're using the lerp() function in the GLSL version of the fragment program. While I believe Nvidia just invisibly translates lerp() to mix(), technically there is no lerp() function in GLSL, the proper function you want is mix(). The ATI 4870 OSX drivers do not appear to invisibly translate lerp() to mix(). Another problem is that you use trunc(), which is only supported in the most recent releases of GLSL (and not those provided by ATI on Mac, as far as I can tell).

Replacing all instances of lerp() with mix(), and trunc() with floor() appears to get both the SM_Utility and SM_SUPERSHADER shaders to work as expected on my Mac (MacPro running 10.6.2) and ATI card (Apple ATI 4870).

lerp was used because most of the GLSL shaders in 3DC use it ... but I did know it was not a GLSL thing...

you're right - prolly better to stick to using mix (unless Akira, or Andrew had a reason for using lerp ?)

as for the trunc... it's a very different function than floor - however, you're totally right, floor is what I intended - good catch. but you have to remove the sign() function before it, or you'll end up with mirroring, I thinkg, which was something I tested a while ago.

XPlanarUV -= XPlanarUV - ( sign(XPlanarUV) * trunc(XPlanarUV) ); // <== dumb :) not -1.25 - ( -1 * -1 ) which is - 2.25 ??? what was I thinking :) thanks for catching that.

XPlanarUV = XPlanarUV - floor(XPlanarUV); (-1.25) - ( -2.0 ) which is 0.75, which is precisely the coordinate I wanted,

XPlanarUV = XPlanarUV - ( sign(XPlanarUV) * floor(XPlanarUV) ) ; (-1.25) - ( -1 * -2.0 ) which is -3.25, which is again, NOT the coord I wante. but then as long as the UVs are accepted as toroidal, then it would still give the correct coordinate. but so would the original term of -1.25... how wasteful would that be ;)

anyway.. thanks to JWiede and Akira for your help on this - I've retested it - and it seems to be fine now.

------ YAY! I just found a WIERD bug - that showed up when messing with this that caused the Z Porjection to dissappear when shadows are OFF?!? which is REALLY nutty, because it happened to be that an abs( blah blah blah (and some blah ) * 2.0 / PI; doesn't work when SHADOWS are defined?! hehe... wierd. cuz it works in HLSL just find, and ... well... whatever an extra set of parentheses fixed it... :)

Share this post


Link to post
Share on other sites

2009.11.10 -----------------------------------

Name: SN_Utility_Voxel_Grid:

post-2065-12578869353149_thumb.jpg

Note that from left to right is the same model with clone and degrade, once in the middle model, and twice in the right model.

The bronze model behind them, shows the relative detail levels.

Material: Utility

Surface: surface is derived from XYZ position in actual voxel grid.

Color: Red is X voxel grid lines, Green is Y, and Blue is Z

Compatibility: ONLY GL version*

Download Shader Here

[/color]

Update! - 2009.12.11 -----------------------------------

Material: Utility (Shows grid over voxels)

Surface: surface color is derived from XYZ position in actual voxel grid.

Color: Red is X voxel grid lines, Green is Y, and Blue is Z

Compatibility: GL and DX

Share this post


Link to post
Share on other sites

Please bear in mind this is a rather complex shader - and I just finished it, so there may be problems with it.

2009.12.06 -----------------------------------

Name: SN_BETA_SUPERSHADER:

SN_Beta_SUPERSHADER.zip removed due to bug...

see below for SN_Beta2_SUPERSHADER.zip - updated

Material: Advanced Dual PicMat Material

Surface: it's Comlicated :D

Color: Whatever you want it to be...

Compatibility: GL and DirectX

Please bear in mind this is a rather complex shader - and I just finished it, and finished it, and finished it ... ;)

Updated! 2009.12.11 -----------------------------------

Name: SN_BETA_SUPERSHADER:

SN_Beta4_SUPERSHADER.zip

Material: Advanced Dual PicMat Material

Surface: it's Comlicated :D

Color: Whatever you want it to be...

Compatibility: GL and DirectX

------ Included in 3D Coat Distro - for a long time now. No need to d/l

Share this post


Link to post
Share on other sites

-----------------------------------

NEW VERSION with more controls!

Update! - 2009.12.12

-----------------------------------

Material: Gridding Utility

Surface: Color relates to Voxel Grid Spacing

Color: Grid color is Black, or White, or Colored.

if Grid is colored,

Red is X grid lines

Green is Y, and

Blue is Z

Grid Background is Black, unless grid is white, then backgroudn is white.

Compatibility: ANY

SN_Utility_Voxel_Grid_V2.zip

//////////////////////////////////////////////

Controls:

//////////////////////////////////////////////

Spacing (x, y, and z):

Range: 0.0 to 10.0

Notes:

values greater than 10.0 ok by manual entry

values of 0.0 or lower turn off specific grid-line

Sharpness (Exponent):

Range: 0.0 to 100.0

Notes:

higher values produce thinner grid lines.

Grid Brightness:

Range: 0.0 to 1.0:

Notes:

value of 0.0 = black grid lines

value of 0.5 = r g b grid lines

value of 1.0 = white grid lines

other values blend between options

values out of range produce other colored effects but must be entered manually.

-1.0 inverts color of grid lines - with white background

1.25 has pastel colored lines - with black background

1.5 looks more like neon with inverted colors and white glowing centerline.

! with negative values and high shading values AND low exponent ( < 1.0 ) the background will take on inverted color

VERY HOT!! look at green and purple topographic image below.

Backgroudn Opacity:

Range: -1.0 to 1.0

value of -1 is completely transparent, grid and background

value of 0 is transparent background of grid (grid holes)

value of 1 is completely opaque.

values above 1.0 and below -1.0 are accepted but are simply clamped at 1.0 and -1.0 respectively.

Shading:

Range: 0.0 to 1.0

value of 0 is flat-no shading.

value of 1 has almost black at at the sillouhette.

values above 1.0 cause much more sever shading and blooming of the grid-lines.

values below 0.0 invert the effect and make the sillouette more glowy.

some combinations of Shading with Grid Brightness can be supprising - :) definitely worth experimenting.

//////////////////////////////////////////////

see attached picture samples...

post-2065-12606689396462_thumb.jpg

post-2065-12606689417505_thumb.jpg

post-2065-12606689434089_thumb.jpg

post-2065-12606689447034_thumb.jpg

post-2065-12606689462038_thumb.jpg

post-2065-12606689473625_thumb.jpg

post-2065-12606689487193_thumb.jpg

1 person likes this

Share this post


Link to post
Share on other sites

I am new in this field, just doing for my interest.

Thanks for sharing shaders.

Your SN_Metal_Bronze_Brushed technique is really good.

I will need your help in future also.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now