Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
VR-demos
Commits
13f24519
Commit
13f24519
authored
Feb 26, 2018
by
Ruben Jesus Garcia Hernandez
Browse files
Add NOMAD License to various files.
Add InfoCube to Vive.
parent
70378f53
Changes
29
Hide whitespace changes
Inline
Side-by-side
NOMADVRLib/CompileGLShader.cpp
View file @
13f24519
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#include
<stdio.h>
#include
<stdio.h>
#include
"MyGL.h"
#include
"MyGL.h"
#include
"eprintf.h"
#include
"eprintf.h"
...
...
NOMADVRLib/CompileGLShader.h
View file @
13f24519
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#include
"MyGL.h"
#include
"MyGL.h"
#define SHADERNAME 0
#define SHADERNAME 0
...
...
NOMADVRLib/ConfigFile.cpp
View file @
13f24519
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#include
<algorithm>
#include
<algorithm>
#include
<errno.h>
#include
<errno.h>
#include
<string.h>
#include
<string.h>
...
@@ -46,6 +63,8 @@ int voxelSize[3];
...
@@ -46,6 +63,8 @@ int voxelSize[3];
float
unitcellcolour
[
4
];
float
unitcellcolour
[
4
];
float
supercellcolour
[
4
];
float
supercellcolour
[
4
];
float
infolinecolour
[
4
];
int
repetitions
[
3
];
int
repetitions
[
3
];
Solid
*
solid
;
Solid
*
solid
;
...
@@ -65,6 +84,8 @@ float cubetrans[3];
...
@@ -65,6 +84,8 @@ float cubetrans[3];
float
animationspeed
;
float
animationspeed
;
float
movementspeed
;
float
movementspeed
;
std
::
vector
<
information
>
info
;
const
char
*
loadConfigFileErrors
[]
=
const
char
*
loadConfigFileErrors
[]
=
{
{
"All Ok"
,
//0
"All Ok"
,
//0
...
@@ -214,6 +235,11 @@ void initState()
...
@@ -214,6 +235,11 @@ void initState()
animationspeed
=
1.0
f
;
animationspeed
=
1.0
f
;
movementspeed
=
1.0
f
;
movementspeed
=
1.0
f
;
infolinecolour
[
0
]
=
1.0
f
;
infolinecolour
[
1
]
=
1.0
f
;
infolinecolour
[
2
]
=
0.0
f
;
infolinecolour
[
3
]
=
1.0
f
;
}
}
int
loadConfigFile
(
const
char
*
f
)
int
loadConfigFile
(
const
char
*
f
)
...
@@ -609,6 +635,10 @@ int loadConfigFile(const char * f)
...
@@ -609,6 +635,10 @@ int loadConfigFile(const char * f)
r
=
fscanf
(
F
,
"%f %f %f"
,
atomtrajectorycolour
,
atomtrajectorycolour
+
1
,
atomtrajectorycolour
+
2
);
r
=
fscanf
(
F
,
"%f %f %f"
,
atomtrajectorycolour
,
atomtrajectorycolour
+
1
,
atomtrajectorycolour
+
2
);
if
(
r
<
3
)
if
(
r
<
3
)
eprintf
(
"Error reading atomtrajectorycolour value"
);
eprintf
(
"Error reading atomtrajectorycolour value"
);
}
else
if
(
!
strcmp
(
s
,
"infolinecolour"
))
{
r
=
fscanf
(
F
,
"%f %f %f"
,
infolinecolour
,
infolinecolour
+
1
,
infolinecolour
+
2
);
if
(
r
<
3
)
eprintf
(
"Error reading atomtrajectorycolour value"
);
}
else
if
(
!
strcmp
(
s
,
"animationspeed"
))
{
}
else
if
(
!
strcmp
(
s
,
"animationspeed"
))
{
r
=
fscanf
(
F
,
"%f"
,
&
animationspeed
);
r
=
fscanf
(
F
,
"%f"
,
&
animationspeed
);
if
(
r
<
1
)
if
(
r
<
1
)
...
@@ -617,6 +647,21 @@ int loadConfigFile(const char * f)
...
@@ -617,6 +647,21 @@ int loadConfigFile(const char * f)
r
=
fscanf
(
F
,
"%f"
,
&
movementspeed
);
r
=
fscanf
(
F
,
"%f"
,
&
movementspeed
);
if
(
r
<
1
)
if
(
r
<
1
)
eprintf
(
"Error reading movementspeed"
);
eprintf
(
"Error reading movementspeed"
);
#ifdef WIN32
}
else
if
(
!
strcmp
(
s
,
"info"
))
{
information
i
;
r
=
fscanf
(
F
,
"%f %f %f %f %d"
,
i
.
pos
,
i
.
pos
+
1
,
i
.
pos
+
2
,
&
(
i
.
size
),
&
(
i
.
atom
));
if
(
r
<
5
)
eprintf
(
"Error reading info"
);
r
=
readString
(
F
,
s
);
if
(
r
!=
0
)
eprintf
(
"Error reading info"
);
char
file
[
256
];
sprintf
(
file
,
"%s%s"
,
PATH
,
s
);
i
.
filename
=
strdup
(
file
);
//i.tex=LoadPNG(i.filename); //opengl not initialized yet
info
.
push_back
(
i
);
#endif
}
else
if
(
!
strcmp
(
s
,
"
\x0d
"
))
{
//discard windows newline (problem in Sebastian Kokott's phone (?!)
}
else
if
(
!
strcmp
(
s
,
"
\x0d
"
))
{
//discard windows newline (problem in Sebastian Kokott's phone (?!)
continue
;
continue
;
}
else
{
}
else
{
...
...
NOMADVRLib/ConfigFile.h
View file @
13f24519
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#ifndef __CONFIGFILE_H
#ifndef __CONFIGFILE_H
#define __CONFIGFILE_H
#define __CONFIGFILE_H
#include
<vector>
#include
<vector>
#include
"MyGL.h"
#include
"polyhedron.h"
#include
"polyhedron.h"
extern
const
char
*
PATH
;
extern
const
char
*
PATH
;
...
@@ -40,6 +57,8 @@ extern float markerscaling;
...
@@ -40,6 +57,8 @@ extern float markerscaling;
extern
float
unitcellcolour
[
4
];
extern
float
unitcellcolour
[
4
];
extern
float
supercellcolour
[
4
];
extern
float
supercellcolour
[
4
];
extern
float
infolinecolour
[
4
];
extern
int
repetitions
[
3
];
extern
int
repetitions
[
3
];
extern
Solid
*
solid
;
extern
Solid
*
solid
;
...
@@ -67,4 +86,14 @@ extern const char * loadConfigFileErrors[];
...
@@ -67,4 +86,14 @@ extern const char * loadConfigFileErrors[];
int
loadConfigFile
(
const
char
*
f
);
int
loadConfigFile
(
const
char
*
f
);
struct
information
{
float
pos
[
3
];
float
size
;
int
atom
;
//-1=do not draw line
const
char
*
filename
;
GLuint
tex
;
};
extern
std
::
vector
<
information
>
info
;
#endif //__CONFIGFILE_H
#endif //__CONFIGFILE_H
NOMADVRLib/Grid.cpp
View file @
13f24519
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#include
"Grid.h"
#include
"Grid.h"
#include
"atoms.hpp"
//for radius
#include
"atoms.hpp"
//for radius
#include
<math.h>
#include
<math.h>
...
...
NOMADVRLib/Grid.h
View file @
13f24519
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#include
<vector>
#include
<vector>
class
grid
class
grid
...
...
NOMADVRLib/IsoShaders.cpp
View file @
13f24519
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#include
"IsoShaders.h"
#include
"IsoShaders.h"
#define GRIDSTR "1"
#define GRIDSTR "1"
...
@@ -55,21 +71,15 @@ const char *const IsoTransparentShaders [] = {"Iso Transparent Renderer",
...
@@ -55,21 +71,15 @@ const char *const IsoTransparentShaders [] = {"Iso Transparent Renderer",
"layout(location = 0) in vec4 position;
\n
"
"layout(location = 0) in vec4 position;
\n
"
"layout(location = 1) in vec3 normalsIn;
\n
"
"layout(location = 1) in vec3 normalsIn;
\n
"
"layout(location = 2) in vec4 colorIn;
\n
"
"layout(location = 2) in vec4 colorIn;
\n
"
// "layout(location = 3) in vec2 uvIn;\n"
"out vec4 color;
\n
"
"out vec4 color;
\n
"
"out vec3 n;
\n
"
"out vec3 n;
\n
"
"out highp vec4 pos;
\n
"
"out highp vec4 pos;
\n
"
// "out vec2 uv;\n"
"void main()
\n
"
"void main()
\n
"
"{
\n
"
"{
\n
"
" color = vec4(colorIn.rgba);
\n
"
" color = vec4(colorIn.rgba);
\n
"
" n=normalize(normalsIn);
\n
"
" n=normalize(normalsIn);
\n
"
// " uv=uvIn;\n"
" pos = matrix * position;
\n
"
// "int i=gl_InstanceID / " GRIDSTR ";\n"
// "int j=gl_InstanceID % " GRIDSTR ";\n"
" pos = matrix * (position /*+ vec4 (float(i)*0.15*101.0, 0, float(j)*0.15*101.0, 0)*/);
\n
"
" gl_Position = pos;
\n
"
" gl_Position = pos;
\n
"
//" gl_Position = matrix * position;\n"
"}
\n
"
,
"}
\n
"
,
// Fragment Shader
// Fragment Shader
...
@@ -86,16 +96,13 @@ const char *const IsoTransparentShaders [] = {"Iso Transparent Renderer",
...
@@ -86,16 +96,13 @@ const char *const IsoTransparentShaders [] = {"Iso Transparent Renderer",
"void main()
\n
"
"void main()
\n
"
"{
\n
"
"{
\n
"
"highp vec4 mytex=texture(diffuse, vec2(pos.x/pos.w*0.5+0.5, pos.y/pos.w*0.5+0.5));
\n
"
"highp vec4 mytex=texture(diffuse, vec2(pos.x/pos.w*0.5+0.5, pos.y/pos.w*0.5+0.5));
\n
"
//http://www.gamedev.net/topic/556521-glsl-manual-shadow-map-biasscale/
//"vec2 d=vec2(dFdx(pos.z), dFdy(pos.z));\n"
"if ((pos.z/pos.w+1.0)/2.0 <= mytex.r+0.00001 ) discard;
\n
"
//"highp float m=sqrt(d.x*d.x + d.y*d.y);\n"
"if ((pos.z/pos.w+1.0)/2.0 <= mytex.r+0.0001 ) discard;
\n
"
"lowp vec3 nn=normalize(n);"
"lowp vec3 nn=normalize(n);"
"lowp float a=max(0.0, dot(nn, vec3(0,sqrt(2.0)/2.0,sqrt(2.0)/2.0)));
\n
"
"lowp float a=max(0.0, dot(nn, vec3(0,sqrt(2.0)/2.0,sqrt(2.0)/2.0)));
\n
"
"lowp float b=max(0.0, dot(nn, vec3(0,0,1)));
\n
"
"lowp float b=max(0.0, dot(nn, vec3(0,0,1)));
\n
"
"highp vec4 res=color;
\n
"
"highp vec4 res=color;
\n
"
//"outputColor = vec4(pos.x/pos.w*0.5+0.5, pos.y/pos.w*0.5+0.5, 0,1);\n"
" outputColor = vec4 ((res.rgb) * (0.2 + 0.2*a + 0.3*b), color.a);
\n
"
" outputColor = vec4 ((res.rgb) * (0.2 + 0.2*a + 0.3*b), color.a);
\n
"
"}
\n
"
,
"}
\n
"
,
...
...
NOMADVRLib/IsoShaders.h
View file @
13f24519
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
extern
const
char
*
const
IsoShaders
[];
extern
const
char
*
const
IsoShaders
[];
extern
const
char
*
const
IsoTransparentShaders
[];
extern
const
char
*
const
IsoTransparentShaders
[];
extern
const
char
*
const
IsoBlendShaders
[];
extern
const
char
*
const
IsoBlendShaders
[];
NOMADVRLib/IsosurfacesGL.cpp
View file @
13f24519
//#if 0
/*Uses code from rply which uses the MIT license*/
/*http://w3.impa.br/~diego/software/rply/*/
/*This license is compatible with Apache 2.0*/
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#include
<vector>
#include
<vector>
#include
<math.h>
#include
<math.h>
...
@@ -153,11 +171,7 @@ int vertex_cb(p_ply_argument argument) {
...
@@ -153,11 +171,7 @@ int vertex_cb(p_ply_argument argument) {
int
face_cb
(
p_ply_argument
argument
)
{
int
face_cb
(
p_ply_argument
argument
)
{
long
length
,
value_index
;
long
length
,
value_index
;
// int v;
ply_get_argument_property
(
argument
,
nullptr
,
&
length
,
&
value_index
);
ply_get_argument_property
(
argument
,
nullptr
,
&
length
,
&
value_index
);
//discard the first call with a 3
//if (value_index == 0 && 3 != (v = (int)ply_get_argument_value(argument)))
// dprintf("Non-triangular face: %d vertices\n", v);
if
(
value_index
>=
0
&&
value_index
<=
2
)
if
(
value_index
>=
0
&&
value_index
<=
2
)
CubeIndices
[
CurrentIndex
++
]
=
(
int
)(
ply_get_argument_value
(
argument
));
CubeIndices
[
CurrentIndex
++
]
=
(
int
)(
ply_get_argument_value
(
argument
));
...
@@ -350,13 +364,11 @@ if ((e = glGetError()) != GL_NO_ERROR)
...
@@ -350,13 +364,11 @@ if ((e = glGetError()) != GL_NO_ERROR)
#else
#else
void
CleanDepthTexture
(
GLuint
t
,
int
width
,
int
height
)
void
CleanDepthTexture
(
GLuint
t
,
int
width
,
int
height
)
{
{
//eprintf ("CleanDepthTexture, t %d, w %d, h %d\n", t, width, height);
GLenum
e
;
GLenum
e
;
const
std
::
vector
<
float
>
z
(
width
*
height
*
4
,
0.0
f
);
const
std
::
vector
<
float
>
z
(
width
*
height
*
4
,
0.0
f
);
glBindTexture
(
GL_TEXTURE_2D
,
t
);
glBindTexture
(
GL_TEXTURE_2D
,
t
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"CleanDepthTexture: Gl error after glBindTexture: %d
\n
"
,
e
);
eprintf
(
"CleanDepthTexture: Gl error after glBindTexture: %d
\n
"
,
e
);
//rgh FIXME: invalid operation here:
glTexSubImage2D
(
GL_TEXTURE_2D
,
0
,
0
,
0
,
width
,
height
,
GL_DEPTH_COMPONENT
,
GL_FLOAT
,
z
.
data
());
glTexSubImage2D
(
GL_TEXTURE_2D
,
0
,
0
,
0
,
width
,
height
,
GL_DEPTH_COMPONENT
,
GL_FLOAT
,
z
.
data
());
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"CleanDepthTexture: Gl error after glTexSubImage2D: %d
\n
"
,
e
);
eprintf
(
"CleanDepthTexture: Gl error after glTexSubImage2D: %d
\n
"
,
e
);
...
@@ -416,7 +428,7 @@ return glGetError();
...
@@ -416,7 +428,7 @@ return glGetError();
GLenum
SetupBlending
(
GLuint
*
vao
,
GLuint
*
vertex
,
GLuint
*
indices
)
GLenum
SetupBlending
(
GLuint
*
vao
,
GLuint
*
vertex
,
GLuint
*
indices
)
{
{
GLenum
e
;
GLenum
e
;
float
z
=
0.0
f
;
//(m_fNearClip + m_fFarClip) / 2.0f;
float
z
=
0.0
f
;
const
float
points
[]
=
{
const
float
points
[]
=
{
-
1
,
-
1
,
z
,
0
,
0
,
-
1
,
-
1
,
z
,
0
,
0
,
-
1
,
1
,
z
,
0
,
1
,
-
1
,
1
,
z
,
0
,
1
,
...
@@ -482,4 +494,4 @@ if ((e = glGetError()) != GL_NO_ERROR)
...
@@ -482,4 +494,4 @@ if ((e = glGetError()) != GL_NO_ERROR)
eprintf
(
"Gl error BlendTextures glDrawElements: %d
\n
"
,
e
);
eprintf
(
"Gl error BlendTextures glDrawElements: %d
\n
"
,
e
);
}
}
}
}
//#endif
NOMADVRLib/IsosurfacesGL.h
View file @
13f24519
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#ifndef __ISOSURFACESGL_H
#ifndef __ISOSURFACESGL_H
#define __ISOSURFACESGL_H
#define __ISOSURFACESGL_H
...
...
NOMADVRLib/MyGL.h
View file @
13f24519
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#ifndef __MYGL_H
#ifndef __MYGL_H
#define __MYGL_H
#define __MYGL_H
...
...
NOMADVRLib/TessShaders.cpp
View file @
13f24519
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#include
"TessShaders.h"
#include
"TessShaders.h"
/*rgh: for now default tesselation control, using
/*rgh: for now default tesselation control, using
...
@@ -16,18 +32,16 @@ const char * const AtomShaders [] = {
...
@@ -16,18 +32,16 @@ const char * const AtomShaders [] = {
"#version 300 es
\n
"
"#version 300 es
\n
"
#endif
#endif
"uniform sampler2D atomData;
\n
"
"uniform sampler2D atomData;
\n
"
"uniform float totalatoms;
\n
"
//(float)atomsInPeriodicTable
"uniform float totalatoms;
\n
"
//(float)atomsInPeriodicTable
"layout(location = 0) in vec3 center;
\n
"
"layout(location = 0) in vec3 center;
\n
"
"layout(location = 1) in float atomIn;
\n
"
"layout(location = 1) in float atomIn;
\n
"
"out vec4 vcolor;
\n
"
//color , radius
"out vec4 vcolor;
\n
"
//color , radius
"out vec3 vcen;"
"out vec3 vcen;"
"void main()
\n
"
"void main()
\n
"
"{
\n
"
"{
\n
"
//"gl_Position = matrix * vec4(position+center, 1);\n"
"float coord=atomIn/totalatoms+0.5/totalatoms;
\n
"
"float coord=atomIn/totalatoms+0.5/totalatoms;
\n
"
"vcolor=vec4(texture(atomData, vec2(coord, 0)));
\n
"
"vcolor=vec4(texture(atomData, vec2(coord, 0)));
\n
"
"vcen=center;
\n
"
"vcen=center;
\n
"
//"color.a=1;\n"
"}
\n
"
,
"}
\n
"
,
//fragment shader
//fragment shader
...
@@ -37,20 +51,14 @@ const char * const AtomShaders [] = {
...
@@ -37,20 +51,14 @@ const char * const AtomShaders [] = {
"#version 300 es
\n
"
"#version 300 es
\n
"
#endif
#endif
"in lowp vec4 color;
\n
"
"in lowp vec4 color;
\n
"
// "in highp vec3 vertex;"
"in highp vec3 normal;"
"in highp vec3 normal;"
"out lowp vec4 outputColor;
\n
"
"out lowp vec4 outputColor;
\n
"
"void main()
\n
"
"void main()
\n
"
"{
\n
"
"{
\n
"
//"vec3 U = dFdx(vertex); "
//"vec3 V = dFdy(vertex); "
"highp vec3 nn = normalize(normal);"
"highp vec3 nn = normalize(normal);"
//"vec3 nn = normalize(cross(U,V));"
"lowp float a=abs(dot(nn, vec3(0,sqrt(2.0)/2.0,sqrt(2.0)/2.0)));
\n
"
"lowp float a=abs(dot(nn, vec3(0,sqrt(2.0)/2.0,sqrt(2.0)/2.0)));
\n
"
"lowp float b=max(0.0, dot(nn, vec3(0,0,1)));
\n
"
"lowp float b=max(0.0, dot(nn, vec3(0,0,1)));
\n
"
"highp vec4 res=color;
\n
"
"highp vec4 res=color;
\n
"
//rgh FIXME: make this depend on the background colour. Otherwise looks almost black with white background
//version for white background:
" outputColor = vec4 ((res.rgb) * (0.4 + 0.3*a + 0.3*b), color.a);
\n
"
" outputColor = vec4 ((res.rgb) * (0.4 + 0.3*a + 0.3*b), color.a);
\n
"
"}
\n
"
,
"}
\n
"
,
...
@@ -60,18 +68,13 @@ const char * const AtomShaders [] = {
...
@@ -60,18 +68,13 @@ const char * const AtomShaders [] = {
#else
#else
"#version 320 es
\n
"
"#version 320 es
\n
"
#endif
#endif
//"layout(triangles, equal_spacing, cw) in;\n"
"layout(quads, equal_spacing, cw) in;
\n
"
"layout(quads, equal_spacing, cw) in;
\n
"
"#define pi 3.1415926535897932384626433832795
\n
"
"#define pi 3.1415926535897932384626433832795
\n
"
"uniform mat4 matrix;
\n
"
"uniform mat4 matrix;
\n
"
//"uniform mat4 mv;\n"
"in vec4 vcolor[];
\n
"
//color , radius
"in vec4 vcolor[];
\n
"
//color , radius
"in vec3 vcen[];"
"in vec3 vcen[];"
"out vec4 color;
\n
"
//color
"out vec4 color;
\n
"
//color
"out vec3 normal;
\n
"
"out vec3 normal;
\n
"
// "out vec3 vertex;"
// "uniform mat4 Projection;\n"
// "uniform mat4 Modelview;\n"
"void main()
\n
"
"void main()
\n
"
"{
\n
"
"{
\n
"
...
@@ -87,8 +90,6 @@ const char * const AtomShaders [] = {
...
@@ -87,8 +90,6 @@ const char * const AtomShaders [] = {
const
char
*
const
AtomShadersNoTess
[]
=
{
const
char
*
const
AtomShadersNoTess
[]
=
{
"Atom Renderer No Tess"
,
"Atom Renderer No Tess"
,
//No Tess means smooth shading looks very strange. Better use per-face lighting
// vertex shader
//Android 21 gives error: only supports up to '310 es'
//Android 21 gives error: only supports up to '310 es'
#if defined(WIN32) || defined(CAVE)
#if defined(WIN32) || defined(CAVE)
"#version 410
\n
"
"#version 410
\n
"
...
@@ -97,7 +98,7 @@ const char * const AtomShadersNoTess [] = {
...
@@ -97,7 +98,7 @@ const char * const AtomShadersNoTess [] = {