Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libRendering
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
STORM
repos
Radium
libRendering
Commits
0b96d149
Commit
0b96d149
authored
4 years ago
by
Mathias Paulin
Browse files
Options
Downloads
Patches
Plain Diff
small improvement in the simpleViewer
parent
4db71905
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/DemoApp/main.cpp
+37
-46
37 additions, 46 deletions
src/DemoApp/main.cpp
src/libRender/RadiumNBR/Passes/CustomAttribToColorPass.cpp
+3
-2
3 additions, 2 deletions
src/libRender/RadiumNBR/Passes/CustomAttribToColorPass.cpp
with
40 additions
and
48 deletions
src/DemoApp/main.cpp
+
37
−
46
View file @
0b96d149
...
@@ -182,55 +182,43 @@ void AddCustomAttributeToMeshes() {
...
@@ -182,55 +182,43 @@ void AddCustomAttributeToMeshes() {
{
{
auto
theMesh
=
ro
->
getMesh
();
auto
theMesh
=
ro
->
getMesh
();
/* Could be helpfull if one can do
auto
displayMesh
=
auto displayable = dynamic_cast<Ra::Engine::Data::CoreGeometryDisplayable< ???
dynamic_cast
<
Ra
::
Engine
::
Data
::
AttribArrayDisplayable
*>
(
theMesh
.
get
()
);
>*>( theMesh.get() );
*/
LOG
(
logINFO
)
<<
"
\t\t
Mesh "
<<
displayMesh
->
getName
()
<<
" is processed."
;
auto
displayMesh
=
dynamic_cast
<
Ra
::
Engine
::
Data
::
Mesh
*>
(
theMesh
.
get
()
);
auto
&
coreMesh
=
displayMesh
->
getAttribArrayGeometry
();
if
(
displayMesh
)
auto
addAttrib
=
[
&
coreMesh
,
displayMesh
](
const
std
::
string
&
name
,
auto
value
)
{
coreMesh
.
addAttrib
<
Ra
::
Core
::
Vector4
>
(
"myCustomAttrib"
,
value
);
};
auto
meshTypeHash
=
typeid
(
*
(
theMesh
.
get
()
)
).
hash_code
();
if
(
meshTypeHash
==
typeid
(
Ra
::
Engine
::
Data
::
Mesh
).
hash_code
()
)
{
{
LOG
(
logINFO
)
<<
"
\t\t
Mesh "
<<
displayMesh
->
getName
()
addAttrib
(
"myCustomAttrib"
,
<<
" (TriangleMesh) is processed."
;
Ra
::
Core
::
Vector4Array
{
displayMesh
->
getNumVertices
(),
displayMesh
->
addAttrib
<
Ra
::
Core
::
Vector4
>
(
/*Ra::Core::Utils::Color::White()*/
{
"myCustomAttrib"
,
0.7
_ra
,
0.8
_ra
,
0.8
_ra
,
1
_ra
}}
);
Ra
::
Core
::
Vector4Array
{
displayMesh
->
getNumVertices
(),
}
Ra
::
Core
::
Utils
::
Color
::
Yellow
()}
);
else
if
(
meshTypeHash
==
typeid
(
Ra
::
Engine
::
Data
::
PolyMesh
).
hash_code
()
)
displayMesh
->
setDirty
(
"myCustomAttrib"
);
{
addAttrib
(
"myCustomAttrib"
,
Ra
::
Core
::
Vector4Array
{
displayMesh
->
getNumVertices
(),
Ra
::
Core
::
Utils
::
Color
{
0.8
_ra
,
0.7
_ra
,
0.8
_ra
}}
);
}
else
if
(
meshTypeHash
==
typeid
(
Ra
::
Engine
::
Data
::
PointCloud
).
hash_code
()
)
{
addAttrib
(
"myCustomAttrib"
,
Ra
::
Core
::
Vector4Array
{
displayMesh
->
getNumVertices
(),
Ra
::
Core
::
Utils
::
Color
{
0.3
_ra
,
0.3
_ra
,
0.8
_ra
}}
);
}
}
else
else
{
{
auto
polyMesh
=
dynamic_cast
<
Ra
::
Engine
::
Data
::
PolyMesh
*>
(
theMesh
.
get
()
);
LOG
(
logINFO
)
<<
"
\t\t
Mesh "
<<
theMesh
->
getName
()
if
(
polyMesh
)
<<
" is nor a trianglemesh, nor a polymesh, nor a "
{
"point cloud ... skipping"
;
LOG
(
logINFO
)
<<
"
\t\t
Mesh "
<<
polyMesh
->
getName
()
<<
" (PolyMesh) is processed."
;
polyMesh
->
addAttrib
<
Ra
::
Core
::
Vector4
>
(
"myCustomAttrib"
,
Ra
::
Core
::
Vector4Array
{
polyMesh
->
getNumVertices
(),
Ra
::
Core
::
Utils
::
Color
::
Magenta
()}
);
polyMesh
->
setDirty
(
"myCustomAttrib"
);
}
else
{
auto
pointCloud
=
dynamic_cast
<
Ra
::
Engine
::
Data
::
PointCloud
*>
(
theMesh
.
get
()
);
if
(
pointCloud
)
{
LOG
(
logINFO
)
<<
"
\t\t
PointCloud "
<<
pointCloud
->
getName
()
<<
" is processed."
;
pointCloud
->
addAttrib
<
Ra
::
Core
::
Vector4
>
(
"myCustomAttrib"
,
Ra
::
Core
::
Vector4Array
{
pointCloud
->
getNumVertices
(),
Ra
::
Core
::
Utils
::
Color
::
Blue
()}
);
pointCloud
->
setDirty
(
"myCustomAttrib"
);
}
else
{
LOG
(
logINFO
)
<<
"
\t\t
Mesh "
<<
theMesh
->
getName
()
<<
" is nor a trianglemesh, nor a polymesh, nor a "
"point cloud ... skipping"
;
}
}
}
}
}
}
}
}
...
@@ -273,13 +261,16 @@ const std::string customVertexAttrib{"in vec4 myCustomAttrib;\n"
...
@@ -273,13 +261,16 @@ const std::string customVertexAttrib{"in vec4 myCustomAttrib;\n"
* Note that this string could also be loaded from a file and/or manually edited if you
* Note that this string could also be loaded from a file and/or manually edited if you
* add an edition widget as in Radium app demo
* add an edition widget as in Radium app demo
*/
*/
const
std
::
string
customFragmentColor
{
const
std
::
string
customFragmentColor
{
"in vec4 fragCustomAttrib;
\n
"
"in vec4 fragCustomAttrib;
\n
"
"
\n
vec4 computeCustomColor(Material mat, vec3 lightDir, vec3 viewDir) {
\n
"
"
\n
vec4 computeCustomColor(Material mat, vec3 lightDir, vec3 viewDir
, vec3 normal_world
) {
\n
"
"vec3 diffColor;
\n
"
"vec3 diffColor;
\n
"
"vec3 specColor;
\n
"
"vec3 specColor;
\n
"
"getSeparateBSDFComponent( mat, getPerVertexTexCoord(), lightDir, viewDir,
\n
"
"getSeparateBSDFComponent( mat, getPerVertexTexCoord(), lightDir, viewDir,
\n
"
"vec3(0, 0, 1), diffColor, specColor );
\n
"
"vec3(0, 0, 1), diffColor, specColor );
\n
"
"vec3 col = normal_world*0.5+0.5;
\n
"
"col *= fragCustomAttrib.rgb;
\n
"
"return vec4( (specColor+fragCustomAttrib.rgb)*max(lightDir.z, 0), 1);
\n
"
"return vec4( (specColor+fragCustomAttrib.rgb)*max(lightDir.z, 0), 1);
\n
"
"}
\n
"
};
"}
\n
"
};
...
...
This diff is collapsed.
Click to expand it.
src/libRender/RadiumNBR/Passes/CustomAttribToColorPass.cpp
+
3
−
2
View file @
0b96d149
...
@@ -190,7 +190,8 @@ bool CustomAttribToColorPass::buildRenderTechnique(
...
@@ -190,7 +190,8 @@ bool CustomAttribToColorPass::buildRenderTechnique(
"layout (location = 5) in vec3 in_viewVector;
\n
"
"layout (location = 5) in vec3 in_viewVector;
\n
"
"layout (location = 6) in vec3 in_lightVector;
\n
"
"layout (location = 6) in vec3 in_lightVector;
\n
"
"layout (location = 0) out vec4 out_color;
\n
"
"layout (location = 0) out vec4 out_color;
\n
"
"vec4 computeCustomColor(Material mat, vec3 light_dir, vec3 view_dir);
\n
"
"vec4 computeCustomColor(Material mat, vec3 light_dir, vec3 view_dir, vec3 "
"normal_world);
\n
"
"void main()
\n
"
"void main()
\n
"
"{
\n
"
"{
\n
"
"vec3 normalWorld = getWorldSpaceNormal();
\n
"
"vec3 normalWorld = getWorldSpaceNormal();
\n
"
...
@@ -208,7 +209,7 @@ bool CustomAttribToColorPass::buildRenderTechnique(
...
@@ -208,7 +209,7 @@ bool CustomAttribToColorPass::buildRenderTechnique(
"world2local[2] = vec3(tangentWorld.z, binormalWorld.z, normalWorld.z);
\n
"
"world2local[2] = vec3(tangentWorld.z, binormalWorld.z, normalWorld.z);
\n
"
"vec3 lightDir = normalize(world2local * in_lightVector);
\n
"
"vec3 lightDir = normalize(world2local * in_lightVector);
\n
"
"vec3 viewDir = normalize(world2local * in_viewVector);
\n
"
"vec3 viewDir = normalize(world2local * in_viewVector);
\n
"
"out_color = computeCustomColor(material, lightDir, viewDir);
\n
"
"out_color = computeCustomColor(material, lightDir, viewDir
, normalWorld
);
\n
"
"}
\n
"
};
"}
\n
"
};
Ra
::
Engine
::
Data
::
ShaderConfiguration
theConfig
{
"CustomAtt2ClrPass::CustomColorProgram"
+
Ra
::
Engine
::
Data
::
ShaderConfiguration
theConfig
{
"CustomAtt2ClrPass::CustomColorProgram"
+
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment