CGTalk > Software > Autodesk 3ds max
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 04-19-2013, 10:57 PM   #1
Chipicao
New Member
portfolio
Romania
 
Join Date: Mar 2013
Posts: 12
DirectX 11 shader render order

I'm working on a custom DirectX 11 shader for Nitrous in max2014 and I have an issue in Shaded mode:


EDIT: never mind I just had to set the DepthStencilState

But now I'm having transparency issues... Does anybody know how to set a BlendState properly?

Last edited by Chipicao : 04-20-2013 at 12:54 AM.
 
Old 06-28-2013, 01:56 PM   #2
nico33
New Member
nico
Technical Artist
France
 
Join Date: Feb 2006
Posts: 3
Angry

Hello,

Directx 11 material is completely bugged for me in 2014. Setting a custom blendState give unpredictable results. It even make other objects with standard materials bugs !

Here an example of a custom blendstate with blend disabled. Normally changing the alpha shouldn't change anything here, but that not the case. And applying it to an object make other objects (without materials) lighter and transparent to the grid !

Code:
string ParamID = "0x0003"; float4x4 WvpXf : WorldViewProjection < string UIWidget="None"; >; float alpha < string UIName = "alpha"; > = 0.5; struct appdata { float4 Position : POSITION; }; float4 std_VS(appdata IN) : SV_Position { return mul(float4(IN.Position.xyz,1), WvpXf);; } float4 std_PS() : SV_Target { return float4(1,0,0,alpha); } BlendState noBlend { BlendEnable[0] = false; }; technique11 NoBlend { pass p0 { SetBlendState(noBlend, float4(1,1,1,1), 0xffffffff); SetVertexShader(CompileShader(vs_5_0,std_VS())); SetPixelShader(CompileShader(ps_5_0,std_PS())); } }


If i try the default 'StandardFX11.fx' shader provided by autodesk, it doesn't work too. In shaded mode it render like there were no z buffer (objects pop in front of each other without intersection), and in realistic mode the transparency simply doesn't work. Setting a custom blendstate does not help.
 
Old 07-05-2013, 02:15 PM   #3
Chipicao
New Member
portfolio
Romania
 
Join Date: Mar 2013
Posts: 12
Quote:
Originally Posted by nico33
Hello,

Directx 11 material is completely bugged for me in 2014. Setting a custom blendState give unpredictable results. It even make other objects with standard materials bugs !

Here an example of a custom blendstate with blend disabled. Normally changing the alpha shouldn't change anything here, but that not the case. And applying it to an object make other objects (without materials) lighter and transparent to the grid !
I think that's because you're supposed to enable it, not disable. If I set BlendEnable[0] to false I get the same problem you describe.
Try this instead:

Code:
BlendState AlphaBlend { //AlphaToCoverageEnable = TRUE; //acts as an Alpha Test, clipping pixels with alpha<0.5 //IndependentBlendEnable = TRUE; //no worky BlendEnable[0] = TRUE; SrcBlend = SRC_ALPHA; DestBlend = INV_SRC_ALPHA; BlendOp = ADD; SrcBlendAlpha = ZERO; DestBlendAlpha = ZERO; BlendOpAlpha = ADD; RenderTargetWriteMask[0] = 0x0F; };




Quote:
Originally Posted by nico33
If i try the default 'StandardFX11.fx' shader provided by autodesk, it doesn't work too. In shaded mode it render like there were no z buffer (objects pop in front of each other without intersection), and in realistic mode the transparency simply doesn't work. Setting a custom blendstate does not help.
Yes, even the DX11 shader "bundled" with max is broken. You have to set the depth state:
Code:
DepthStencilState DepthOn { DepthEnable = TRUE; DepthWriteMask = ALL; DepthFunc = LESS; //default //StencilEnable = TRUE; //FrontFace = KEEP; };
And use this in your pass: SetDepthStencilState( DepthOn, 0 );


The only problem I still have is that objects behind transparent materials tend to disappear depending on the camera angle.
 
Old 07-08-2013, 12:25 PM   #4
nico33
New Member
nico
Technical Artist
France
 
Join Date: Feb 2006
Posts: 3
Hello Chipicao,

Thanks for your answer.

About blendstate, sure i can enable it an make sure the pixel shader output is always one. That ok.

For the depth, i had to use "Less_Equal" instead of "Less", if not the object would disappear in "realistic mode".

For transparent materials it is normal that objects pop in front of each other depending on camera angle/distance (in shaded mode), because it depend on the rendering order. We often deactivate depth write when rendering transparent objects.

What is strange is that i get black instead of background color if using zero for SrcBlendAlpha and DestBlendAlpha. Using SrcBlendAlpha = zero and DestBlendAlpha = INV_SRC_ALPHA seems to work.

Code:
BlendEnable[0] = TRUE; SrcBlend = SRC_ALPHA; DestBlend = INV_SRC_ALPHA; BlendOp = ADD; SrcBlendAlpha = ZERO; DestBlendAlpha = INV_SRC_ALPHA; BlendOpAlpha = ADD; RenderTargetWriteMask[0] = 0x0F;


Still all other objects not using a directx material are broken when using one directx material with SetBlendState and/or SetDepthStencilState.
 
Old 07-08-2013, 12:25 PM   #5
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,480
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 10:21 AM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.