Thanks,
Help with some complicated C coding
Started by
stettybet0
, Feb 22 2008 09:28 PM
#1
Posted 22 February 2008 - 09:28 PM
Thanks,
#2
Posted 24 February 2008 - 04:40 PM
Could you please repost these with the "correct" format - this is important as many parts of the code dwell upon the fact of formatting.
#3
Posted 24 February 2008 - 08:09 PM
The formatting that you see when you download the files is the same as it actually is. I don't think formatting is the problem, because separately both of these mods work. Thanks for the thought though.
#4
Posted 29 February 2008 - 10:59 PM
It seems that some of the variables are not correctly assigned.
#5
Posted 29 February 2008 - 11:29 PM
If you could be a bit more specific, that would be helpful.
#6
Posted 01 March 2008 - 02:38 PM
I would suggest checking the following:
From Common1:
Common2:
From Common1:
float calc_cyclic (float x) { float phase = 1/(2*3.141592653589f); float sqrt2 = 1.4142136f; float sqrt2m2 = 2.8284271f; float f = sqrt2m2*frac(x)-sqrt2; // [-sqrt2 .. +sqrt2] !No changes made, but this controls the grass wave (which is violent if I must say) return f*f - 1.f; // [-1 .. +1] } float2 calc_xz_wave (float2 dir2D, float frac) { // Beizer float2 ctrl_A = float2(0.f, 0.f ); float2 ctrl_B = float2(dir2D.x, dir2D.y ); return lerp (ctrl_A, ctrl_B, frac);
Common2:
float4 offsetBest = float4(vTexCurrentOffset,0,0); vTexCurrentOffset.xy -= vTexOffsetPerStep; float fPrevHeight = tex2Dlod( s_base, float4(vTexCurrentOffset.xy,0,0) ).a+Brightness; if (fPrevHeight > Q2) fPrevHeight = 1.0f; else if (fPrevHeight < Q1) fPrevHeight = 0.0f; else fPrevHeight = (fPrevHeight - Q1)/(Q2-Q1); float error = 1.0; float t1 = fCurrentBound; float t0 = t1 + fStepSize; float delta1 = t1 - fCurrHeight; float delta0 = t0 - fPrevHeight; float4 intersect = float4(vDelta, vDelta + tc); for (int i=0; i<3 && abs(error) > 0.01; i++) { float denom = (delta1 - delta0); float t = (t0 * delta1 - t1 * delta0) / denom; offsetBest.xy = -t * intersect.xy + intersect.zw; float NB = tex2Dlod(s_base, offsetBest).a+Brightness; if (NB > Q2) NB = 1.0f; else if (NB < Q1) NB = 0.0f; else NB = (NB - Q1)/(Q2-Q1); error = t - NB;
Similar Topics
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users