R2 Shaders
Functions
R2EnvironmentReflection.h File Reference

Functions for environment-mapped reflections. More...

#include "R2CubeMaps.h"
Include dependency graph for R2EnvironmentReflection.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

vec4 R2_environmentReflection (const samplerCube t, const vec3 v_eye, const vec3 n_eye, const mat4x4 view_inv)
 

Detailed Description

Functions for environment-mapped reflections.

Definition in file R2EnvironmentReflection.h.

Function Documentation

§ R2_environmentReflection()

vec4 R2_environmentReflection ( const samplerCube  t,
const vec3  v_eye,
const vec3  n_eye,
const mat4x4  view_inv 
)

Calculate a reflection based on the eye-space view direction v_eye and eye-space surface normal n_eye. The reflection vector is transformed to world-space using the inverse view transform view_inv and sampled from the right-handed cube map t.

Parameters
tA right-handed cube map
v_eyeAn eye-space view direction
n_eyeAn eye-space surface normal
view_invAn eye-space-to-world-space matrix

Definition at line 24 of file R2EnvironmentReflection.h.

29 {
30  vec3 v_eye_n = normalize (v_eye);
31  vec3 n_eye_n = normalize (n_eye);
32  vec3 r = reflect (v_eye_n, n_eye_n);
33  vec4 r_world = view_inv * vec4 (r, 0.0);
34  return R2_cubeMapTextureRH (t, r_world.xyz);
35 }
vec4 R2_cubeMapTextureRH(const samplerCube t, const vec3 v)
Definition: R2CubeMaps.h:15