Jump to content
3DCoat Forums

Shaders


Andrew Shpagin
 Share

Recommended Posts

  • Advanced Member

Yay I'm the 1st one to reply. :lol:

Thank you ALL guyz, so glad that you like the shaders I made. They look much better applying on your perfect sculptings than just on the default sphere.

So I improved the PicMat_Skin_Shadow shaders and added another PicMat Pewter shader to test cavity.

Again the GL version of PicMat_Pewter_Shadow is buggy, depth buffer stop updating again LOL, I'll leave it for Andrew. ;)

regards,

akira

p.s. the original pewter shader is made for ZB by Simon.C, you can find it in this thread:

http://www.zbrushcentral.com/zbc/showthread.php?t=46175

post-751-1223316010_thumb.jpg

post-751-1223316029_thumb.jpg

PicMatShaders_002.rar

Link to comment
Share on other sites

Thank you! I have made some changes in upcoming update so that there is no need to make several copies of the same shader with/without shadow.

I will upload it soon but main idea is that define will be used. There is an example:

// Vertex shader

float4x4 g_WorldViewProjectionMatrix;
float3 g_ViewerPos;
float4 Sphere;
float4x4 ShadowTM;

struct VS_INPUT {
	float3 Pos	   : POSITION;
	float3 Normal	: TEXCOORD0;
};

struct VS_OUTPUT {
	float4 Pos  : POSITION;	
	float3 N	: TEXCOORD1;
#ifdef SHADOWS
	float3 SPos : TEXCOORD2;
#endif
};

VS_OUTPUT main(const VS_INPUT In) {
	VS_OUTPUT Out;
	float4 P = float4(In.Pos, 1.0);
	Out.Pos = mul(P, g_WorldViewProjectionMatrix);
	Out.N = In.Normal;
#ifdef SHADOWS
	Out.SPos = mul(P, ShadowTM);
	Out.SPos.xy += float2(1.0/4096.0f,1.0/4096.0);
#endif
	return Out;
}

// Pixel shader

struct VS_OUTPUT {
	float4 Pos  : POSITION;
	float3 N	: TEXCOORD1;
#ifdef SHADOWS
	float3 SPos : TEXCOORD2;
#endif
};

sampler ShadowSampler;

float4 Color;
float4 CurrColor;
float3 LDir;
float LDiffuse;
float LAmbient;
float ShadowMin;


float4 main( const VS_OUTPUT v ) : COLOR {
	float mpl=1.0;
#ifdef SHADOWS
	float3 m=tex2D(ShadowSampler,v.SPos).xyz;	
	float3 d=float3(1.0,1.0/255.0,1.0/255.0/255.0);
	mpl=clamp(2.0-(v.SPos.z-dot(m,d))*120,ShadowMin,1);
#endif
	float3 N=normalize(v.N);
#ifdef AOPASS
	float  D = LAmbient-LDiffuse*dot(N,LDir)*mpl;
#else
	float  D = -LDiffuse*dot(N,LDir)*mpl;	
#endif
	float4 C=CurrColor*D;
	C.w=1;
	return C;		
}

defines meaning:

SHADOWS - used when shader is used for shadow casting

AOPASS - used to calculate AO in render feature. In this cash it is better to modulate overall color on shadow to get black color on shadowed parts.

Link to comment
Share on other sites

  • Advanced Member

I was playing with the new mudbox, and they have added a great new feature that was really lacking in zbrush.

Now you have different lighting preset, so you can see your object lit in different angle.

Is it possible to have this kind of thing?

I think it's really important.

Link to comment
Share on other sites

I was playing with the new mudbox, and they have added a great new feature that was really lacking in zbrush.

Now you have different lighting preset, so you can see your object lit in different angle.

Is it possible to have this kind of thing?

I think it's really important.

Do you mean light direction presets?

Link to comment
Share on other sites

  • Advanced Member
Thank you! I have made some changes in upcoming update so that there is no need to make several copies of the same shader with/without shadow.

I will upload it soon but main idea is that define will be used. There is an example:

defines meaning:

SHADOWS - used when shader is used for shadow casting

AOPASS - used to calculate AO in render feature. In this cash it is better to modulate overall color on shadow to get black color on shadowed parts.

Cool! That will help a lot! :D

And I have a question about the linearity of the depth buffer, I saw you render depth buffer in mcubes_rt like:

Out.Pos = mul(P, g_WorldViewProjectionMatrix);
Out.pz = Out.Pos.z/2500;

In that transformation Out.pz will not be linear, because P.xyz is divided by P.w in g_WorldViewProjectionMatrix,

this final division that causes the non-linearity of transformed depth values.

http://www.mvps.org/directx/articles/linear_z/linearz.htm

This article suggested a simple solution:

float4 vPos = mul(Input.Pos,worldViewProj);
vPos.z = vPos.z * vPos.w / Far;
Output.Pos = vPos;

Or maybe you have already done it in g_WorldViewProjectionMatrix, I just want to make sure about this.

regards,

akira.

Link to comment
Share on other sites

  • Advanced Member
I was playing with the new mudbox, and they have added a great new feature that was really lacking in zbrush.

Now you have different lighting preset, so you can see your object lit in different angle.

Is it possible to have this kind of thing?

I think it's really important.

3DC always allows the rotation of light direction.

Or did you mean the PicMat Shaders?

I think it's possible by rendering different lighting setup on same shader balls and output them as separate textures,

then you can switch them to observe different lighting effects at run-time.

Link to comment
Share on other sites

  • Advanced Member
Actually depth buffer is linear. Non-linearity does not appears in vertex shader.

After exiting VS video card performs division (in rastrization module before pixel shader)

pos/=pos.w;

So in vertex shader all is linear and pos.z can be used as a linear depth.

I see, thank you for explaining about this. :)

Link to comment
Share on other sites

  • Advanced Member
I have uploaded V24. Shaders are placed in Shaders\Custom\

Defines SHADOWS and AOPASS work there.

Thank you for great work!

Awesome Andrew!! It's getting much better now!!

Just one thing, the "darkside check" in PicMat Shaders is supposed to work only when shadow is turned on. I'll correct them after clearing my regular work.

Thank you again for this early Monday updating. :lol:

Regards,

akira.

Link to comment
Share on other sites

  • Advanced Member

Several shader issues

I am unable to render on my PC. Im using a Dell XPS with a Nvidia 7950 GX2 graphics card 1 gig video ram. I should be able to render.

Also the shaders are still showing concentric circles on certain shaders like red wax.

Also the GL version will crash when attempting to render. The DX version you can see something happeing but the image disappears.

The concern im having is that 3d-coat seems to be becoming very Hardware specific and that is not cool in my opinion. Now I know this is an alpha but Im just expressing a concern especially since im a Mac user too and Cuda is being discussed and I have no idea if Cuda will work on the mac. 3d-coat need to be stable with a wide range of video cards and performance should not be platform specific.

Link to comment
Share on other sites

  • Advanced Member

@ Deadman

Im certain Andrew will optimize it to the max. However there is no escaping a faster pc (or mac) will make 3dcoat perform better. Thats just a fact of life.

With that said have you tried the recent "picmap" shaders? They are awesome to sculpt on and they are even faster then lambert while looking better! Im really loving this on my not so fast system. ;)

I also still have the circles on shaders like red wax and bronze. (nvidia Geforce 6800GT)

Before i forget:

"Just one thing, the "darkside check" in PicMat Shaders is supposed to work only when shadow is turned on. I'll correct them after clearing my regular work.

Thank you again for this early Monday updating."

Is this the reason i cant turn off shadows for the picmat materials? I dont find the shadows very beautifull (i realise its still a work in progress) and they kinda ruin the picmat materials now that i cant turn them of. :mellow:

3dioot

Ive been playing a little more. Its not that i cant turn shadows on and off. Its just that i get weird dark splodges along the edges of my models. Must be that darkside thing but just to remove all doubts.

post-949-1223417142_thumb.jpg

Link to comment
Share on other sites

  • Advanced Member
I also still have the circles on shaders like red wax and bronze. (nvidia Geforce 6800GT)

Before i forget:

"Just one thing, the "darkside check" in PicMat Shaders is supposed to work only when shadow is turned on. I'll correct them after clearing my regular work.

Thank you again for this early Monday updating."

Is this the reason i cant turn off shadows for the picmat materials? I dont find the shadows very beautifull (i realise its still a work in progress) and they kinda ruin the picmat materials now that i cant turn them of. :mellow:

Yup, we were talking about the same thing, it is a little problem that can be corrected by modifying the shader code, I'll correct them after finishing my job.

akira

BTW About the circles issue, I've tested this issue on Geforce 7-series and saw some circles too, but that's not my pc and I forgot to take a screenshot about that, could you post a screenshot for better discussion of this problem?

Link to comment
Share on other sites

I like the idea of the new checkbox for shadows, but I was sad to see that Soft Shadows for Lamblight is gone.

I wasn't personally a big fan of Red Wax before but I checked it out now and it is looking kind of ugly now. Here's a screenshot:

http://screencast.com/t/Nzsc6soa

It seems to be Cavity related as I can see the same effect on Bronze but not with Bronze no Cavity.

Link to comment
Share on other sites

  • Advanced Member

Time for updating shaders~

1. The darkside issue of PicMat shaders is fixed.

2. Gave back the cavity effect for PicMat Pewter.

3. Added a PicMat_RedWax shader for low powered graphics card users.

Usage:

Extract them into Shaders\Custom\ and overwrite old folders.

cheers,

akira.

@philnolan3d

Sorry about the ugly RedWax shader, but it's the best I can do for now. :)

And you can still get soft shadow from rendering, it looks much better than the real-time PCF soft shadow before.

PicMat_Shaders_Oct09.rar

post-751-1223483915_thumb.jpg

Link to comment
Share on other sites

  • Advanced Member

Thankyou very much for the fixed shaders. :)

Here is a screengrab of the rings problem like you requested. Its just like before; when you zoom in and out these rings grow and shrink over the model.

The graphics card im using is an Nvidia 6800GT

post-949-1223485789_thumb.jpg

3dioot

Link to comment
Share on other sites

  • Member
Thankyou very much for the fixed shaders. :)

Here is a screengrab of the rings problem like you requested. Its just like before; when you zoom in and out these rings grow and shrink over the model.

The graphics card im using is an Nvidia 6800GT

post-949-1223485789_thumb.jpg

3dioot

Same Video card and same effects here!

Btw VERY Nice shaders Akira.

Luca

Link to comment
Share on other sites

  • Advanced Member
Thank you 3dioot!

I think this ring issue is caused by some "jumping" of depth value, maybe hardware specific, I will try to figure it out.

And one more shader here - PicMat_Beeswax LOL

Have Fun!

akira.

I'm not sure if you take requests akira :lol: , but I'd love a bone shader like this:

http://www.zbrushcentral.com/zbc/showpost....mp;postcount=25

It's weird sculpting with skin!

Also, if it helps - I get this banding issue on cavity based shaders on my machine here (7800GTX) but my work machine (8800GT) doesn't have a problem.

Link to comment
Share on other sites

  • Advanced Member
I'm not sure if you take requests akira :lol: , but I'd love a bone shader like this:

http://www.zbrushcentral.com/zbc/showpost....mp;postcount=25

It's weird sculpting with skin!

Also, if it helps - I get this banding issue on cavity based shaders on my machine here (7800GTX) but my work machine (8800GT) doesn't have a problem.

It's very simple to DIY PicMat shaders, just replace the dds file with the one you like. :)

PicMat_ShinyOldSkull.rar

Link to comment
Share on other sites

  • Advanced Member

Can we have a sticky thread or where all the released and currently working shaders are posted? I miss AO and some others which didn't came with the last alpha and I think they are somewhere in that 56 pages thread...

Thanks,

mike

many thanks for the wealth of shaders Akira :)

Link to comment
Share on other sites

Thankyou very much for the fixed shaders. :)

Here is a screengrab of the rings problem like you requested. Its just like before; when you zoom in and out these rings grow and shrink over the model.

The graphics card im using is an Nvidia 6800GT

post-949-1223485789_thumb.jpg

3dioot

Does they move quickly or it seems like thay stay in space?

Link to comment
Share on other sites

  • Advanced Member

They only move when you zoom in/out or rotate. They are static when you dont move the camera.

When you zoom in and out its almost like your moving the model through the rings. They keep growing/emerging like a never ending pattern.

Do you need a movie?

3dioot

Link to comment
Share on other sites

  • Advanced Member
They only move when you zoom in/out or rotate. They are static when you dont move the camera.

When you zoom in and out its almost like your moving the model through the rings. They keep growing/emerging like a never ending pattern.

Do you need a movie?

3dioot

Problem solved. :)

It was in mcubes_rt.hlsl like:

int i =(int)(Depth * 255.0);

When compiling for Geforce 6 and 7 series cards, it becomes:

int i =ceil(Depth * 255.0);

That causes this issue. So I replaced all "(int)" with "floor"(already done in glsl code) then the problem was gone.

akira.

usage:

Extract the attached file into Shaders folder to replace the old one.

mcubes_rt.rar

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...