R2 Core Shaders
Functions | Variables
R2SurfaceBasicStippled.h File Reference

Basic surface implementation. More...

#include "R2SurfaceShaderMain.h"
#include "R2SurfaceBasicTypes.h"
#include "R2Viewport.h"
#include "R2Stipple.h"
Include dependency graph for R2SurfaceBasicStippled.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

R2_surface_output_t R2_deferredSurfaceMain (const R2_vertex_data_t data, const R2_surface_derived_t derived, const R2_surface_textures_t textures, const R2_view_t view, const R2_surface_matrices_instance_t matrices_instance)
 

Variables

uniform R2_basic_surface_textures_t R2_basic_surface_textures
 
uniform R2_basic_surface_parameters_t R2_basic_surface_parameters
 
uniform R2_stipple_t R2_stipple
 
uniform R2_viewport_t R2_viewport
 

Detailed Description

Basic surface implementation.

Definition in file R2SurfaceBasicStippled.h.

Function Documentation

§ R2_deferredSurfaceMain()

R2_surface_output_t R2_deferredSurfaceMain ( const R2_vertex_data_t  data,
const R2_surface_derived_t  derived,
const R2_surface_textures_t  textures,
const R2_view_t  view,
const R2_surface_matrices_instance_t  matrices_instance 
)

Calculate surface values for the current surface. Implementations of this function are expected to calculate a description of the current surface. The description is encoded into the G-buffer by the caller.

Parameters
dataSurface data (typically coming from a vertex)
derivedSurface data calculated from the original vertex
texturesTextures that are required by all surfaces
viewMatrices and parameters related to the current view
matrices_instanceMatrices related to the instance to which this surface belongs
Returns
Calculated surface values

Definition at line 19 of file R2SurfaceBasicStippled.h.

25 {
26  vec4 albedo_sample =
27  texture (R2_basic_surface_textures.albedo, data.uv);
28  vec4 surface =
29  mix (R2_basic_surface_parameters.albedo_color,
30  albedo_sample,
31  R2_basic_surface_parameters.albedo_mix * albedo_sample.w);
32 
33  float emission_sample =
34  texture (R2_basic_surface_textures.emission, data.uv).x;
35  float emission =
36  R2_basic_surface_parameters.emission_amount * emission_sample;
37 
38  vec3 specular_sample =
39  texture (R2_basic_surface_textures.specular, data.uv).xyz;
40  vec3 specular =
41  specular_sample * R2_basic_surface_parameters.specular_color;
42 
43  bool discarded =
44  R2_stippleRun(R2_stipple, R2_viewport, gl_FragCoord.xy)
45  || surface.w < R2_basic_surface_parameters.alpha_discard_threshold;
46 
47  return R2_surface_output_t (
48  surface.xyz,
49  emission,
50  derived.normal_bumped,
51  specular,
52  R2_basic_surface_parameters.specular_exponent,
53  discarded
54  );
55 }
float emission_amount
Emission level in the range [0, 1]
vec2 uv
Object-space UV.
vec3 normal_bumped
Final uncompressed eye-space normal produced by bump/normal mapping.
vec3 specular_color
RGB specular color.
sampler2D emission
R emission level texture.
vec4 albedo_color
Base RGBA albedo color.
sampler2D albedo
RGBA albedo texture.
float specular_exponent
Specular exponent in the range [0, 256]
The type of surface details that all deferred surface shaders are required to calculate.
float albedo_mix
Albedo color/texture mix.
float alpha_discard_threshold
Alpha discard threshold in the range [0, 1].
sampler2D specular
RGB specular map texture.