Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, howardR), 472 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Sprites with multiple skins #445244
09/01/14 13:09
09/01/14 13:09
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline 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 Offline
Expert
sivan  Offline
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.

Free world editor for 3D Gamestudio: MapBuilder Editor
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 Offline
User
Emre  Offline
User

Joined: Jul 2007
Posts: 619
Turkey, Izmir
how about shader solution?
Code:
//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 Offline OP
Expert
Kartoffel  Offline 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:
Code:
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: Kartoffel] #445279
09/02/14 11:00
09/02/14 11:00
Joined: Jul 2007
Posts: 619
Turkey, Izmir
Emre Offline
User
Emre  Offline
User

Joined: Jul 2007
Posts: 619
Turkey, Izmir
Originally Posted By: Kartoffel
not sure what it does? I guess you're generating a normalmap from the color data?

Yes, exactly. laugh


as far as i remember, i took that code from RenderMonkey

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 Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
okay, nice. BUT, I really don't like generated normalmaps smirk
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: Kartoffel] #445282
09/02/14 11:17
09/02/14 11:17
Joined: Jul 2007
Posts: 619
Turkey, Izmir
Emre Offline
User
Emre  Offline
User

Joined: Jul 2007
Posts: 619
Turkey, Izmir
fair enough. i don't like it either. as i said result is not very good. tongue

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 Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
yeah grin
but thanks though, always nice to see how ppl offer their help here... really appreciate that.


POTATO-MAN saves the day! - Random

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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