First working example
This commit is contained in:
@ -93,6 +93,8 @@ void RenderPipeline::init() {
|
|||||||
// 0.0f
|
// 0.0f
|
||||||
// );
|
// );
|
||||||
// glyphMesh.draw(MESH_DRAW_MODE_TRIANGLES, 0, -1);
|
// glyphMesh.draw(MESH_DRAW_MODE_TRIANGLES, 0, -1);
|
||||||
|
|
||||||
|
this->shaderBuffer.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPipeline::render() {
|
void RenderPipeline::render() {
|
||||||
@ -167,6 +169,11 @@ void RenderPipeline::renderSceneCamera(Scene *scene, Camera *camera) {
|
|||||||
assertNotNull(renderTarget);
|
assertNotNull(renderTarget);
|
||||||
|
|
||||||
// Update shader parameter buffers with current knowledge
|
// Update shader parameter buffers with current knowledge
|
||||||
|
struct RenderPipelineShaderBufferData shaderBufferData;
|
||||||
|
shaderBufferData.projection = camera->getProjection();
|
||||||
|
shaderBufferData.view = camera->transform->getWorldTransform();
|
||||||
|
this->shaderBuffer.buffer(&shaderBufferData);
|
||||||
|
|
||||||
this->camera = camera;
|
this->camera = camera;
|
||||||
|
|
||||||
// Get the list of things to render first.
|
// Get the list of things to render first.
|
||||||
@ -219,6 +226,9 @@ void RenderPipeline::renderSceneCamera(Scene *scene, Camera *camera) {
|
|||||||
// Now we've sorted everything! Let's actually start rendering.
|
// Now we've sorted everything! Let's actually start rendering.
|
||||||
Shader *boundShader = nullptr;
|
Shader *boundShader = nullptr;
|
||||||
std::map<textureslot_t, Texture*> boundTextures;
|
std::map<textureslot_t, Texture*> boundTextures;
|
||||||
|
std::map<shaderbufferlocation_t, shaderbufferslot_t> locationSlotMap;
|
||||||
|
std::map<IShaderParameterBuffer<shaderbufferlocation_t>*, shaderbufferslot_t> bufferSlotMap;
|
||||||
|
shaderbufferslot_t globalSlot = 0;
|
||||||
|
|
||||||
// TODO: This will be editable!
|
// TODO: This will be editable!
|
||||||
renderTarget->bind();
|
renderTarget->bind();
|
||||||
@ -251,6 +261,29 @@ void RenderPipeline::renderSceneCamera(Scene *scene, Camera *camera) {
|
|||||||
++itTextureSlot;
|
++itTextureSlot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bind the buffers to their slots
|
||||||
|
auto itBufferSlot = item.parameterBuffers.begin();
|
||||||
|
while(itBufferSlot != item.parameterBuffers.end()) {
|
||||||
|
// First check if buffer is already bound
|
||||||
|
auto location = itBufferSlot->first;
|
||||||
|
auto buff = itBufferSlot->second;
|
||||||
|
// auto existingBind = bufferSlotMap.find(buff);
|
||||||
|
shaderbufferslot_t slot;
|
||||||
|
|
||||||
|
// if(existingBind == bufferSlotMap.end()) {
|
||||||
|
// Not bound, let's find a slot we can use!
|
||||||
|
// slot = -1;
|
||||||
|
slot = globalSlot++;
|
||||||
|
// } else {
|
||||||
|
// // Already bound
|
||||||
|
// slot = existingBind->second;
|
||||||
|
// }
|
||||||
|
|
||||||
|
buff->bind(slot);
|
||||||
|
locationSlotMap[itBufferSlot->first] = slot;
|
||||||
|
++itBufferSlot;
|
||||||
|
}
|
||||||
|
|
||||||
// Now set each of the parameters. Nothing exciting here.
|
// Now set each of the parameters. Nothing exciting here.
|
||||||
auto itColors = item.colorValues.begin();
|
auto itColors = item.colorValues.begin();
|
||||||
while(itColors != item.colorValues.end()) {
|
while(itColors != item.colorValues.end()) {
|
||||||
@ -282,6 +315,12 @@ void RenderPipeline::renderSceneCamera(Scene *scene, Camera *camera) {
|
|||||||
++itText;
|
++itText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto itBuffer = item.parameterBuffers.begin();
|
||||||
|
while(itBuffer != item.parameterBuffers.end()) {
|
||||||
|
item.shader->setParameterBuffer(itBuffer->first, locationSlotMap[itBuffer->first]);
|
||||||
|
++itBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
auto itFloat = item.floatValues.begin();
|
auto itFloat = item.floatValues.begin();
|
||||||
while(itFloat != item.floatValues.end()) {
|
while(itFloat != item.floatValues.end()) {
|
||||||
item.shader->setFloat(itFloat->first, itFloat->second);
|
item.shader->setFloat(itFloat->first, itFloat->second);
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "scene/components/scene/SubSceneController.hpp"
|
#include "scene/components/scene/SubSceneController.hpp"
|
||||||
#include "scene/components/ui/UIComponent.hpp"
|
#include "scene/components/ui/UIComponent.hpp"
|
||||||
#include "display/shader/ShaderPass.hpp"
|
#include "display/shader/ShaderPass.hpp"
|
||||||
|
#include "display/shader/buffers/RenderPipelineShaderBuffer.hpp"
|
||||||
|
|
||||||
namespace Dawn {
|
namespace Dawn {
|
||||||
class RenderManager;
|
class RenderManager;
|
||||||
@ -23,6 +24,7 @@ namespace Dawn {
|
|||||||
|
|
||||||
// Temporary hack
|
// Temporary hack
|
||||||
Camera *camera = nullptr;
|
Camera *camera = nullptr;
|
||||||
|
RenderPipelineShaderBuffer shaderBuffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new RenderPipeline. Render Pipelines are my attempt to
|
* Constructs a new RenderPipeline. Render Pipelines are my attempt to
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "display/shader/Shader.hpp"
|
#include "display/shader/Shader.hpp"
|
||||||
#include "display/mesh/Mesh.hpp"
|
#include "display/mesh/Mesh.hpp"
|
||||||
|
#include "display/shader/ShaderParameterBuffer.hpp"
|
||||||
|
|
||||||
namespace Dawn {
|
namespace Dawn {
|
||||||
struct ShaderPassItem {
|
struct ShaderPassItem {
|
||||||
@ -26,6 +27,7 @@ namespace Dawn {
|
|||||||
std::map<shaderparameter_t, glm::vec3> vec3Values;
|
std::map<shaderparameter_t, glm::vec3> vec3Values;
|
||||||
std::map<shaderparameter_t, textureslot_t> textureValues;
|
std::map<shaderparameter_t, textureslot_t> textureValues;
|
||||||
std::map<shaderparameter_t, float_t> floatValues;
|
std::map<shaderparameter_t, float_t> floatValues;
|
||||||
|
std::map<shaderbufferlocation_t, IShaderParameterBuffer<shaderbufferslot_t>*> parameterBuffers;
|
||||||
|
|
||||||
// Textures
|
// Textures
|
||||||
std::map<textureslot_t, Texture*> textureSlots;
|
std::map<textureslot_t, Texture*> textureSlots;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "dawnlibs.hpp"
|
#include "dawnlibs.hpp"
|
||||||
|
|
||||||
namespace Dawn {
|
namespace Dawn {
|
||||||
template<typename T, typename L>
|
template<typename L>
|
||||||
class IShaderParameterBuffer {
|
class IShaderParameterBuffer {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@ -15,14 +15,6 @@ namespace Dawn {
|
|||||||
*/
|
*/
|
||||||
virtual void init() = 0;
|
virtual void init() = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic buffer method. Buffers the entire contents of the data struct to
|
|
||||||
* this shader parameter buffer.
|
|
||||||
*
|
|
||||||
* @param data Data to buffer to the parameter.
|
|
||||||
*/
|
|
||||||
virtual void buffer(T *data) = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bind this shader buffer to the supplied location.
|
* Bind this shader buffer to the supplied location.
|
||||||
*
|
*
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
// https://opensource.org/licenses/MIT
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
#include "SceneDebugLine.hpp"
|
#include "SceneDebugLine.hpp"
|
||||||
#include "display/shader/SimpleTexturedShader.hpp"
|
#include "display/shader/shaders/SimpleTexturedShader.hpp"
|
||||||
#include "scene/components/display/Camera.hpp"
|
#include "scene/components/display/Camera.hpp"
|
||||||
#include "scene/Scene.hpp"
|
#include "scene/Scene.hpp"
|
||||||
#include "scene/components/physics/3d/Collider3D.hpp"
|
#include "scene/components/physics/3d/Collider3D.hpp"
|
||||||
|
@ -27,33 +27,33 @@ namespace Dawn {
|
|||||||
camera = Camera::create(this);
|
camera = Camera::create(this);
|
||||||
camera->transform->lookAt(glm::vec3(3, 3, 3), glm::vec3(0, 0, 0));
|
camera->transform->lookAt(glm::vec3(3, 3, 3), glm::vec3(0, 0, 0));
|
||||||
|
|
||||||
// cube = SimpleSpinningCubePrefab::create(this);
|
cube = SimpleSpinningCubePrefab::create(this);
|
||||||
|
|
||||||
item = this->createSceneItem();
|
// item = this->createSceneItem();
|
||||||
auto meshRenderer = item->addComponent<MeshRenderer>();
|
// auto meshRenderer = item->addComponent<MeshRenderer>();
|
||||||
auto quadMeshHost = item->addComponent<QuadMeshHost>();
|
// auto quadMeshHost = item->addComponent<QuadMeshHost>();
|
||||||
auto material = item->addComponent<SimpleTexturedMaterial>();
|
// auto material = item->addComponent<SimpleTexturedMaterial>();
|
||||||
|
|
||||||
if(FT_New_Face(
|
// if(FT_New_Face(
|
||||||
this->game->renderManager.getFontManager()->fontLibrary,
|
// this->game->renderManager.getFontManager()->fontLibrary,
|
||||||
"C:\\Windows\\Fonts\\Arial.ttf",
|
// "C:\\Windows\\Fonts\\Arial.ttf",
|
||||||
0,
|
// 0,
|
||||||
&face
|
// &face
|
||||||
)) {
|
// )) {
|
||||||
assertUnreachable();
|
// assertUnreachable();
|
||||||
}
|
// }
|
||||||
if(FT_Set_Pixel_Sizes(face, 0, 16)) {
|
// if(FT_Set_Pixel_Sizes(face, 0, 16)) {
|
||||||
assertUnreachable();
|
// assertUnreachable();
|
||||||
}
|
// }
|
||||||
|
|
||||||
_newTrueTypePlaceholder(face, texture, charStore);
|
// _newTrueTypePlaceholder(face, texture, charStore);
|
||||||
FT_ULong c = 'B';
|
// FT_ULong c = 'B';
|
||||||
auto x = charStore[c];
|
// auto x = charStore[c];
|
||||||
glm::vec2 wh = glm::vec2(texture.getWidth(), texture.getHeight());
|
// glm::vec2 wh = glm::vec2(texture.getWidth(), texture.getHeight());
|
||||||
quadMeshHost->uv0 = glm::vec2(0.0f, x.textureY) / wh;
|
// quadMeshHost->uv0 = glm::vec2(0.0f, x.textureY) / wh;
|
||||||
quadMeshHost->uv1 = (glm::vec2)quadMeshHost->uv0 + (x.bitmapSize / wh);
|
// quadMeshHost->uv1 = (glm::vec2)quadMeshHost->uv0 + (x.bitmapSize / wh);
|
||||||
std::cout << "Done" << std::endl;
|
// std::cout << "Done" << std::endl;
|
||||||
material->texture = &texture;
|
// material->texture = &texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Asset*> getRequiredAssets() override {
|
std::vector<Asset*> getRequiredAssets() override {
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
#include "display/_RenderManager.hpp"
|
#include "display/_RenderManager.hpp"
|
||||||
#include "display/BackBufferRenderTarget.hpp"
|
#include "display/BackBufferRenderTarget.hpp"
|
||||||
#include "display/shader/ShaderManager.hpp"
|
#include "display/shader/ShaderManager.hpp"
|
||||||
#include "display/shader/SimpleTexturedShader.hpp"
|
#include "display/shader/shaders/SimpleTexturedShader.hpp"
|
||||||
#include "display/shader/FontShader.hpp"
|
#include "display/shader/shaders/FontShader.hpp"
|
||||||
#include "display/shader/UIShader.hpp"
|
#include "display/shader/shaders/UIShader.hpp"
|
||||||
#include "display/RenderPipeline.hpp"
|
#include "display/RenderPipeline.hpp"
|
||||||
#include "display/font/FontManager.hpp"
|
#include "display/font/FontManager.hpp"
|
||||||
#include "display/font/ExampleFont.hpp"
|
#include "display/font/ExampleFont.hpp"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
target_sources(${DAWN_TARGET_NAME}
|
target_sources(${DAWN_TARGET_NAME}
|
||||||
PRIVATE
|
PRIVATE
|
||||||
Shader.cpp
|
Shader.cpp
|
||||||
FontShader.cpp
|
)
|
||||||
SimpleTexturedShader.cpp
|
|
||||||
SimpleBillboardedShader.cpp
|
add_subdirectory(buffers)
|
||||||
)
|
add_subdirectory(shaders)
|
@ -13,7 +13,7 @@ namespace Dawn {
|
|||||||
typedef GLuint shaderbufferlocation_t;
|
typedef GLuint shaderbufferlocation_t;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class ShaderParameterBuffer : public IShaderParameterBuffer<T, shaderbufferslot_t> {
|
class ShaderParameterBuffer : public IShaderParameterBuffer<shaderbufferslot_t> {
|
||||||
protected:
|
protected:
|
||||||
shaderbufferlocation_t id = -1;
|
shaderbufferlocation_t id = -1;
|
||||||
size_t size;
|
size_t size;
|
||||||
@ -29,7 +29,14 @@ namespace Dawn {
|
|||||||
glBufferData(GL_UNIFORM_BUFFER, this->size, NULL, GL_DYNAMIC_DRAW);
|
glBufferData(GL_UNIFORM_BUFFER, this->size, NULL, GL_DYNAMIC_DRAW);
|
||||||
}
|
}
|
||||||
|
|
||||||
void buffer(T *data) override {
|
/**
|
||||||
|
* Basic buffer method. Buffers the entire contents of the data struct to
|
||||||
|
* this shader parameter buffer.
|
||||||
|
*
|
||||||
|
* @param data Data to buffer to the parameter.
|
||||||
|
*/
|
||||||
|
void buffer(T *data) {
|
||||||
|
this->bind(0);
|
||||||
this->bufferRaw((void*)data);
|
this->bufferRaw((void*)data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
9
src/dawnopengl/display/shader/buffers/CMakeLists.txt
Normal file
9
src/dawnopengl/display/shader/buffers/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Copyright (c) 2023 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Sources
|
||||||
|
target_sources(${DAWN_TARGET_NAME}
|
||||||
|
PRIVATE
|
||||||
|
)
|
@ -0,0 +1,30 @@
|
|||||||
|
// Copyright (c) 2023 Dominic Masters
|
||||||
|
//
|
||||||
|
// This software is released under the MIT License.
|
||||||
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "display/shader/ShaderParameterBuffer.hpp"
|
||||||
|
|
||||||
|
namespace Dawn {
|
||||||
|
struct RenderPipelineShaderBufferData {
|
||||||
|
glm::mat4 view;
|
||||||
|
glm::mat4 projection;
|
||||||
|
};
|
||||||
|
|
||||||
|
class RenderPipelineShaderBuffer : public ShaderParameterBuffer<struct RenderPipelineShaderBufferData> {
|
||||||
|
public:
|
||||||
|
static std::string getShaderUniformName() {
|
||||||
|
return "ub_RenderPipeline";
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string getShaderUniform() {
|
||||||
|
return std::string(
|
||||||
|
"layout (std140) uniform ub_RenderPipeline {\n"
|
||||||
|
"mat4 u_View;\n"
|
||||||
|
"mat4 u_Projection;\n"
|
||||||
|
"};"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
12
src/dawnopengl/display/shader/shaders/CMakeLists.txt
Normal file
12
src/dawnopengl/display/shader/shaders/CMakeLists.txt
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# Copyright (c) 2023 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Sources
|
||||||
|
target_sources(${DAWN_TARGET_NAME}
|
||||||
|
PRIVATE
|
||||||
|
FontShader.cpp
|
||||||
|
SimpleTexturedShader.cpp
|
||||||
|
SimpleBillboardedShader.cpp
|
||||||
|
)
|
@ -1,96 +1,98 @@
|
|||||||
// Copyright (c) 2023 Dominic Masters
|
// Copyright (c) 2023 Dominic Masters
|
||||||
//
|
//
|
||||||
// This software is released under the MIT License.
|
// This software is released under the MIT License.
|
||||||
// https://opensource.org/licenses/MIT
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
#include "SimpleTexturedShader.hpp"
|
#include "SimpleTexturedShader.hpp"
|
||||||
|
|
||||||
using namespace Dawn;
|
using namespace Dawn;
|
||||||
|
|
||||||
void SimpleTexturedShader::compile() {
|
void SimpleTexturedShader::compile() {
|
||||||
#if DAWN_OPENGL_GLSL
|
#if DAWN_OPENGL_GLSL
|
||||||
this->compileShader(
|
this->compileShader(
|
||||||
{
|
{
|
||||||
{ "aPos", 0 },
|
{ "aPos", 0 },
|
||||||
{ "aTexCoord", 1 }
|
{ "aTexCoord", 1 }
|
||||||
},
|
},
|
||||||
// Vertex Shader
|
// Vertex Shader
|
||||||
"#version 330 core\n"
|
"#version 330 core\n"
|
||||||
"layout (location = 0) in vec3 aPos;\n"
|
"layout (location = 0) in vec3 aPos;\n"
|
||||||
"layout (location = 1) in vec2 aTexCoord;\n"
|
"layout (location = 1) in vec2 aTexCoord;\n" +
|
||||||
|
|
||||||
"uniform mat4 u_Proj;\n"
|
RenderPipelineShaderBuffer::getShaderUniform() + ""
|
||||||
"uniform mat4 u_View;\n"
|
|
||||||
"uniform mat4 u_Model;\n"
|
// "uniform mat4 u_Proj;\n"
|
||||||
|
// "uniform mat4 u_View;\n"
|
||||||
"out vec2 o_TextCoord;\n"
|
"uniform mat4 u_Model;\n"
|
||||||
"void main() {\n"
|
|
||||||
"gl_Position = u_Proj * u_View * u_Model * vec4(aPos, 1.0);\n"
|
"out vec2 o_TextCoord;\n"
|
||||||
"o_TextCoord = vec2(aTexCoord.x, aTexCoord.y);\n"
|
"void main() {\n"
|
||||||
"}",
|
"gl_Position = u_Projection * u_View * u_Model * vec4(aPos, 1.0);\n"
|
||||||
|
"o_TextCoord = vec2(aTexCoord.x, aTexCoord.y);\n"
|
||||||
// Fragment Shader
|
"}",
|
||||||
"#version 330 core\n"
|
|
||||||
|
// Fragment Shader
|
||||||
"in vec2 o_TextCoord;\n"
|
"#version 330 core\n"
|
||||||
"out vec4 o_Color;\n"
|
|
||||||
"uniform vec4 u_Color;\n"
|
"in vec2 o_TextCoord;\n"
|
||||||
"uniform bool u_HasTexture;\n"
|
"out vec4 o_Color;\n"
|
||||||
"uniform sampler2D u_Text;\n"
|
"uniform vec4 u_Color;\n"
|
||||||
|
"uniform bool u_HasTexture;\n"
|
||||||
"void main() {\n"
|
"uniform sampler2D u_Text;\n"
|
||||||
"if(u_HasTexture) {\n"
|
|
||||||
"o_Color = texture(u_Text, o_TextCoord) * u_Color;\n"
|
"void main() {\n"
|
||||||
"} else {\n"
|
"if(u_HasTexture) {\n"
|
||||||
"o_Color = u_Color;"
|
"o_Color = texture(u_Text, o_TextCoord) * u_Color;\n"
|
||||||
"}\n"
|
"} else {\n"
|
||||||
"}\n"
|
"o_Color = u_Color;"
|
||||||
);
|
"}\n"
|
||||||
#elif DAWN_OPENGL_HLSL
|
"}\n"
|
||||||
this->compileShader(
|
);
|
||||||
{
|
#elif DAWN_OPENGL_HLSL
|
||||||
{ "aPos", 0 },
|
this->compileShader(
|
||||||
{ "aTexCoord", 1 }
|
{
|
||||||
},
|
{ "aPos", 0 },
|
||||||
// Vertex Shader
|
{ "aTexCoord", 1 }
|
||||||
"uniform float4x4 u_Proj;\n"
|
},
|
||||||
"uniform float4x4 u_View;\n"
|
// Vertex Shader
|
||||||
"uniform float4x4 u_Model;\n"
|
"uniform float4x4 u_Proj;\n"
|
||||||
"void main("
|
"uniform float4x4 u_View;\n"
|
||||||
"float3 aPos,\n"
|
"uniform float4x4 u_Model;\n"
|
||||||
"float2 aTexCoord,\n"
|
"void main("
|
||||||
"float2 out o_TextCoord : TEXCOORD0,\n"
|
"float3 aPos,\n"
|
||||||
"float4 out gl_Position : POSITION\n"
|
"float2 aTexCoord,\n"
|
||||||
") {\n"
|
"float2 out o_TextCoord : TEXCOORD0,\n"
|
||||||
"o_TextCoord = aTexCoord;\n"
|
"float4 out gl_Position : POSITION\n"
|
||||||
"gl_Position = mul(mul(mul(float4(aPos, 1.0), u_Model), u_View), u_Proj);\n"
|
") {\n"
|
||||||
"}",
|
"o_TextCoord = aTexCoord;\n"
|
||||||
|
"gl_Position = mul(mul(mul(float4(aPos, 1.0), u_Model), u_View), u_Proj);\n"
|
||||||
// Fragment Shader
|
"}",
|
||||||
"uniform float4 u_Color;\n"
|
|
||||||
"uniform bool u_HasTexture;\n"
|
// Fragment Shader
|
||||||
"uniform sampler2D u_Text : TEXUNIT0;\n"
|
"uniform float4 u_Color;\n"
|
||||||
|
"uniform bool u_HasTexture;\n"
|
||||||
"float4 main(\n"
|
"uniform sampler2D u_Text : TEXUNIT0;\n"
|
||||||
"float2 o_TextCoord : TEXCOORD0\n"
|
|
||||||
") {\n"
|
"float4 main(\n"
|
||||||
"float4 o_Color;\n"
|
"float2 o_TextCoord : TEXCOORD0\n"
|
||||||
"if(u_HasTexture) {\n"
|
") {\n"
|
||||||
"o_Color = mul(tex2D(u_Text, o_TextCoord), u_Color);\n"
|
"float4 o_Color;\n"
|
||||||
"} else {\n"
|
"if(u_HasTexture) {\n"
|
||||||
"o_Color = u_Color;\n"
|
"o_Color = mul(tex2D(u_Text, o_TextCoord), u_Color);\n"
|
||||||
"}\n"
|
"} else {\n"
|
||||||
"return o_Color;\n"
|
"o_Color = u_Color;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
);
|
"return o_Color;\n"
|
||||||
#else
|
"}\n"
|
||||||
#error Shader Type must be either GLSL or HLSL
|
);
|
||||||
#endif
|
#else
|
||||||
|
#error Shader Type must be either GLSL or HLSL
|
||||||
this->paramProjection = this->getParameterByName("u_Proj");
|
#endif
|
||||||
this->paramView = this->getParameterByName("u_View");
|
|
||||||
this->paramModel = this->getParameterByName("u_Model");
|
this->paramModel = this->getParameterByName("u_Model");
|
||||||
this->paramColor = this->getParameterByName("u_Color");
|
this->paramColor = this->getParameterByName("u_Color");
|
||||||
this->paramTexture = this->getParameterByName("u_Text");
|
this->paramTexture = this->getParameterByName("u_Text");
|
||||||
this->paramHasTexture = this->getParameterByName("u_HasTexture");
|
this->paramHasTexture = this->getParameterByName("u_HasTexture");
|
||||||
|
|
||||||
|
this->bufferRenderPipeline = this->getBufferLocationByName(RenderPipelineShaderBuffer::getShaderUniformName());
|
||||||
}
|
}
|
@ -1,21 +1,24 @@
|
|||||||
// Copyright (c) 2023 Dominic Masters
|
// Copyright (c) 2023 Dominic Masters
|
||||||
//
|
//
|
||||||
// This software is released under the MIT License.
|
// This software is released under the MIT License.
|
||||||
// https://opensource.org/licenses/MIT
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "display/shader/Shader.hpp"
|
#include "display/shader/buffers/RenderPipelineShaderBuffer.hpp"
|
||||||
|
#include "display/shader/Shader.hpp"
|
||||||
namespace Dawn {
|
|
||||||
class SimpleTexturedShader : public Shader {
|
namespace Dawn {
|
||||||
public:
|
class SimpleTexturedShader : public Shader {
|
||||||
shaderparameter_t paramProjection;
|
public:
|
||||||
shaderparameter_t paramView;
|
shaderparameter_t paramProjection;
|
||||||
shaderparameter_t paramModel;
|
shaderparameter_t paramView;
|
||||||
shaderparameter_t paramColor;
|
|
||||||
shaderparameter_t paramTexture;
|
shaderparameter_t paramModel;
|
||||||
shaderparameter_t paramHasTexture;
|
shaderparameter_t paramColor;
|
||||||
|
shaderparameter_t paramTexture;
|
||||||
void compile() override;
|
shaderparameter_t paramHasTexture;
|
||||||
};
|
shaderbufferlocation_t bufferRenderPipeline;
|
||||||
|
|
||||||
|
void compile() override;
|
||||||
|
};
|
||||||
}
|
}
|
@ -3,7 +3,7 @@
|
|||||||
// This software is released under the MIT License.
|
// This software is released under the MIT License.
|
||||||
// https://opensource.org/licenses/MIT
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
#include "display/shader/SimpleBillboardedShader.hpp"
|
#include "display/shader/shaders/SimpleBillboardedShader.hpp"
|
||||||
#include "SimpleBillboardedMaterial.hpp"
|
#include "SimpleBillboardedMaterial.hpp"
|
||||||
#include "game/DawnGame.hpp"
|
#include "game/DawnGame.hpp"
|
||||||
|
|
||||||
|
@ -36,8 +36,12 @@ std::vector<struct ShaderPassItem> SimpleTexturedMaterial::getRenderPasses() {
|
|||||||
onlyPass.shader = shader;
|
onlyPass.shader = shader;
|
||||||
onlyPass.colorValues[shader->paramColor] = this->color;
|
onlyPass.colorValues[shader->paramColor] = this->color;
|
||||||
onlyPass.matrixValues[shader->paramModel] = this->transform->getWorldTransform();
|
onlyPass.matrixValues[shader->paramModel] = this->transform->getWorldTransform();
|
||||||
onlyPass.matrixValues[shader->paramView] = camera->transform->getWorldTransform();
|
|
||||||
onlyPass.matrixValues[shader->paramProjection] = camera->getProjection();
|
onlyPass.parameterBuffers[shader->bufferRenderPipeline] = &this->getGame()->renderManager.getRenderPipeline()->shaderBuffer;
|
||||||
|
|
||||||
|
// onlyPass.matrixValues[shader->paramView] = camera->transform->getWorldTransform();
|
||||||
|
// onlyPass.matrixValues[shader->paramProjection] = camera->getProjection();
|
||||||
|
|
||||||
onlyPass.renderFlags = (
|
onlyPass.renderFlags = (
|
||||||
RENDER_MANAGER_RENDER_FLAG_BLEND |
|
RENDER_MANAGER_RENDER_FLAG_BLEND |
|
||||||
RENDER_MANAGER_RENDER_FLAG_DEPTH_TEST
|
RENDER_MANAGER_RENDER_FLAG_DEPTH_TEST
|
||||||
|
Reference in New Issue
Block a user