Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Ayumi), 1,405 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Vertex shader question #56681
10/01/05 14:59
10/01/05 14:59
Joined: Mar 2005
Posts: 80
S
SirSven Offline OP
Junior Member
SirSven  Offline OP
Junior Member
S

Joined: Mar 2005
Posts: 80
Is it possible to make a shader (i think vertex shader is needed - but i'm a shader noob) which turns all vertices of an modell to the camera? Like an sprite with facing=on and oriented=off but for every vertex of a modell.

Thanks

Last edited by SirSven; 10/01/05 14:59.
Re: Vertex shader question [Re: SirSven] #56682
10/03/05 18:17
10/03/05 18:17
Joined: Aug 2002
Posts: 44
Panama City, FL
S
Specterdragon Offline
Newbie
Specterdragon  Offline
Newbie
S

Joined: Aug 2002
Posts: 44
Panama City, FL
If I'm understanding you correctly, you're trying to flatten the model into a plane and then have that plane facing the camera? If so, does the model recalculate and reflatten itself on every frame, or once flattened does this fixed image face the camera?

Depending on your aplication, you may or may not need a vertex shader vs. a different model. Any chance of getting a more in-depth explination of the effect you're trying to achieve?


Just thinking out loud, Specterdragon
Re: Vertex shader question [Re: Specterdragon] #56683
10/04/05 16:57
10/04/05 16:57
Joined: Mar 2005
Posts: 80
S
SirSven Offline OP
Junior Member
SirSven  Offline OP
Junior Member
S

Joined: Mar 2005
Posts: 80
I mean it this way:
http://www.directupload.net/show/d/475/36peoRzZ.jpg#

I have a model with 4 (unconectet) vertices and i would like every vertex to turn to the camera.

Re: Vertex shader question [Re: SirSven] #56684
10/05/05 11:00
10/05/05 11:00
Joined: May 2003
Posts: 609
Rattenfängerstadt
Rigoletto Offline
Developer
Rigoletto  Offline
Developer

Joined: May 2003
Posts: 609
Rattenfängerstadt
That could be the solution:

web page

Re: Vertex shader question [Re: Rigoletto] #56685
10/05/05 11:58
10/05/05 11:58
Joined: Mar 2005
Posts: 80
S
SirSven Offline OP
Junior Member
SirSven  Offline OP
Junior Member
S

Joined: Mar 2005
Posts: 80
Thank you, but I'm so bad in shader programming (shame on me). I can't get it work. If tried Rhuarc's code, but I get errors. Maybe someone can have a look at this code.

Code:
DELETED -> IT WAS DAMN BAD, SORRY



Last edited by SirSven; 10/05/05 17:45.
Re: Vertex shader question [Re: SirSven] #56686
10/05/05 16:40
10/05/05 16:40
Joined: May 2003
Posts: 609
Rattenfängerstadt
Rigoletto Offline
Developer
Rigoletto  Offline
Developer

Joined: May 2003
Posts: 609
Rattenfängerstadt
Well, there are a lot of mistakes. Take a look at the wiki tutorials and make a second try. If there a still errors post again.

Re: Vertex shader question [Re: Rigoletto] #56687
10/05/05 17:41
10/05/05 17:41
Joined: Mar 2005
Posts: 80
S
SirSven Offline OP
Junior Member
SirSven  Offline OP
Junior Member
S

Joined: Mar 2005
Posts: 80
Thanks Rigoletto (you must excuse because thats the first shader I'm triing to program and it's very hard to learn with my bad english )

So here is my 2nd try

Code:
 material material_test
{
effect
"
float4x4 matWorldViewProj;
texture entSkin1;

sampler ScreenProjSampler = sampler_state
{
texture = <entSkin1>;
magfilter = LINEAR;
minfilter = LINEAR;
mipfilter = LINEAR;
};

float3 mainVS(float4 Pos : POSITION0) : TEXCOORD0
{
float4 toScreen = mul(float4(Pos.xyz,1),matWorldViewProj);
float3 tex0;
tex0.x = 0.5f * (toScreen.z+toScreen.x);
tex0.y = 0.5f * (toScreen.z-toScreen.y);
tex0.z = 1.0f * toScreen.w;

return tex0;
}

float4 mainPS(float3 tex0 : TEXCOORD0) : COLOR0
{
float2 screenCoords;
screenCoords.x = tex0.x/tex0.z;
screenCoords.y = tex0.y/tex0.z;
float4 ScreenSpaceSample = tex2D(ScreenProjSampler,screenCoords.xy);

return ScreenSpaceSample;
}

technique test
{
pass p0
{
VertexShader = compile vs_2_0 mainVS();
PixelShader = compile ps_2_0 mainPS();
}

}
";
}



Now I get an error with the position in the vs and i can't understand why.


Last edited by SirSven; 10/05/05 17:49.
Re: Vertex shader question [Re: SirSven] #56688
10/05/05 17:54
10/05/05 17:54
Joined: Mar 2001
Posts: 3,298
Beverly, Massachusetts
Rhuarc Offline
Expert
Rhuarc  Offline
Expert

Joined: Mar 2001
Posts: 3,298
Beverly, Massachusetts
Quote:

Thanks Rigoletto (you must excuse because thats the first shader I'm triing to program and it's very hard to learn with my bad english )

So here is my 2nd try

<code omitted>

Now I get an error with the position in the vs and i can't understand why.





You need to do just that, write out the position coordinates.

Code:
 material material_test
{
effect
"
float4x4 matWorldViewProj;
texture entSkin1;

sampler ScreenProjSampler = sampler_state
{
texture = <entSkin1>;
magfilter = LINEAR;
minfilter = LINEAR;
mipfilter = LINEAR;
};

struct VS_OUT
{
float4 pos : POSITION;
float3 tex0 : TEXCOORD0;
};

VS_OUT mainVS(float4 Pos : POSITION0)
{
VS_OUT outStruct;
outStruct.pos = mul(Pos,matWorldViewProj);
float4 toScreen = mul(float4(Pos.xyz,1),matWorldViewProj);
outStruct.tex0.x = 0.5f * (toScreen.z+toScreen.x);
outStruct.tex0.y = 0.5f * (toScreen.z-toScreen.y);
outStruct.tex0.z = 1.0f * toScreen.w;

return outStruct;
}

float4 mainPS(float3 tex0 : TEXCOORD0) : COLOR0
{
float2 screenCoords;
screenCoords.x = tex0.x/tex0.z;
screenCoords.y = tex0.y/tex0.z;
float4 ScreenSpaceSample = tex2D(ScreenProjSampler,screenCoords.xy);

return ScreenSpaceSample;
}

technique test
{
pass p0
{
VertexShader = compile vs_2_0 mainVS();
PixelShader = compile ps_2_0 mainPS();
}

}
";
}



This shader however, transforms the texture to be displayed flat on a 3d object, not flatten out the polys of a 3d object (alike to a sprite) and face it to the camera, that would be a bit different.

-Rhuarc


I no longer post on these forums, keep in touch with me via:
Linkedin.com
My MSDN blog
Re: Vertex shader question [Re: Rhuarc] #56689
10/05/05 18:28
10/05/05 18:28
Joined: Mar 2005
Posts: 80
S
SirSven Offline OP
Junior Member
SirSven  Offline OP
Junior Member
S

Joined: Mar 2005
Posts: 80
Thank you Rhuarc

Now it works without errors, but I just see a black object!

Last edited by SirSven; 10/05/05 18:28.
Re: Vertex shader question [Re: SirSven] #56690
10/05/05 18:35
10/05/05 18:35
Joined: May 2003
Posts: 609
Rattenfängerstadt
Rigoletto Offline
Developer
Rigoletto  Offline
Developer

Joined: May 2003
Posts: 609
Rattenfängerstadt
I have make a short try to archive your desired effect in effectedit (DX9 SDK, good for fast testing). It is easy possible to flat all vertex on ONE plane, but setting the z-coord gives sorting errors and looks bad. Manipulating the vertex in the way you want needs to know which vertex belongs together, and which is used as z-coord. I think this is nearly impossible!? Perhaps VS3.0...

Page 1 of 2 1 2

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