2 registered members (AndrewAMD, Quad),
843
guests, and 1
spider. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Sprites with multiple skins
#445244
09/01/14 13:09
09/01/14 13:09
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
OP
Expert
|
OP
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
Hey,
I'd like to know if it's possible to create sprites with multiple skins (I need this for normalmapping). I just tried using ent_setskin but had no success.
POTATO-MAN saves the day! - Random
|
|
|
Re: Sprites with multiple skins
[Re: Kartoffel]
#445272
09/02/14 07:09
09/02/14 07:09
|
Joined: Mar 2011
Posts: 3,150 Budapest
sivan
Expert
|
Expert
Joined: Mar 2011
Posts: 3,150
Budapest
|
I think no, sprites have some limitations I discussed with Jcl a while ago (I don't remember exactly, but it was related to my lightmapper, i.e. getting skin pixel data by c_tracing, and finally I needed to create temporary models out of sprites, and then remove them... the manual does not describe it exactly). maybe you can use a skin looking like of an animated sprite to read normal map from it. (by the way I do not use sprites any more.)
Last edited by sivan; 09/02/14 07:09.
|
|
|
Re: Sprites with multiple skins
[Re: sivan]
#445274
09/02/14 08:16
09/02/14 08:16
|
Joined: Jul 2007
Posts: 619 Turkey, Izmir
Emre
User
|
User
Joined: Jul 2007
Posts: 619
Turkey, Izmir
|
how about shader solution?
//from rendermonkey
float4 lightness = float4( 0.30, 0.59, 0.11, 0.00 );
float4 tex2DN_ATI(uniform sampler2D BaseMap,float2 texCoord,float res) : COLOR
{
float off = 1.0 / res;
float4 s00 = tex2D(BaseMap, texCoord + float2(-off, -off));
float4 s01 = tex2D(BaseMap, texCoord + float2( 0, -off));
float4 s02 = tex2D(BaseMap, texCoord + float2( off, -off));
float4 s10 = tex2D(BaseMap, texCoord + float2(-off, 0));
float4 s12 = tex2D(BaseMap, texCoord + float2( off, 0));
float4 s20 = tex2D(BaseMap, texCoord + float2(-off, off));
float4 s21 = tex2D(BaseMap, texCoord + float2( 0, off));
float4 s22 = tex2D(BaseMap, texCoord + float2( off, off));
float4 sobelX = s00 + 2 * s10 + s20 - s02 - 2 * s12 - s22;
float4 sobelY = s00 + 2 * s01 + s02 - s20 - 2 * s21 - s22;
float sx = dot(sobelX, lightness);
float sy = dot(sobelY, lightness);
float3 normal = normalize(float3(sx, sy, 1));
return float4(normal * 0.5 + 0.5, 1);
}
...
float4 normal=2*(tex2DN_ATI(sampler,coord,512)-0.5);
...
result is not very good but maybe you'd like to use anyway.
|
|
|
Re: Sprites with multiple skins
[Re: Emre]
#445277
09/02/14 10:02
09/02/14 10:02
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
OP
Expert
|
OP
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
not sure what it does? I guess you're generating a normalmap from the color data? I think I'm going with a workaround then, making the texture twice as wide (left colormap, right normalmap), applying 'scale_x = 0.5;' and using some little helperfunctions to sample the texture properly. (actually that's pretty much sivan's soluition :D) But thank you for your suggestions. Edit: the function would be something like this:
const static float num_skins_total = 2.0;
const static float4 border_color = { 0.0, 0.0, 0.0, 0.0 };
float4 tex2D_multitex(sampler2D smp, float2 tex, float skin_num)
{
// address modes:
tex %= 1.0; // address wrap
//tex = saturate(tex); // address clamp
//if(saturate(tex.x) != tex.x || saturate(tex.y) != tex.y) // address border
// return border_color;
return tex2D(smp, (tex + skin_num) / num_skins_total);
}
Last edited by Kartoffel; 09/02/14 10:15.
POTATO-MAN saves the day! - Random
|
|
|
Re: Sprites with multiple skins
[Re: Emre]
#445280
09/02/14 11:05
09/02/14 11:05
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
OP
Expert
|
OP
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
okay, nice. BUT, I really don't like generated normalmaps Especially because I'm working on low-res graphics and the normalmaps have to be really accurate.
POTATO-MAN saves the day! - Random
|
|
|
Re: Sprites with multiple skins
[Re: Emre]
#445283
09/02/14 11:20
09/02/14 11:20
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
OP
Expert
|
OP
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
yeah but thanks though, always nice to see how ppl offer their help here... really appreciate that.
POTATO-MAN saves the day! - Random
|
|
|
|