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 "../common.h"
5
6#include <vector>
7#include <string>
8#include <map>
9#include <unordered_map>
10#include <glm/mat4x4.hpp>
11
12#include "shader_base.h"
13
14namespace oe::render
15{
22 {
23 public:
30 SurfaceShader(const std::string& source_code, const std::string& name = "");
31
39 void setDepthFunctionName(const std::string& name)
40 {
41 define("SHADER_DEPTH_ENTRYPOINT", name);
42 }
43 };
44
45 static constexpr const char* surface_shader_headers = R"(
46 // Input surface option
47 struct SurfaceInput
48 {
49 vec2 texCoords;
50 vec2 lmCoords;
51 };
52
53 // Result surface option
54 struct SurfaceOutput
55 {
56 vec4 albedo;
57 vec3 emissive;
58 vec3 normal;
59
60 float roughness;
61 float metalness;
62 float ao;
63
64 // These following 3 are only for refractive surfaces
65 float ior;
66 float transmission;
67 float thickness;
68
69 bool use_pbr;
70 };
71
72 #define RENDER_PASS_DEPTH 1
73 #define RENDER_PASS_DEFERRED 2
74 #define RENDER_PASS_FORWARD 3
75
76 #define GEOMETRY_PASS_SOLID 1
77 #define GEOMETRY_PASS_SKINNED 2
78
79 // Read a normal texture and extract a normal
80 vec3 OE_UNPACK_NORMAL_MAP(sampler2D TEX, vec2 TEX_COORDS);
81
82 // Convert color stored into sRGB into linear
83 vec3 OE_CONVERT_SRGB_TO_LINEAR(vec3 X);
84
85 // Surface shaders should implement this function
86 void surface(in SurfaceInput surface_input, inout SurfaceOutput result);
87 )";
88}
89
90#endif
Shader class.
Definition shader_base.h:33
void define(const std::string &name, const T &value)
Define a shader constant.
Definition shader_base.h:55
Surface Shader class.
Definition surface_shader.h:22
void setDepthFunctionName(const std::string &name)
Set a custom function to use for getting alpha.
Definition surface_shader.h:39
SurfaceShader(const std::string &source_code, const std::string &name="")
Create a new shader instance.
Render related abstractions (Shader, Framebuffer, Cubemaps, Textures)
Definition opengl.h:10