litp - Light coefficients

litp - Light coefficients

Calling Format

litp    dest, src

Operands

Name Registers
dest An output register or temporary register.
src A temporary register, input register, or floating-point constant register.

Overview

Runs some lighting calculations.
This instruction determines the sign of the product of the normal and light vectors and that of the normal and half vectors required by the vertex shader to perform lighting. It also clamps the specular coefficient, which is equivalent to the value specified by GL_SHININESS for the material color in OpenGL ES1.1.

If called with the dot product of the normal and light vector stored in src.x, the specular coefficient stored in src.y, and the dot project of the normal and half vector stored in src.w, then parameters that aid in calculating specular lighting will be stored in dest and the status register.

Status registers are also simultaneously changed by this instruction.
If src.x is larger than 0, status register 0 is set to 1. If src.w is larger than 0, status register 1 is set to 1.
After this instruction is called, if a branch instruction, such as ifc, determines that both status registers are set to 1, it is assumed a power calculation will be made.

Operation

dest.x = ( src.x < 0 ) ? 0 : src.x
dest.y = ( src.y < -127.9961 ) ? -127.9961 : ( src.y > 127.9961 ? 127.9961 : src.y )
dest.z = 0
dest.w = ( src.w < 0 ) ? 0 : src.w
status_reg0 = ( src.x > 0 ) ? 1 : 0
status_reg1 = ( src.w > 0 ) ? 1 : 0

Code Example

// r0.x : Stores the dot product of the normal and light vectors.
// r0.y : Stores the specular coefficient.
// r0.z : This value is not used.
// r0.w : Stores the dot product of the normal and half vectors.

litp    r1, r0
ifc     1, 1, 1             // if ( N*H > 0 && N*L > 0 )
  pow     r2.x, r1.w, r1.y  // r2.x = power ( r1.w , r1.y );
endif

Timetable

12345
litp read MAX MIN post write
CMP

Revision History

2011/12/20
Initial version.

CONFIDENTIAL