Sign in to follow this  

fragment program: error C9999: symbol "@TMP0" already in table

This topic is 4104 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

A fragment shader (compiled to 235 instruction on nvidia gpu) works well on 7800, and 7600. But not on the 7300. There it throws this error: (0) : error C9999: symbol "@TMP0" already in table What does it mean? Searching google didn't help. The posts in this forum on this topic did not help. I could break down the problem to the following code fragment (commenting it out helped, the rest of the shader works fine):
vec4 local_reflection = vec4(0.0,0.0,0.0,0.0);
float r = ReflectionOffset;
const vec3 R1 = reflect(-E,N);
const vec3 R = fDistanceUndisplaced * R1;
const vec2 dN = (ReflectionDisplacement / fDistanceUndisplaced ) * N.xz;
for( int i=0; i<5; i++, r -= 0.5 * ReflectionOffset ) {
	vec4 dPos = ReflectionMatrix * vec4( position + r*R, 1.0 );
	dPos.xy /= dPos.w;
	dPos.xy += vec2(1.0,1.0);
	dPos.xy *= window_dim_half;
	dPos.xy += dN;
	local_reflection += textureRect( ReflectionMap, dPos.xy );
}
local_reflection *= 0.2;
It computes a local reflection on a hardly planar surface (an ocean) and takes multiple samples to emulate a slightly diffuse reflection.

Share this post


Link to post
Share on other sites
post the whole shader.... take the vec4 dPos out of the loop and declare it ahead of the loop. just a thought

and this

for( int i=0; i<5; i++, r -= 0.5 * ReflectionOffset )


I guess I never seen a for loop like that before?

Share this post


Link to post
Share on other sites
Quote:
I guess I never seen a for loop like that before?


No, the second iterator part is no problem. I also had the "r -= 0.5 * ReflectionOffset;" inside the for loop, and the error was the same.

The whole shader:



uniform sampler2D NormalMap;
uniform samplerRect ReflectionMap;
uniform samplerCube ReflectionCubeMap;
uniform sampler2D UnderwaterMap;

uniform float water_height;
uniform vec3 deepColor;
uniform vec3 skyFilterColor;
uniform float nSnell;
uniform float Kdiffuse;
uniform vec3 airColor;
uniform float UnderWaterMapScale;
uniform float UnderWaterDistance;
uniform vec3 UnderWaterMapFilter;

// reflections
uniform float SpecularShininess;
uniform vec3 SpecularCoefficients;

// reflections tweaking
uniform float ReflectionDisplacement, ReflectionOffset;
uniform mat4 ReflectionMatrix;
uniform vec2 window_dim_half;

// bump mapping parameters
uniform vec2 bumpTextureScale;
uniform vec2 bump_delta1, bump_delta2, bump_delta3; // time dependent translations
uniform float bumpScale;

// atmosphere
uniform vec3 v3CameraPos; // The camera's current position
uniform vec3 v3LightPos; // The direction vector to the light source
uniform vec3 bR; // Rayleigh coefficients
uniform vec3 bM; // Mie coefficients
uniform vec4 Esun; // Sun irradiance
uniform float g; // Hanyey/Greenstein phase function eccentricity
uniform float scale1; // Geometry to Shader scale


varying vec3 position;
varying vec3 normal;
varying mat3 tangentSpaceMatrix;

void main(void) {

const vec3 eyeVector = normalize( v3CameraPos - position );

const float fDistanceUndisplaced = distance( vec3(position.x,water_height,position.z), v3CameraPos );

// calculate texture coordinates for normal map lookup & compute normal
const vec2 bumpuv = gl_TexCoord[0].xy * bumpTextureScale;
const vec3 t0 = texture2D(NormalMap, bumpuv + bump_delta1).xyz;
const vec3 t1 = texture2D(NormalMap, bumpuv * 2.0 + bump_delta2).xyz;
const vec3 t2 = texture2D(NormalMap, bumpuv * 4.0 + bump_delta3).xyz;
const vec3 N = normalize( ( tangentSpaceMatrix * ( 2.0 * (t0 + t1 + t2) - 3.0 ) ) );
const vec3 E = eyeVector;

// compute reflectivity
const float thetai = acos( abs( dot(E,N) ) );
const float thetat = asin( sin(thetai) / nSnell );
const float fs = sin(thetai - thetat) / sin(thetai + thetat);
const float ts = tan(thetai - thetat) / tan(thetai + thetat);
const float reflectivity = 0.5 * ( fs*fs + ts*ts );
const float dist = exp( - fDistanceUndisplaced * Kdiffuse );

vec4 local_reflection = vec4(0.0,0.0,0.0,0.0);

// &lt;problem occurs in this part&gt;
float r = ReflectionOffset;
const vec3 R1 = reflect(-E,N);
const vec3 R = fDistanceUndisplaced * R1;
const vec2 dN = (ReflectionDisplacement / fDistanceUndisplaced ) * N.xz;
for( int i=0; i&lt;5; i++ ) {
vec4 dPos = ReflectionMatrix * vec4( position + r*R, 1.0 );
dPos.xy /= dPos.w;
dPos.xy = window_dim_half * ( dPos.xy + vec2(1.0,1.0) ); // translate and scale to 0..1 and scale to viewport coordinates
local_reflection += textureRect( ReflectionMap, dPos.xy + dN );
r -= 0.5 * ReflectionOffset;
}
local_reflection *= 0.2;
// &lt;/problem occurs in this part&gt;

vec3 Rg = reflect(E,N);
Rg.z = -Rg.z;
if( Rg.y &gt; 0.0 ) Rg.y = 0.0; // clip to above water
vec4 global_reflection = textureCube( ReflectionCubeMap, Rg );

// add specular term to global_reflection
if( dot(N,v3LightPos) &gt; 0.0 && (Esun.r+Esun.g+Esun.b) &gt; 0.0 ) {
const vec3 L = -v3LightPos;
const vec3 Rl = reflect(L,N);
const float spec1 = pow( dot(Rl,E), SpecularShininess );
if( spec1 &gt; 0.0 ) {
const vec3 spec = spec1 * Esun.rgb * SpecularCoefficients;
global_reflection.rgb += spec;
}
}

// mix reflection terms
vec3 sky = skyFilterColor * mix( global_reflection.rgb, local_reflection.rgb, local_reflection.a );


// compute refracted ray and intersect ray with underwater plane
const vec3 RE = refract(E,N,1.0/nSnell);
const vec3 groundPosition = UnderWaterMapScale * ( vec3(position.x,0.0,position.z) + (UnderWaterDistance/RE.y) * RE );

// attenuate airColor and upwelling at night
const float attenuate = clamp( 1.0 + 2.5 * v3LightPos.y, 0.0, 1.0 );

// final upwelling term
const vec3 upwelling = attenuate * ( (vec3(1.0,1.0,1.0)-UnderWaterMapFilter) * deepColor + UnderWaterMapFilter * texture2D( UnderwaterMap, (groundPosition.xz) ).xyz );


// combine results
const vec3 color = dist * ( reflectivity * sky + (1.0-reflectivity) * upwelling ) + (1.0-dist) * attenuate * airColor;
gl_FragColor = vec4( AtmosphericScattering( position, N, color, scale1, v3CameraPos, v3LightPos, Esun, bR, bM, g ), 1.0 );
}

Share this post


Link to post
Share on other sites

This topic is 4104 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this