Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,493 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Hide certain pixels #236882
11/17/08 00:10
11/17/08 00:10
Joined: Aug 2006
Posts: 155
R
RyuMaster Offline OP
Member
RyuMaster  Offline OP
Member
R

Joined: Aug 2006
Posts: 155
Hi! I need to write one tricky shader.
I hope, it is enough to set vertex alpha to zero to hide it from render, but I do not know how to get access to certain vertexes.

For instance, I have plane parallel to X axis. Using C-Lite, I can get exact part of model which needs to be cut:

Quote:
if (divide_plane.x > object.x)
{
if ((divide_plane.x - object.x) > object.max_x)
/// Does not matter, cutter plane is outside objects
else
trace_for_divider = (you.x - me.x);//Now this matters, we get X amount of object which needs to be cut
}
else
{
same vise versa
}


So, trace_for_divider will hold number, and if this number is, lets say, 2, then all vertexes, lying further away then 2 on X axis (relevant to local object coordinates, its origin), needs to be hide.

What I do not know, is hot to transfer this affect_only_vertexes_which_position_is_more_then_2_on_X_axis_local_object_coordinates to HLSL ?


What kills me not, that makes me stronger.

***Working on RPG/RTS***
Re: Hide certain pixels [Re: RyuMaster] #237188
11/18/08 20:10
11/18/08 20:10
Joined: Aug 2006
Posts: 155
R
RyuMaster Offline OP
Member
RyuMaster  Offline OP
Member
R

Joined: Aug 2006
Posts: 155
On one of the DirectX forums, I have got this message:

Quote:

Which version of Direct3D are you using? Prior to D3D 10.0 you can't modify the number of vertices/primitives via HLSL - the Geometry Shader is required to add or remove actual geometry.

That said, if you're using D3D9 you can output the threshold value to a TEXCOORD (so its interpolated correctly) and then use clip() in the pixel shader. It's not necessarily the most efficient operation but it should do what you want.

Alternatively, if you're using D3D 10.0, 10.1 or 11.0 you can move your computation to the GS unit and simply control the emit() statements. You can bypass the VS if you're using this to eliminate extra processing, but be careful as this may not speed things up.

Quote:
And how to determine, which are on the right side of X (or Y, Z) axis? Or something like that?

At a syntax level you'll often go off the sign of the input so a simple inequality will do the trick. If you want to deal with planes (D3DPLANE in your app) you can pack all the coefficients into a single HLSL register and do a dot() (with w=1) to evaluate which side a point is...


Maybe this will help a bit...


What kills me not, that makes me stronger.

***Working on RPG/RTS***
Re: Hide certain pixels [Re: RyuMaster] #237198
11/18/08 21:02
11/18/08 21:02
Joined: Dec 2000
Posts: 4,608
mk_1 Offline

Expert
mk_1  Offline

Expert

Joined: Dec 2000
Posts: 4,608
You can "kill" pixels (see hlsl intrinsic functions)


Follow me on twitter
Re: Hide certain pixels [Re: mk_1] #237205
11/18/08 22:02
11/18/08 22:02
Joined: Aug 2006
Posts: 155
R
RyuMaster Offline OP
Member
RyuMaster  Offline OP
Member
R

Joined: Aug 2006
Posts: 155
Thanks! I found out, that "clip" function does it in pixel shader. But on what stage/level I should use it? Where I can actually process model to kill certain pixels I need...


What kills me not, that makes me stronger.

***Working on RPG/RTS***

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1