[size=150]Difference between 1.7.0 and Runtime[/size]
I continue to build special effects for my game. I decided that if everything will eventually be on the web, I should try to make my footprint as small as possible, this means moving away from pre-rendered effects and moving toward shaders. It saves footprint size and I think the end result looks better anyway.
During that process I’ve run into a problem. Here is my “plasma explosion” shader in Panda 1.7.0

and here is the result if I run the same thing as a packed p3d file in panda3d.exe

The shader is a little complex- I set a start position in world-space, then move the vertices away from that point in the vertex shader, I apply a plasma and mix it with a gradient that is set up along the distance from the world space origin to the current position of the fragment.
The runtime version appears to be simply ignoring that texture and combine call. That texture is called “agemap” in the code below.
Here’s the code, sorry for it’s length.
//Cg
//This shader is for explosions.
void vshader(
float2 vtx_texcoord0 : TEXCOORD0,
out float2 l_texcoord0 : TEXCOORD0,
uniform float4x4 trans_model_to_view,
uniform float4x4 tpose_view_to_model,
uniform float4x4 trans_model_to_world,
in float4 vtx_normal : TEXCOORD1,
uniform float4 k_startTime,
uniform float4 k_time,
uniform float4 k_values,
out float4 l_normal : TEXCOORD2,
out float4 l_pos : TEXCOORD1,
out float4 l_explosionVec,
float4 vtx_position : POSITION,
out float4 l_position : POSITION,
uniform float4 wspos_pos,
uniform float4x4 mat_modelproj
) {
//Calculate world space for vertex and compare to world space start point.
float4 worldSpacePos = mul(trans_model_to_world, vtx_position);
l_explosionVec = worldSpacePos-wspos_pos; //vector from start point to vertex in question.
//Calculate time passed since start and re-set vertex.
float time = k_time.x - k_startTime.x;
//calculate displacement along the explosion vector.
// k_values.x is amplitude
// k_values.y is surface roughness
// k_values.z is speed of expansion
float displace = k_values.x* sin((vtx_position.x+vtx_position.y+vtx_position.z+time*.2)*k_values.y) ;
l_explosionVec += l_explosionVec * time*k_values.z+ vtx_normal*displace ;
vtx_position += l_explosionVec ;
//Basic vertex functions
l_position = mul(mat_modelproj, vtx_position);
l_texcoord0 = vtx_texcoord0;
l_pos = mul(trans_model_to_view, vtx_position);
l_normal.xyz = mul((float3x3)tpose_view_to_model, vtx_normal.xyz);
l_normal.w = 0;
}
void fshader(
in float4 l_explosionVec: TEXCOORD3,
float2 l_texcoord0 : TEXCOORD0,
uniform sampler2D tex_0,
uniform float4 k_values,
uniform sampler2D k_tex1 : TEXUNIT0,
uniform sampler2D k_tex2 : TEXUNIT1,
uniform sampler2D k_agemap : TEXUNIT2,
uniform sampler2D k_firetex : TEXUNIT3,
uniform float4 k_time,
uniform float4 k_startTime,
out float4 o_color : COLOR0,
uniform float4 attr_color
) {
//determine how far this fragment is from the worldPos and apply gradient, stretch out that gradient by "size" value.
//This will create a type of spherical 3D texture with the gradient applied.
float size = k_values.w;
float j = length(l_explosionVec)/size;
if( j >= 0.99)
j = 0.99;
float4 result = tex2D(k_agemap, float2(j,0));
//generate cycling map
float2 off1 = float2(0.01,0.01) * k_time.x * 3;
float2 off2 = float2(-0.02,-0.03) * k_time.x * 3;
float c1 = tex2D(k_tex1, l_texcoord0 + off1).x;
float c2 = tex2D(k_tex2, l_texcoord0 + off2).x;
float v = saturate(c1+c2-0.2);
float4 move = tex2D(k_firetex, float2(v,0));
//determine time since start of model.
float time = k_time.x - k_startTime.x;
// combine the spherical 3D volume texture with the cycling map
float4 combine = lerp(move,result,0.7);
float alpha = result.a -(time*.2) ; //the explosion should generally become more transparent through time.
o_color = float4(combine.r,combine.g,combine.b,alpha);
}
What am I doing wrong? and why was the outputs different between the SDK and the runtime?