Implement mesh-specific fragment shader to display secondary data

This commit is contained in:
baldurk
2015-01-25 19:31:47 +00:00
parent 8318720561
commit 5972ffa661
10 changed files with 126 additions and 3 deletions
+5
View File
@@ -69,6 +69,8 @@ data/glsl/checkerboard.frago \
data/glsl/generic.frago \
data/glsl/generic.verto \
data/glsl/mesh.verto \
data/glsl/mesh.frago \
data/glsl/mesh.geomo \
data/glsl/text.verto \
data/glsl/text.frago \
data/glsl/histogram.compo \
@@ -102,6 +104,9 @@ $(OBJDIR)/%.verto: %.vert
$(OBJDIR)/%.frago: %.frag
@echo Object building $@
@$(OBJGEN)
$(OBJDIR)/%.geomo: %.geom
@echo Object building $@
@$(OBJGEN)
$(OBJDIR)/%.compo: %.comp
@echo Object building $@
@$(OBJGEN)
+2
View File
@@ -36,6 +36,8 @@ DECLARE_EMBED(texdisplay_frag);
DECLARE_EMBED(checkerboard_frag);
DECLARE_EMBED(histogram_comp);
DECLARE_EMBED(mesh_vert);
DECLARE_EMBED(mesh_frag);
DECLARE_EMBED(mesh_geom);
DECLARE_EMBED(generic_vert);
DECLARE_EMBED(generic_frag);
DECLARE_EMBED(text_frag);
+62
View File
@@ -0,0 +1,62 @@
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2015 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
in v2f
{
vec4 secondary;
vec4 norm;
} IN;
layout (location = 0) out vec4 color_out;
uniform vec4 RENDERDOC_GenericFS_Color;
uniform uint Mesh_DisplayFormat;
void main(void)
{
uint type = Mesh_DisplayFormat;
if(type == MESHDISPLAY_SECONDARY)
{
color_out = vec4(IN.secondary.xyz, 1);
}
else if(type == MESHDISPLAY_SECONDARY_ALPHA)
{
color_out = vec4(IN.secondary.www, 1);
}
else if(type == MESHDISPLAY_FACELIT)
{
color_out = vec4(0, 1, 0, 1);
/*
float3 lightDir = normalize(float3(0, -0.3f, -1));
return float4(WireframeColour.xyz*saturate(dot(lightDir, IN.norm)), 1);
*/
}
else //if(type == MESHDISPLAY_SOLID)
{
color_out = vec4(RENDERDOC_GenericFS_Color.xyz, 1);
}
}
+25
View File
@@ -0,0 +1,25 @@
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2015 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
#version 420 core
+10 -1
View File
@@ -25,10 +25,19 @@
#version 420 core
layout (location = 0) in vec4 position;
layout (location = 1) in vec4 secondary;
uniform mat4 ModelViewProj;
out v2f
{
vec4 secondary;
vec4 norm;
} OUT;
void main(void)
{
gl_Position = ModelViewProj * position;
gl_Position = ModelViewProj * position;
OUT.secondary = secondary;
OUT.norm = vec4(0, 0, 0, 0);
}
+2
View File
@@ -121,6 +121,8 @@ RESOURCE_text_vert TYPE_EMBED "glsl/text.vert"
RESOURCE_text_frag TYPE_EMBED "glsl/text.frag"
RESOURCE_texsample_h TYPE_EMBED "glsl/texsample.h"
RESOURCE_histogram_comp TYPE_EMBED "glsl/histogram.comp"
RESOURCE_mesh_frag TYPE_EMBED "glsl/mesh.frag"
RESOURCE_mesh_geom TYPE_EMBED "glsl/mesh.geom"
RESOURCE_sourcecodepro_ttf TYPE_EMBED "sourcecodepro.ttf"
+2
View File
@@ -23,6 +23,8 @@
#define RESOURCE_text_frag 210
#define RESOURCE_texsample_h 211
#define RESOURCE_histogram_comp 212
#define RESOURCE_mesh_frag 213
#define RESOURCE_mesh_geom 214
#define RESOURCE_sourcecodepro_ttf 301
+10 -2
View File
@@ -173,8 +173,10 @@ void GLReplay::InitDebugData()
DebugData.genericProg = CreateShaderProgram(DebugData.genericvsSource.c_str(), DebugData.genericfsSource.c_str());
string meshvs = GetEmbeddedResource(mesh_vert);
string meshfs = GetEmbeddedResource(mesh_frag);
meshfs = glslheader + meshfs;
DebugData.meshProg = CreateShaderProgram(meshvs.c_str(), DebugData.genericfsSource.c_str());
DebugData.meshProg = CreateShaderProgram(meshvs.c_str(), meshfs.c_str());
WrappedOpenGL &gl = *m_pDriver;
@@ -1591,13 +1593,15 @@ void GLReplay::RenderMesh(uint32_t frameID, uint32_t eventID, const vector<MeshF
// set GS-specific uniform
}
gl.glEnableVertexAttribArray(1);
float wireCol[] = { 0.8f, 0.8f, 0.0f, 1.0f };
gl.glUniform4fv(colLoc, 1, wireCol);
GLint OutputDisplayFormat = (int)cfg.solidShadeMode;
if(cfg.solidShadeMode == eShade_Secondary && cfg.second.showAlpha)
OutputDisplayFormat = MESHDISPLAY_SECONDARY_ALPHA;
gl.glUniform1i(fmtLoc, OutputDisplayFormat);
gl.glUniform1ui(fmtLoc, OutputDisplayFormat);
gl.glPolygonMode(eGL_FRONT_AND_BACK, eGL_FILL);
@@ -1616,6 +1620,8 @@ void GLReplay::RenderMesh(uint32_t frameID, uint32_t eventID, const vector<MeshF
{
gl.glDrawArrays(topo, 0, cfg.position.numVerts);
}
gl.glEnableVertexAttribArray(0);
}
colLoc = gl.glGetUniformLocation(prog, "RENDERDOC_GenericFS_Color");
@@ -1632,6 +1638,8 @@ void GLReplay::RenderMesh(uint32_t frameID, uint32_t eventID, const vector<MeshF
float wireCol[] = { 0.0f, 0.0f, 0.0f, 1.0f };
gl.glUniform4fv(colLoc, 1, wireCol);
gl.glUniform1ui(fmtLoc, MESHDISPLAY_SOLID);
gl.glPolygonMode(eGL_FRONT_AND_BACK, eGL_LINE);
if(topo == eGL_PATCHES) topo = eGL_POINTS;
+2
View File
@@ -370,6 +370,8 @@
<None Include="data\glsl\generic.frag" />
<None Include="data\glsl\generic.vert" />
<None Include="data\glsl\histogram.comp" />
<None Include="data\glsl\mesh.frag" />
<None Include="data\glsl\mesh.geom" />
<None Include="data\glsl\mesh.vert" />
<None Include="data\glsl\texdisplay.frag" />
<None Include="data\glsl\text.frag" />
+6
View File
@@ -595,6 +595,12 @@
<None Include="data\glsl\histogram.comp">
<Filter>Resources\glsl</Filter>
</None>
<None Include="data\glsl\mesh.frag">
<Filter>Resources\glsl</Filter>
</None>
<None Include="data\glsl\mesh.geom">
<Filter>Resources\glsl</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="data\renderdoc.rc">