Da pojasnim mislim na samu implementaciju unutra koda.
Zavrsavam neku igricu za diplomski pa sam zaglavio bio na par mesta pisaao sam o tome da ne davim,
konkretno sada kada instanciram effekat "vBomb.fx"
dodelim mu matWorldViewProj setujem promenjive parametre na vrednosti koje meni odgovaraju i krenem iscrtavanje
u OnRender event-u
//Brisanje ekrana provere i ostalo
int numPasses = _effectBall.Begin(FX.None);
for(int i=0;i<numPasses;i++)
{
_effectBall.BeginPass(i);
_meshBall.Draw(_device,0.5f,new Vector3(Y,R,P));
//0.5f je skaliranje a Y,R,P su konstante... Inace _meshBall 0 je
//objekat moje neke klase Ball tako da je Draw() metoda ovakva...
_effectBall.EndPass();
}
_effectBall.End();
// ostatak isctravanja (teren, drvece, ostali objekti)...
E jednostavno kugla se ne vidi ni efekat na njoj ??? ....
To me muci :S
Voleo bi da neko ovde ko mi non sto pomaze i ovom prilikom se zahvaljujem smiljanicu i ostalima proba da izvede prostu implementaciju u kodu ovog effekta
io da mi ukaze na gresku koja mi promice...
moguce da je stvar do samog effekta ali NVIDIA ga deli kao share sto kapiram znaci da je proveren i moguc za implementaciju u kodu...
Ukoliko je potrebno mogu da nakacima kod effekta da prodiskutujemo o tome...
a evo i shadera
--
--
Code:
#include <include\\vnoise-table.fxh>
float Script : STANDARDSGLOBAL <
string UIWidget = "none";
string ScriptClass = "object";
string ScriptOrder = "standard";
string ScriptOutput = "color";
string Script = "Technique=Main;";
> = 0.8;
//////////////////////////////////////////////////////////////
// UNTWEAKABLES //////////////////////////////////////////////
//////////////////////////////////////////////////////////////
float Timer : TIME <string UIWidget="None";>;
float4x4 WvpXf : WORLDVIEWPROJECTION <string UIWidget="None";>;
//////////////////////////////////////////////////////////////
// TWEAKABLES ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
float Displacement <
string UIWidget = "slider";
float UIMin = 0.0;
float UIMax = 2.0;
float UIStep = 0.01;
> = 1.6f;
float Sharpness <
string UIWidget = "slider";
float UIMin = 0.1;
float UIMax = 5.0;
float UIStep = 0.1;
> = 1.90f;
float ColorSharpness <
string UIWidget = "slider";
float UIMin = 0.1;
float UIMax = 5.0;
float UIStep = 0.1;
> = 3.0f;
float Speed <
string UIWidget = "slider";
float UIMin = 0.01;
float UIMax = 1.0;
float UIStep = 0.001;
> = 0.3f;
float TurbDensity <
string UIWidget = "slider";
string UIName = "Turbulence Density";
float UIMin = 0.01;
float UIMax = 8.0;
float UIStep = 0.001;
> = 2.27f;
float ColorRange <
string UIWidget = "slider";
string UIName = "Color Range";
float UIMin = -6.0;
float UIMax = 6.0;
float UIStep = 0.01;
> = -2.0f;
float4x4 NoiseMatrix <
string UIName = "Coordinate System for Noise";
> = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1};
//float4 dd[5] = {
// 0,2,3,1, 2,2,2,2, 3,3,3,3, 4,4,4,4, 5,5,5,5 };
//////////////////////////// texture ///////////////////////
texture GradeTex <
// string ResourceName = "1D\\FireGrade.bmp";
string ResourceName = "FireGrade.bmp";
string ResourceType = "2D";
string UIName = "Fire Gradient";
>;
sampler2D GradeSampler = sampler_state
{
Texture = <GradeTex>;
MinFilter = Linear;
MipFilter = Point;
AddressU = Clamp;
AddressV = Clamp;
};
///////////// functions
// this is the smoothstep function f(t) = 3t^2 - 2t^3, without the normalization
float3 s_curve(float3 t) { return t*t*( float3(3,3,3) - float3(2,2,2)*t); }
float2 s_curve(float2 t) { return t*t*( float2(3,3) - float2(2,2)*t); }
float s_curve(float t) { return t*t*(3.0-2.0*t); }
// 3D version
float noise(float3 v, const uniform float4 pg[FULLSIZE])
{
v = v + (10000.0f).xxx; // hack to avoid negative numbers
float3 i = frac(v * NOISEFRAC) * BSIZE; // index between 0 and BSIZE-1
float3 f = frac(v); // fractional position
// lookup in permutation table
float2 p;
p.x = pg[ i[0] ].w;
p.y = pg[ i[0] + 1 ].w;
p = p + i[1];
float4 b;
b.x = pg[ p[0] ].w;
b.y = pg[ p[1] ].w;
b.z = pg[ p[0] + 1 ].w;
b.w = pg[ p[1] + 1 ].w;
b = b + i[2];
// compute dot products between gradients and vectors
float4 r;
r[0] = dot( pg[ b[0] ].xyz, f );
r[1] = dot( pg[ b[1] ].xyz, f - float3(1.0f, 0.0f, 0.0f) );
r[2] = dot( pg[ b[2] ].xyz, f - float3(0.0f, 1.0f, 0.0f) );
r[3] = dot( pg[ b[3] ].xyz, f - float3(1.0f, 1.0f, 0.0f) );
float4 r1;
r1[0] = dot( pg[ b[0] + 1 ].xyz, f - float3(0.0f, 0.0f, 1.0f) );
r1[1] = dot( pg[ b[1] + 1 ].xyz, f - float3(1.0f, 0.0f, 1.0f) );
r1[2] = dot( pg[ b[2] + 1 ].xyz, f - float3(0.0f, 1.0f, 1.0f) );
r1[3] = dot( pg[ b[3] + 1 ].xyz, f - float3(1.0f, 1.0f, 1.0f) );
// interpolate
f = s_curve(f);
r = lerp( r, r1, f[2] );
r = lerp( r.xyyy, r.zwww, f[1] );
return lerp( r.x, r.y, f[0] );
}
// 2D version
float noise(float2 v, const uniform float4 pg[FULLSIZE])
{
v = v + (10000.0f).xx;
float2 i = frac(v * NOISEFRAC) * BSIZE; // index between 0 and BSIZE-1
float2 f = frac(v); // fractional position
// lookup in permutation table
float2 p;
p[0] = pg[ i[0] ].w;
p[1] = pg[ i[0]+1 ].w;
p = p + i[1];
// compute dot products between gradients and vectors
float4 r;
r[0] = dot( pg[ p[0] ].xy, f);
r[1] = dot( pg[ p[1] ].xy, f - float2(1.0f, 0.0f) );
r[2] = dot( pg[ p[0]+1 ].xy, f - float2(0.0f, 1.0f) );
r[3] = dot( pg[ p[1]+1 ].xy, f - float2(1.0f, 1.0f) );
// interpolate
f = s_curve(f);
r = lerp( r.xyyy, r.zwww, f[1] );
return lerp( r.x, r.y, f[0] );
}
// 1D version
float noise(float v, const uniform float4 pg[FULLSIZE])
{
v = v + 10000.0f;
float i = frac(v * NOISEFRAC) * BSIZE; // index between 0 and BSIZE-1
float f = frac(v); // fractional position
// compute dot products between gradients and vectors
float2 r;
r[0] = pg[i].x * f;
r[1] = pg[i + 1].x * (f - 1.0f);
// interpolate
f = s_curve(f);
return lerp( r[0], r[1], f);
}
/////////////////////////////
struct appData
{
float4 Position : POSITION;
float4 Normal : NORMAL;
float4 TexCoord0 : TEXCOORD0;
};
// define outputs from vertex shader
struct vbombVertexData
{
float4 HPosition : POSITION;
float4 Color0 : COLOR0;
};
////////
vbombVertexData mainVS(appData IN) {
vbombVertexData OUT;
float4 noisePos = TurbDensity*mul(IN.Position+(Speed*Timer),NoiseMatrix);
float i = (noise(noisePos.xyz, NTab) + 1.0f) * 0.5f;
float cr = 1.0-(0.5+ColorRange*(i-0.5));
cr = pow(cr,ColorSharpness);
OUT.Color0 = float4((cr).xxx, 1.0f);
// displacement along normal
float ni = pow(abs(i),Sharpness);
i -= 0.5;
//i = sign(i) * pow(i,Sharpness);
// we will use our own "normal" vector because the default geom is a sphere
float4 Nn = float4(normalize(IN.Position).xyz,0);
float4 NewPos = IN.Position - (Nn * (ni-0.5) * Displacement);
//position.w = 1.0f;
OUT.HPosition = mul(NewPos,WvpXf);
return OUT;
}
float4 hotPS(vbombVertexData IN) : COLOR {
float2 nuv = float2(IN.Color0.x,0.5);
float4 nc = tex2D(GradeSampler,nuv);
//return float4(IN.Color0.xxx,1.0);
return nc;
}
//////////////////////
technique Main <
string Script = "Pass=p0;";
> {
pass p0 <
string Script = "Draw=geometry;";
> {
VertexShader = compile vs_2_0 mainVS();
ZEnable = true;
ZWriteEnable = true;
ZFunc = LessEqual;
CullMode = None;
PixelShader = compile ps_2_a hotPS();
}
}