Oxygen Engine
Modern C++ 3D Engine using OpenGL
Loading...
Searching...
No Matches
surface_shader.h
1#ifndef OE_RENDER_SURFACE_SHADER_H
2#define OE_RENDER_SURFACE_SHADER_H
3
4#include <string>
5#include <glm/mat4x4.hpp>
6
7#include "shader_base.h"
8
9namespace oe::render
10{
16 struct SurfaceShader : public ShaderBase
17 {
24 SurfaceShader(const std::string& source_code, const std::string& name = "");
25
33 void setDepthFunctionName(const std::string& name)
34 {
35 define("SHADER_DEPTH_ENTRYPOINT", name);
36 }
37 };
38
39 static constexpr const char* surface_shader_headers = R"(
40 // Input surface option
41 struct SurfaceInput
42 {
43 vec2 tex_coords_0;
44 vec2 tex_coords_1;
45 vec3 color;
46 };
47
48 // Result surface option
49 struct SurfaceOutput
50 {
51 vec4 albedo;
52 vec3 emissive;
53 vec3 normal;
54
55 float roughness;
56 float metalness;
57 float ao;
58
59 // These following 3 are only for refractive surfaces
60 float ior;
61 float transmission;
62 float thickness;
63
64 bool use_pbr;
65 };
66
67 #define RENDER_PASS_DEPTH 1
68 #define RENDER_PASS_FORWARD 2
69 #define RENDER_PASS_DEFERRED 3
70
71 #define GEOMETRY_PASS_SOLID 1
72 #define GEOMETRY_PASS_SKINNED 2
73
74 // Read a normal texture and extract a normal
75 vec3 OE_UNPACK_NORMAL_MAP(sampler2D TEX, vec2 TEX_COORDS);
76
77 // Convert color stored into sRGB into linear
78 vec3 OE_CONVERT_SRGB_TO_LINEAR(vec3 X);
79
80 // Surface shaders should implement this function
81 void surface(in SurfaceInput surface_input, inout SurfaceOutput result);
82 )";
83}
84
85#endif
ShaderBase(const std::string &name="")
Create a new shader instance.
void define(const std::string &name, const T &value)
Define a shader constant.
Definition shader_base.h:69
Render related abstractions (Shader, Framebuffer, Cubemaps, Textures).
Definition opengl.h:12
void setDepthFunctionName(const std::string &name)
Set a custom function to use for getting alpha.
Definition surface_shader.h:33
SurfaceShader(const std::string &source_code, const std::string &name="")
Create a new shader instance.