Ejemplo n.º 1
0
void FinalCombinerStruct::Invoke()
{
	if(clamp)
		glCombinerParameteriNV(GL_COLOR_SUM_CLAMP_NV, GL_TRUE);
	else
		glCombinerParameteriNV(GL_COLOR_SUM_CLAMP_NV, GL_FALSE);

	glFinalCombinerInputNV(
		GL_VARIABLE_A_NV,
		rgb.a.reg.bits.name,
		rgb.a.map,
		MAP_CHANNEL(rgb.a.reg.bits.channel));

	glFinalCombinerInputNV(
		GL_VARIABLE_B_NV,
		rgb.b.reg.bits.name,
		rgb.b.map,
		MAP_CHANNEL(rgb.b.reg.bits.channel));

	glFinalCombinerInputNV(
		GL_VARIABLE_C_NV,
		rgb.c.reg.bits.name,
		rgb.c.map,
		MAP_CHANNEL(rgb.c.reg.bits.channel));

	glFinalCombinerInputNV(
		GL_VARIABLE_D_NV,
		rgb.d.reg.bits.name,
		rgb.d.map,
		MAP_CHANNEL(rgb.d.reg.bits.channel));

	glFinalCombinerInputNV(
		GL_VARIABLE_E_NV,
		product.e.reg.bits.name,
		product.e.map,
		MAP_CHANNEL(product.e.reg.bits.channel));

	glFinalCombinerInputNV(
		GL_VARIABLE_F_NV,
		product.f.reg.bits.name,
		product.f.map,
		MAP_CHANNEL(product.f.reg.bits.channel));

	glFinalCombinerInputNV(
		GL_VARIABLE_G_NV,
		alpha.g.reg.bits.name,
		alpha.g.map,
		MAP_CHANNEL(alpha.g.reg.bits.channel));
}
Ejemplo n.º 2
0
void InitChromaticTwin2States()
{
	//Set up the register combiners
	glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, 1);

	//Disable per-stage constants if we have been using them
	if(NV_register_combiners2_supported)
		glDisable(GL_PER_STAGE_CONSTANTS_NV);

	//Send (1, 0, 0, 0) as constant color 0
	GLfloat constant0[]={1.0f, 0.0f, 0.0f, 0.0f};
	glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV, constant0);
	
	//Combiner 0 does:	red(tex0)->spare0.rgb
	glCombinerInputNV(	GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_A_NV, GL_TEXTURE0_ARB,
						GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glCombinerInputNV(	GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_B_NV, GL_CONSTANT_COLOR0_NV,
						GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glCombinerOutputNV(	GL_COMBINER0_NV, GL_RGB, GL_SPARE0_NV, GL_DISCARD_NV, GL_DISCARD_NV,
						GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);

	glFinalCombinerInputNV(GL_VARIABLE_A_NV, GL_PRIMARY_COLOR_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_TEXTURE1_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glFinalCombinerInputNV(GL_VARIABLE_C_NV, GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glFinalCombinerInputNV(GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);

	//Bind vertex program
	glBindProgramNV(GL_VERTEX_PROGRAM_NV, chromaticTwin2VP);

	//Enable blend to add to first pass
	glBlendFunc(GL_ONE, GL_ONE);
	glEnable(GL_BLEND);
}
Ejemplo n.º 3
0
void SetTexture3DAttenStates()
{
    //Set up texture units
    //Unit 0 - decal texture
    glBindTexture(GL_TEXTURE_2D, decalTexture);
    //Unit 1 - 3d attanuation
    glActiveTextureARB(GL_TEXTURE1_ARB);
    glBindTexture(GL_TEXTURE_3D, atten3DTexture);
    glActiveTextureARB(GL_TEXTURE0_ARB);

    //Set up register combiners
    //one general combiner
    glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, 1);

    //Set up final combiner to output tex1*col0*tex0
    //first do tex0*col0 in the EF multiplier
    glFinalCombinerInputNV(GL_VARIABLE_E_NV, GL_TEXTURE0_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
    glFinalCombinerInputNV(GL_VARIABLE_F_NV, GL_PRIMARY_COLOR_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);

    //now do rest
    glFinalCombinerInputNV(GL_VARIABLE_A_NV, GL_TEXTURE1_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
    glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_E_TIMES_F_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
    glFinalCombinerInputNV(GL_VARIABLE_C_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
    glFinalCombinerInputNV(GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
}
Ejemplo n.º 4
0
void SetLookUpSpecularStates(void)
{
	//Set Up Texture Shaders
	
	//Unit 0 - texture 2d with signed normal map
	glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_2D);
	if(showBumps)
		glBindTexture(GL_TEXTURE_2D, signedNormalMap);
	else
		glBindTexture(GL_TEXTURE_2D, signedFlatNormalMap);

	//Unit 1 - dot product
	glActiveTextureARB(GL_TEXTURE1_ARB);
	glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_NV);
	glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB);

	//Unit 2 - dot product texture 2d into specular ramp
	glActiveTextureARB(GL_TEXTURE2_ARB);
	glBindTexture(GL_TEXTURE_2D, specularRamp);
	glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_TEXTURE_2D_NV);
	glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB);

	//Unit 3 - texture 2d with normal map (for gloss)
	glActiveTextureARB(GL_TEXTURE3_ARB);
	glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_2D);
	if(showBumps)
		glBindTexture(GL_TEXTURE_2D, normalMapTexture);
	else
		glBindTexture(GL_TEXTURE_2D, flatNormalMap);

	glActiveTextureARB(GL_TEXTURE0_ARB);

	glEnable(GL_TEXTURE_SHADER_NV);

	

	//Set up Register combiners
	//1 general combiner
	glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, 1);

	//final combiner outputs texture2*tex3.a
	glFinalCombinerInputNV(GL_VARIABLE_A_NV, GL_TEXTURE2_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_TEXTURE3_ARB, GL_UNSIGNED_IDENTITY_NV, GL_ALPHA);
	glFinalCombinerInputNV(GL_VARIABLE_C_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glFinalCombinerInputNV(GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);

	glEnable(GL_REGISTER_COMBINERS_NV);
	
	
	//Set up vertex program
	glEnable(GL_VERTEX_PROGRAM_NV);
	glBindProgramNV(GL_VERTEX_PROGRAM_NV, lookUpSpecularVertexProgram);
}
Ejemplo n.º 5
0
void InitChromaticSingleStates()
{
	//Set up the register combiners
	glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, 2);

	//Enable per stage constants
	glEnable(GL_PER_STAGE_CONSTANTS_NV);

	//Send (1, 0, 0, 0) and (0, 1, 0, 0) as combiner 0 constant colors
	GLfloat combiner0Constant0[]={1.0f, 0.0f, 0.0f, 0.0f};
	glCombinerStageParameterfvNV(GL_COMBINER0_NV, GL_CONSTANT_COLOR0_NV, combiner0Constant0);
	GLfloat combiner0Constant1[]={0.0f, 1.0f, 0.0f, 0.0f};
	glCombinerStageParameterfvNV(GL_COMBINER0_NV, GL_CONSTANT_COLOR1_NV, combiner0Constant1);

	//Send (0, 0, 1, 0) as combiner 1 constant color 0
	GLfloat combiner1Constant0[]={0.0f, 0.0f, 1.0f, 0.0f};
	glCombinerStageParameterfvNV(GL_COMBINER1_NV, GL_CONSTANT_COLOR0_NV, combiner1Constant0);

	//Combiner 0 does:	red(tex2)+green(tex1)->spare0.rgb
	glCombinerInputNV(	GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_A_NV, GL_TEXTURE2_ARB,
						GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glCombinerInputNV(	GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_B_NV, GL_CONSTANT_COLOR0_NV,
						GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glCombinerInputNV(	GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_C_NV, GL_TEXTURE1_ARB,
						GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glCombinerInputNV(	GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_D_NV, GL_CONSTANT_COLOR1_NV,
						GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glCombinerOutputNV(	GL_COMBINER0_NV, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, GL_SPARE0_NV,
						GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);

	//Combiner 1 does:	blue(tex0)+spare0.rgb->spare0.rgb
	glCombinerInputNV(	GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_A_NV, GL_TEXTURE0_ARB,
						GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glCombinerInputNV(	GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_B_NV, GL_CONSTANT_COLOR0_NV,
						GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glCombinerInputNV(	GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_C_NV, GL_SPARE0_NV,
						GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glCombinerInputNV(	GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_D_NV, GL_ZERO,
						GL_UNSIGNED_INVERT_NV, GL_RGB);
	glCombinerOutputNV(	GL_COMBINER1_NV, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, GL_SPARE0_NV,
						GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);

	glFinalCombinerInputNV(GL_VARIABLE_A_NV, GL_PRIMARY_COLOR_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_TEXTURE3_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glFinalCombinerInputNV(GL_VARIABLE_C_NV, GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glFinalCombinerInputNV(GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);

	//Bind vertex program
	glBindProgramNV(GL_VERTEX_PROGRAM_NV, chromaticSingleVP);
}
Ejemplo n.º 6
0
void GeneralCombinersStruct::Invoke()
{
    glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, num);
    int i;
    for (i = 0; i < num; i++)
        general[i].Invoke(i);
    
    if (NULL != glCombinerStageParameterfvNV) {
        if (localConsts > 0)
            glEnable(GL_PER_STAGE_CONSTANTS_NV);
        else
            glDisable(GL_PER_STAGE_CONSTANTS_NV);
    }
        
}
Ejemplo n.º 7
0
void SetDiffuseDecalStates(void)
{
	//Bind textures
	//Unit 0 - normal map
	glEnable(GL_TEXTURE_2D);
	if(showBumps)
		glBindTexture(GL_TEXTURE_2D, normalMapTexture);
	else
		glBindTexture(GL_TEXTURE_2D, flatNormalMap);

	//Unit 1 - normalisation cube map
	glActiveTextureARB(GL_TEXTURE1_ARB);
	glEnable(GL_TEXTURE_CUBE_MAP_ARB);
	glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, normalisationCubeMap);

	//Unit 2 - decal map
	glActiveTextureARB(GL_TEXTURE2_ARB);
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, decalTexture);
	glActiveTextureARB(GL_TEXTURE0_ARB);


	//Set up Register combiners
	//1 general combiner
	glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, 1);

	//combiner 0 does	tex0.rgb dot tex1.rgb -> spare0.rgb,
	glCombinerInputNV(	GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_A_NV, GL_TEXTURE0_ARB,
						GL_EXPAND_NORMAL_NV, GL_RGB);
	glCombinerInputNV(	GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_B_NV, GL_TEXTURE1_ARB,
						GL_EXPAND_NORMAL_NV, GL_RGB);
	
	glCombinerOutputNV(	GL_COMBINER0_NV, GL_RGB, GL_SPARE0_NV, GL_DISCARD_NV, GL_DISCARD_NV,
						GL_NONE, GL_NONE, GL_TRUE, GL_FALSE, GL_FALSE);

	//final combiner outputs spare0.rgb*texture2.rgb
	glFinalCombinerInputNV(GL_VARIABLE_A_NV, GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_TEXTURE2_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glFinalCombinerInputNV(GL_VARIABLE_C_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glFinalCombinerInputNV(GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);

	glEnable(GL_REGISTER_COMBINERS_NV);

	//Set up vertex program
	glEnable(GL_VERTEX_PROGRAM_NV);
	glBindProgramNV(GL_VERTEX_PROGRAM_NV, diffuseDecalVertexProgram);
}
Ejemplo n.º 8
0
void InitSimpleSingleStates()
{
	//Set up the register combiners
	glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, 2);

	//Disable per-stage constants if we have been using them
	if(NV_register_combiners2_supported)
		glDisable(GL_PER_STAGE_CONSTANTS_NV);

	//Final combiner does col0*tex1 + (1-col0)*tex0
	glFinalCombinerInputNV(GL_VARIABLE_A_NV, GL_PRIMARY_COLOR_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_TEXTURE1_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glFinalCombinerInputNV(GL_VARIABLE_C_NV, GL_TEXTURE0_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glFinalCombinerInputNV(GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);

	//Bind vertex program
	glBindProgramNV(GL_VERTEX_PROGRAM_NV, simpleSingleVP);
}
Ejemplo n.º 9
0
//Set the states for texture attenuation
void SetTextureAttenStates()
{
    //Set up texture units
    //Unit 0 - decal texture
    glBindTexture(GL_TEXTURE_2D, decalTexture);
    //Unit 1 - 2D attenuation
    glActiveTextureARB(GL_TEXTURE1_ARB);
    glBindTexture(GL_TEXTURE_2D, atten2DTexture);
    //Unit 2 - 1D attenuation
    glActiveTextureARB(GL_TEXTURE2_ARB);
    glBindTexture(GL_TEXTURE_1D, atten1DTexture);
    glActiveTextureARB(GL_TEXTURE0_ARB);

    //Set up register combiners
    //one general combiner
    glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, 1);

    //combiner 0 does tex1+tex2 -> spare0
    glCombinerInputNV(	GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_A_NV, GL_TEXTURE1_ARB,
                        GL_UNSIGNED_IDENTITY_NV, GL_RGB);
    glCombinerInputNV(	GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_B_NV, GL_ZERO,
                        GL_UNSIGNED_INVERT_NV, GL_RGB);
    glCombinerInputNV(	GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_C_NV, GL_TEXTURE2_ARB,
                        GL_UNSIGNED_IDENTITY_NV, GL_RGB);
    glCombinerInputNV(	GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_D_NV, GL_ZERO,
                        GL_UNSIGNED_INVERT_NV, GL_RGB);
    glCombinerOutputNV(	GL_COMBINER0_NV, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, GL_SPARE0_NV,
                        GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);

    //final combiner outputs (1-spare0)*tex0*col0
    //first do tex0*col0 in the EF multiplier
    glFinalCombinerInputNV(GL_VARIABLE_E_NV, GL_TEXTURE0_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
    glFinalCombinerInputNV(GL_VARIABLE_F_NV, GL_PRIMARY_COLOR_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);

    //now do rest
    glFinalCombinerInputNV(GL_VARIABLE_A_NV, GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
    glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
    glFinalCombinerInputNV(GL_VARIABLE_C_NV, GL_E_TIMES_F_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
    glFinalCombinerInputNV(GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
}
Ejemplo n.º 10
0
//Set the states for pass through atten
void SetPassThroughAttenStates()
{
    //Set up texture units
    //Unit 0 - decal texture
    glBindTexture(GL_TEXTURE_2D, decalTexture);

    //Set up texture shaders
    //unit 0 - decal
    glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_2D);
    //unit 1 - pass through atten coords
    glActiveTextureARB(GL_TEXTURE1_ARB);
    glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_PASS_THROUGH_NV);
    glActiveTextureARB(GL_TEXTURE0_ARB);


    //Set up register combiners
    //one general combiner
    glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, 1);

    //combiner 0 does tex1 dot tex1 -> spare0
    //spare 0 thus holds the squared length of the vector in tex1
    glCombinerInputNV(	GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_A_NV, GL_TEXTURE1_ARB,
                        GL_EXPAND_NORMAL_NV, GL_RGB);
    glCombinerInputNV(	GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_B_NV, GL_TEXTURE1_ARB,
                        GL_EXPAND_NORMAL_NV, GL_RGB);
    glCombinerOutputNV(	GL_COMBINER0_NV, GL_RGB, GL_SPARE0_NV, GL_DISCARD_NV, GL_DISCARD_NV,
                        GL_NONE, GL_NONE, GL_TRUE, GL_FALSE, GL_FALSE);

    //Set up final combiner to output clampto01(1-spare0)*col0*tex0
    //first do tex0*col0 in the EF multiplier
    glFinalCombinerInputNV(GL_VARIABLE_E_NV, GL_TEXTURE0_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
    glFinalCombinerInputNV(GL_VARIABLE_F_NV, GL_PRIMARY_COLOR_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);

    //now do rest
    glFinalCombinerInputNV(GL_VARIABLE_A_NV, GL_SPARE0_NV, GL_UNSIGNED_INVERT_NV, GL_RGB);
    glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_E_TIMES_F_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
    glFinalCombinerInputNV(GL_VARIABLE_C_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
    glFinalCombinerInputNV(GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_NVRegisterCombiners_nglCombinerParameteriNV(JNIEnv *env, jclass clazz, jint pname, jint param, jlong function_pointer) {
	glCombinerParameteriNVPROC glCombinerParameteriNV = (glCombinerParameteriNVPROC)((intptr_t)function_pointer);
	glCombinerParameteriNV(pname, param);
}
Ejemplo n.º 12
0
void SetSimpleSpecularStates(void)
{
	//Bind textures
	//Unit 0 - normal map
	glEnable(GL_TEXTURE_2D);
	if(showBumps)
		glBindTexture(GL_TEXTURE_2D, normalMapTexture);
	else
		glBindTexture(GL_TEXTURE_2D, flatNormalMap);

	//Unit 1 - normalisation cube map
	glActiveTextureARB(GL_TEXTURE1_ARB);
	glEnable(GL_TEXTURE_CUBE_MAP_ARB);
	glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, normalisationCubeMap);
	
	glActiveTextureARB(GL_TEXTURE0_ARB);

	

	//Set up Register combiners
	//2 general combiners
	glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, 2);

	//combiner 0 does	tex0.rgb dot tex1.rgb -> spare0.rgb,
	glCombinerInputNV(	GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_A_NV, GL_TEXTURE0_ARB,
						GL_EXPAND_NORMAL_NV, GL_RGB);
	glCombinerInputNV(	GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_B_NV, GL_TEXTURE1_ARB,
						GL_EXPAND_NORMAL_NV, GL_RGB);
	
	glCombinerOutputNV(	GL_COMBINER0_NV, GL_RGB, GL_SPARE0_NV, GL_DISCARD_NV, GL_DISCARD_NV,
						GL_NONE, GL_NONE, GL_TRUE, GL_FALSE, GL_FALSE);


	//combiner 1 does	2*((spare0.rgb * spare0.rgb)-0.5) -> spare0.rgb
	//					spare0.b   * tex0.a		-> spare0.a
	glCombinerInputNV(	GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_A_NV, GL_SPARE0_NV,
						GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glCombinerInputNV(	GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_B_NV, GL_SPARE0_NV,
						GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	
	glCombinerOutputNV(	GL_COMBINER1_NV, GL_RGB, GL_SPARE0_NV, GL_DISCARD_NV, GL_DISCARD_NV,
						GL_SCALE_BY_TWO_NV, GL_BIAS_BY_NEGATIVE_ONE_HALF_NV,
						GL_FALSE, GL_FALSE, GL_FALSE);


	glCombinerInputNV(	GL_COMBINER1_NV, GL_ALPHA, GL_VARIABLE_A_NV, GL_SPARE0_NV,
						GL_UNSIGNED_IDENTITY_NV, GL_BLUE);
	glCombinerInputNV(	GL_COMBINER1_NV, GL_ALPHA, GL_VARIABLE_B_NV, GL_TEXTURE0_ARB,
						GL_UNSIGNED_IDENTITY_NV, GL_ALPHA);
	
	glCombinerOutputNV(	GL_COMBINER1_NV, GL_ALPHA, GL_SPARE0_NV, GL_DISCARD_NV, GL_DISCARD_NV,
						GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);



	//final combiner outputs spare0.rgb*spare0.rgb*spare0.a
	//first do spare0.rgb * spare0.rgb in EF multiplier
	glFinalCombinerInputNV(GL_VARIABLE_E_NV, GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glFinalCombinerInputNV(GL_VARIABLE_F_NV, GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	
	glFinalCombinerInputNV(GL_VARIABLE_A_NV, GL_E_TIMES_F_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_ALPHA);
	glFinalCombinerInputNV(GL_VARIABLE_C_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glFinalCombinerInputNV(GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);

	glEnable(GL_REGISTER_COMBINERS_NV);
	
	
	//Set up vertex program
	glEnable(GL_VERTEX_PROGRAM_NV);
	glBindProgramNV(GL_VERTEX_PROGRAM_NV, simpleSpecularVertexProgram);
}
Ejemplo n.º 13
0
void SetSinglePassStates(void)
{
	//Bind textures
	//Unit 0 - normal map
	glEnable(GL_TEXTURE_2D);
	if(showBumps)
		glBindTexture(GL_TEXTURE_2D, normalMapTexture);
	else
		glBindTexture(GL_TEXTURE_2D, flatNormalMap);

	//Unit 1 - normalisation cube map
	glActiveTextureARB(GL_TEXTURE1_ARB);
	glEnable(GL_TEXTURE_CUBE_MAP_ARB);
	glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, normalisationCubeMap);
	
	//Unit 2 - normalisation cube map
	glActiveTextureARB(GL_TEXTURE2_ARB);
	glEnable(GL_TEXTURE_CUBE_MAP_ARB);
	glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, normalisationCubeMap);
	
	//Unit 3 - decal texture
	glActiveTextureARB(GL_TEXTURE3_ARB);
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, decalTexture);

	glActiveTextureARB(GL_TEXTURE0_ARB);

	

	//Set up Register combiners
	//3 general combiners
	glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, 4);

	//combiner 0 does	tex0.rgb dot tex1.rgb -> spare0.rgb,
	//					tex0.rgb dot tex2.rgb -> spare1.rgb
	glCombinerInputNV(	GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_A_NV, GL_TEXTURE0_ARB,
						GL_EXPAND_NORMAL_NV, GL_RGB);
	glCombinerInputNV(	GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_B_NV, GL_TEXTURE1_ARB,
						GL_EXPAND_NORMAL_NV, GL_RGB);
	
	glCombinerInputNV(	GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_C_NV, GL_TEXTURE0_ARB,
						GL_EXPAND_NORMAL_NV, GL_RGB);
	glCombinerInputNV(	GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_D_NV, GL_TEXTURE2_ARB,
						GL_EXPAND_NORMAL_NV, GL_RGB);
	
	glCombinerOutputNV(	GL_COMBINER0_NV, GL_RGB, GL_SPARE0_NV, GL_SPARE1_NV, GL_DISCARD_NV,
						GL_NONE, GL_NONE, GL_TRUE, GL_TRUE, GL_FALSE);


	//combiner 1 does	spare1.rgb * spare1.rgb -> spare1.rgb
	//					spare0.rgb * tex3.rgb   -> spare0.rgb
	glCombinerInputNV(	GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_A_NV, GL_SPARE1_NV,
						GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glCombinerInputNV(	GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_B_NV, GL_SPARE1_NV,
						GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glCombinerInputNV(	GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_C_NV, GL_SPARE0_NV,
						GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glCombinerInputNV(	GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_D_NV, GL_TEXTURE3_ARB,
						GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	
	glCombinerOutputNV(	GL_COMBINER1_NV, GL_RGB, GL_SPARE1_NV, GL_SPARE0_NV, GL_DISCARD_NV,
						GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);


	//combiner 2 does	spare1.rgb * spare1.rgb -> spare1.rgb
	glCombinerInputNV(	GL_COMBINER2_NV, GL_RGB, GL_VARIABLE_A_NV, GL_SPARE1_NV,
						GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glCombinerInputNV(	GL_COMBINER2_NV, GL_RGB, GL_VARIABLE_B_NV, GL_SPARE1_NV,
						GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	
	glCombinerOutputNV(	GL_COMBINER2_NV, GL_RGB, GL_SPARE1_NV, GL_DISCARD_NV, GL_DISCARD_NV,
						GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);

	//combiner 3 does	spare1.rgb * spare1.rgb -> spare1.rgb
	glCombinerInputNV(	GL_COMBINER3_NV, GL_RGB, GL_VARIABLE_A_NV, GL_SPARE1_NV,
						GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glCombinerInputNV(	GL_COMBINER3_NV, GL_RGB, GL_VARIABLE_B_NV, GL_SPARE1_NV,
						GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	
	glCombinerOutputNV(	GL_COMBINER3_NV, GL_RGB, GL_SPARE1_NV, GL_DISCARD_NV, GL_DISCARD_NV,
						GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);

	//final combiner outputs spare1.rgb*spare1.rgb*tex0.a+spare0.rgb
	//First do spare1.rgb*spare1.rgb in EF multiplier
	glFinalCombinerInputNV(GL_VARIABLE_E_NV, GL_SPARE1_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glFinalCombinerInputNV(GL_VARIABLE_F_NV, GL_SPARE1_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	
	//Now do rest
	glFinalCombinerInputNV(GL_VARIABLE_A_NV, GL_E_TIMES_F_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_TEXTURE0_ARB, GL_UNSIGNED_IDENTITY_NV, GL_ALPHA);
	glFinalCombinerInputNV(GL_VARIABLE_C_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glFinalCombinerInputNV(GL_VARIABLE_D_NV, GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);

	glEnable(GL_REGISTER_COMBINERS_NV);
	
	
	//Set up vertex program
	glEnable(GL_VERTEX_PROGRAM_NV);
	glBindProgramNV(GL_VERTEX_PROGRAM_NV, singlePassVertexProgram);
}