|
|
Help!
by VoroneTZ. 10/14/25 05:04
|
|
|
|
|
|
|
3 registered members (TipmyPip, Quad, AndrewAMD),
7,177
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
animated sprites / matTexture
#346595
11/07/10 21:23
11/07/10 21:23
|
Joined: Jul 2001
Posts: 6,904
HeelX
OP
Senior Expert
|
OP
Senior Expert
Joined: Jul 2001
Posts: 6,904
|
Hi, I noticed that some of my A8-shaders, which deal with animated sprites, behave different under A7 -- or in other words: they work in A7 as one could assume and need extra overhead in A8. In the A8-version I always got coordinates for the whole texture. That means, if I returned just the color * alpha, I stretched -all frames- on the texture surface. After some experimenting, I used the following construction in my vertex shader:
VS_OUT VS (VS_IN In)
{
VS_OUT Out = (VS_OUT)0;
// If this an animated sprite we have to transform coordinates
if (vecSkill1.x > 0)
{
// Set to first frame
Out.Tex = mul(In.Tex, matTexture);
// Shift by frame number
float4 width = mul(float4(1,0,0,0), matTexture);
Out.Tex.x += vecSkill1.y * width;
}
else // Everything else (default)
{
Out.Tex.xy = In.Tex.xy;
}
(...) // Do some other stuff
return(Out);
}
I wasted two material skills for the flag if this is an animated sprite and another one for which frame it is. I didn't knew if this is right or wrong, but hey, it worked  Now, when checking if they work with A7, I encountered that something went wrong. After some trial and error I recognized that I can simply do without that matTexture-related instructions. I used a compiler switch to detect if this is A8 or A7 and set a float to see if this is A8, so that I can branch into this extra code-section (or better said: to leave it, if it is A7):
// A7 compatibility mode
#ifndef wait_for_my
#define PP_SSAO_A7_COMPAT
float ppSsaoIsA8 = 0; // For shaders
#else
float ppSsaoIsA8 = 1; // For shaders
#endif
So, you might ask "what is the point? It works for him!" Well, if you accidently changed this behaviour while migrating to A8, please fix it, because it saves me lots of overhead and additional shader cycles ;-)
Last edited by HeelX; 11/07/10 22:51.
|
|
|
Re: animated sprites / matTexture
[Re: jcl]
#346643
11/08/10 14:46
11/08/10 14:46
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
Expert
|
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
It could just be me, but I don't think the "standard shader functions" are particularly popular amongst shader programmers -- at least, I prefer to handle transformations myself in order that I can make changes as needed for the effect I need.
Jibb
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
Re: animated sprites / matTexture
[Re: jcl]
#346649
11/08/10 16:08
11/08/10 16:08
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
Expert
|
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
But the "standard shader functions" are just functions anyway, the majority of which contain no branches whatsoever. So whether we use the "standard shader functions" or not, it makes no difference to how many variants and branches we need to write for the shader situations in our games. Surely the best answer would've been that the change between A7 and A8 is indeed intentional, but hasn't yet been documented?
float4x4 matTexture;
float2 DoTexture(float2 Tex)
{
return mul(float4(Tex.x,Tex.y,1,1),matTexture).xy;
}
@HeelX: This is A8's DoTexture. I don't know what A7's DoTexture looks like, but I imagine the difference is the way matTexture works rather than the actual DoTexture functions, since this function makes no attempt to do the animation itself. Jibb
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
Re: animated sprites / matTexture
[Re: jcl]
#346909
11/10/10 15:49
11/10/10 15:49
|
Joined: Jul 2001
Posts: 6,904
HeelX
OP
Senior Expert
|
OP
Senior Expert
Joined: Jul 2001
Posts: 6,904
|
When you want to release something to the public, you must make sure to include all needed files. Including .fx files is absolutely no different then including models or any other resources. I know :-) What is nagging me is that I have to publish the code\ folder of the Gamestudio installation for loading the default.fx properly:
#define PRAGMA_PATH "%EXE_DIR%\\code";
Which is only valid for dev-mode ... what if the user - or I for demo reasons - want to publish it? Then he/I have to add the default.fx into that folder (beside the compiled .exe, acknex.dll and so on). That is an unconvinient situation, I also think that the publish dialog doesn't copy the default.fx... So the only way to publish sourcecode to the public using the default.fx file is to do the #define as stated above for dev-mode and when publishing binaries loading the .fxo files instead. Isn't it? I hope you understand this issue... Best regards, -Christian BTW: can't you just place some #defines like #define A8 and/or version defines like #define A8_1_0 or so into acknex.h to enable engine(-version) dependent compiler directives?
|
|
|
|