-
Notifications
You must be signed in to change notification settings - Fork 466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GLSL 330 shaders #1726
Closed
simonschmeisser
wants to merge
3
commits into
ros-visualization:noetic-devel
from
isys-vision:glsl330-shaders
Closed
GLSL 330 shaders #1726
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
function rotateY(t) { | ||
var s = Math.sin(t); | ||
var c = Math.cos(t); | ||
return [ | ||
c, 0,-s, 0, | ||
0, 1, 0, 0, | ||
s, 0, c, 0, | ||
0, 0, 0, 1 | ||
]; | ||
} | ||
|
||
function perspective(fovy, aspect, near, far) { | ||
var y = 1 / Math.tan(fovy / 2 * Math.PI / 180); | ||
var x = y / aspect; | ||
var c = (near + far) / (near - far); | ||
var d = (near * far) / (near - far) * 2; | ||
return [ | ||
x, 0, 0, 0, | ||
0, y, 0, 0, | ||
0, 0, c,-1, | ||
0, 0, d, 0 | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,219 @@ | ||
[ | ||
{ | ||
"executeOn": "ResetEvaluation", | ||
"fileName": "../../../../../../../../tmp/.mount_GPUpadasGMNv/usr/share/gpupad/samples/Cube/math.js", | ||
"id": 103, | ||
"type": "Script" | ||
}, | ||
{ | ||
"fileName": "cube_position_normal_texcoords.bin", | ||
"id": 7253, | ||
"items": [ | ||
{ | ||
"id": 7254, | ||
"items": [ | ||
{ | ||
"count": 3, | ||
"dataType": "Float", | ||
"id": 7255, | ||
"name": "position", | ||
"padding": 0, | ||
"type": "Field" | ||
}, | ||
{ | ||
"count": 3, | ||
"dataType": "Float", | ||
"id": 7256, | ||
"name": "normal", | ||
"padding": 0, | ||
"type": "Field" | ||
}, | ||
{ | ||
"count": 2, | ||
"dataType": "Float", | ||
"id": 7257, | ||
"name": "texcoords", | ||
"padding": 0, | ||
"type": "Field" | ||
} | ||
], | ||
"name": "Vertex", | ||
"offset": "0", | ||
"rowCount": "36", | ||
"type": "Block" | ||
} | ||
], | ||
"type": "Buffer" | ||
}, | ||
{ | ||
"id": 7247, | ||
"items": [ | ||
{ | ||
"divisor": 0, | ||
"fieldId": 7255, | ||
"id": 7248, | ||
"name": "vertex", | ||
"normalize": false, | ||
"type": "Attribute" | ||
} | ||
], | ||
"name": "Stream", | ||
"type": "Stream" | ||
}, | ||
{ | ||
"bindingType": "Uniform", | ||
"editor": "Expression4", | ||
"id": 7250, | ||
"name": "size", | ||
"type": "Binding", | ||
"values": [ | ||
"4", | ||
"4", | ||
"4", | ||
"4" | ||
] | ||
}, | ||
{ | ||
"bindingType": "Uniform", | ||
"editor": "Expression4x4", | ||
"id": 78, | ||
"name": "uView", | ||
"type": "Binding", | ||
"values": [ | ||
"1", | ||
"0", | ||
"0", | ||
"0", | ||
"0", | ||
"1", | ||
"0", | ||
"0", | ||
"0", | ||
"0", | ||
"1", | ||
"0", | ||
"0.40", | ||
"-0.75", | ||
"-4.00", | ||
"1" | ||
] | ||
}, | ||
{ | ||
"bindingType": "Uniform", | ||
"editor": "Expression", | ||
"id": 7259, | ||
"name": "uProjection", | ||
"type": "Binding", | ||
"values": [ | ||
"perspective(45, 1, 1, 100)" | ||
] | ||
}, | ||
{ | ||
"bindingType": "Uniform", | ||
"editor": "Expression", | ||
"id": 7249, | ||
"name": "worldviewproj_matrix", | ||
"type": "Binding", | ||
"values": [ | ||
"uProjection*uView" | ||
] | ||
}, | ||
{ | ||
"bindingType": "Uniform", | ||
"editor": "Expression4", | ||
"id": 7251, | ||
"name": "auto_size", | ||
"type": "Binding", | ||
"values": [ | ||
"4", | ||
"4", | ||
"4", | ||
"4" | ||
] | ||
}, | ||
{ | ||
"id": 7241, | ||
"items": [ | ||
{ | ||
"fileName": "pass_pos_color.vert", | ||
"id": 7242, | ||
"language": "GLSL", | ||
"shaderType": "Vertex", | ||
"type": "Shader" | ||
}, | ||
{ | ||
"fileName": "box.geom", | ||
"id": 7243, | ||
"language": "GLSL", | ||
"shaderType": "Geometry", | ||
"type": "Shader" | ||
} | ||
], | ||
"name": "Program", | ||
"type": "Program" | ||
}, | ||
{ | ||
"flipVertically": false, | ||
"format": "RGBA8_UNorm", | ||
"height": "600", | ||
"id": 7252, | ||
"name": "Texture", | ||
"target": "Target2D", | ||
"type": "Texture", | ||
"width": "800" | ||
}, | ||
{ | ||
"blendConstant": "#ffffffff", | ||
"cullMode": "NoCulling", | ||
"frontFace": "CCW", | ||
"id": 7245, | ||
"items": [ | ||
{ | ||
"blendAlphaDest": "Zero", | ||
"blendAlphaEq": "Add", | ||
"blendAlphaSource": "One", | ||
"blendColorDest": "Zero", | ||
"blendColorEq": "Add", | ||
"blendColorSource": "One", | ||
"colorWriteMask": 15, | ||
"id": 7246, | ||
"level": 0, | ||
"name": "Attachment", | ||
"textureId": 7252, | ||
"type": "Attachment" | ||
} | ||
], | ||
"logicOperation": "NoLogicOperation", | ||
"name": "Target", | ||
"polygonMode": "Fill", | ||
"type": "Target" | ||
}, | ||
{ | ||
"callType": "ClearTexture", | ||
"checked": true, | ||
"clearColor": "#ff000000", | ||
"clearDepth": 1, | ||
"clearStencil": 0, | ||
"executeOn": "EveryEvaluation", | ||
"id": 7258, | ||
"name": "Clear Texture", | ||
"textureId": 7252, | ||
"type": "Call" | ||
}, | ||
{ | ||
"baseInstance": "0", | ||
"callType": "Draw", | ||
"checked": true, | ||
"count": "3", | ||
"executeOn": "EveryEvaluation", | ||
"first": "0", | ||
"id": 7244, | ||
"instanceCount": "1", | ||
"name": "Draw", | ||
"primitiveType": "Points", | ||
"programId": 7241, | ||
"targetId": 7245, | ||
"type": "Call", | ||
"vertexStreamId": 7247 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[General] | ||
editorState=@ByteArray(\0\0\0\xff\0\0\0\0\xfd\0\0\0\x1\0\0\0\x2\0\0\x4\xf9\0\0\x3\v\xfc\x1\0\0\0\x10\xfc\0\0\0\0\0\0\x3 \0\0\0\0\0\xff\xff\xff\xfa\0\0\0\0\x1\0\0\0\x2\xfb\0\0\0\x1e\0\x66\0\x37\0\x61\0\x64\0\x35\0\x63\0\x66\0\x38\0\x36\0\x35\0\x30\0\x61\0\x66\0\x63\0\x65\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\xfb\0\0\0 \0\x31\0\x31\0\x36\0\x34\0\x39\0\x33\0\x35\0\x34\0\x37\0\x61\0\x65\0\x62\0\x33\0\x63\0\x36\0\x31\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\xfc\0\0\0\0\0\0\x1\xe0\0\0\0\0\0\xff\xff\xff\xfa\0\0\0\0\x1\0\0\0\x2\xfb\0\0\0 \0\x31\0\x30\0\x61\0\x65\0\x32\0\x66\0\x64\0\x39\0\x63\0\x34\0\x65\0\x63\0\x64\0\x39\0\x66\0\x31\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\xfb\0\0\0 \0\x39\0\x35\0\x64\0\x62\0\x33\0\x37\0\x38\0\x64\0\x31\0\x64\0\x33\0\x37\0\x31\0\x63\0\x62\0\x66\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\xfc\0\0\x1\xe6\0\0\x1\xd7\0\0\0\0\0\xff\xff\xff\xfa\0\0\0\0\x1\0\0\0\x2\xfb\0\0\0 \0\x64\0\x35\0\x35\0\x38\0\x39\0\x30\0\x66\0\x37\0\x61\0\x64\0\x61\0\x33\0\x37\0\x35\0\x66\0\x30\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\xfb\0\0\0 \0\x65\0\x30\0\x36\0\x64\0\x38\0\x31\0\x61\0\x38\0\x39\0\x64\0\x64\0\x38\0\x37\0\x61\0\x35\0\x36\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\xfc\0\0\0\0\0\0\x2\x61\0\0\0\0\0\xff\xff\xff\xfa\0\0\0\0\x1\0\0\0\x2\xfb\0\0\0 \0\x66\0\x38\0\x30\0\x64\0\x65\0\x36\0\x63\0\x35\0\x37\0\x34\0\x33\0\x37\0\x35\0\x32\0\x30\0\x39\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\xfb\0\0\0 \0\x63\0\x35\0\x36\0\x31\0\x65\0\x38\0\x37\0\x38\0\x33\0\x63\0\x63\0\x30\0\x31\0\x30\0\x38\0\x66\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\xfc\0\0\x2g\0\0\x2N\0\0\0\0\0\xff\xff\xff\xfa\0\0\0\0\x1\0\0\0\x4\xfb\0\0\0 \0\x62\0\x39\0\x32\0\x38\0\x31\0\x62\0\x65\0\x30\0\x36\0\x66\0\x64\0\x61\0\x32\0\x32\0\x34\0\x39\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\xfb\0\0\0 \0\x37\0\x37\0\x31\0\x38\0\x30\0\x39\0\x36\0\x63\0\x32\0\x65\0\x30\0\x65\0\x62\0\x38\0\x38\0\x65\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\xfb\0\0\0 \0\x38\0\x32\0\x38\0\x32\0\x34\0\x37\0\x66\0\x33\0\x63\0\x62\0\x31\0\x34\0\x37\0\x30\0\x61\0\x38\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\xfb\0\0\0 \0\x66\0\x36\0\x33\0\x38\0\x66\0\x39\0\x39\0\x63\0\x38\0\x63\0\x35\0\x36\0\x34\0\x61\0\x36\0\x66\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\xfb\0\0\0\x1e\0\x32\0\x63\0\x66\0\x33\0\x33\0\x39\0\x63\0\x38\0\x62\0\x30\0\x66\0\x61\0\x63\0\x31\0\x64\x1\0\0\0\0\0\0\x4\xb5\0\0\0\0\0\0\0\0\xfb\0\0\0\x1e\0\x66\0\x30\0\x37\0\x31\0\x31\0\x66\0\x32\0\x35\0\x63\0\x65\0\x37\0\x61\0\x64\0\x31\0\x66\x1\0\0\0\0\0\0\x4\xb5\0\0\0\0\0\0\0\0\xfb\0\0\0 \0\x39\0\x65\0\x63\0\x34\0\x37\0\x62\0\x37\0\x35\0\x30\0\x39\0\x61\0\x34\0\x34\0\x35\0\x39\0\x30\x1\0\0\0\0\0\0\x4\xb5\0\0\0\0\0\0\0\0\xfb\0\0\0\x1e\0\x32\0\x31\0\x30\0\x31\0\x37\0\x65\0\x32\0\x66\0\x35\0\x37\0\x66\0\x32\0\x39\0\x66\0\x61\x1\0\0\0\0\0\0\x4\xb5\0\0\0\0\0\0\0\0\xfb\0\0\0 \0\x65\0\x35\0\x37\0\x33\0\x65\0\x30\0\x36\0\x65\0\x39\0\x34\0\x36\0\x62\0\x35\0\x36\0\x65\0\x35\x1\0\0\0\0\0\0\x4\xb5\0\0\0\0\0\0\0\0\xfb\0\0\0 \0\x36\0\x63\0\x63\0\x35\0\x34\0\x33\0\x65\0\x62\0\x34\0\x61\0\x61\0\x31\0\x35\0\x63\0\x37\0\x36\x1\0\0\0\0\0\0\x4\xb5\0\0\0\0\0\0\0\0\xfb\0\0\0 \0\x64\0\x65\0\x32\0\x32\0\x34\0\x33\0\x65\0\x63\0\x62\0\x38\0\x62\0\x64\0\x32\0\x37\0\x31\0\x61\x1\0\0\0\0\0\0\x4\xb5\0\0\0\0\0\0\0\0\xfb\0\0\0 \0\x62\0\x36\0\x62\0\x62\0\x37\0\x30\0\x30\0\x63\0\x39\0\x31\0\x34\0\x35\0\x34\0\x61\0\x32\0\x37\x1\0\0\0\0\0\0\x2X\0\0\0\0\0\0\0\0\xfc\0\0\x2^\0\0\x2W\0\0\0\0\0\xff\xff\xff\xfa\0\0\0\0\x1\0\0\0\x4\xfb\0\0\0 \0\x32\0\x39\0\x38\0\x62\0\x35\0\x64\0\x37\0\x34\0\x35\0\x36\0\x38\0\x39\0\x39\0\x64\0\x30\0\x31\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\xfb\0\0\0 \0\x66\0\x34\0\x64\0\x30\0\x39\0\x39\0\x63\0\x61\0\x32\0\x38\0\x33\0\x34\0\x33\0\x32\0\x36\0\x63\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\xfb\0\0\0 \0\x63\0\x36\0\x36\0\x34\0\x66\0\x38\0\x34\0\x65\0\x37\0\x37\0\x36\0\x37\0\x31\0\x61\0\x38\0\x35\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\xfb\0\0\0 \0\x34\0\x36\0\x33\0\x34\0\x66\0\x64\0\x66\0\x63\0\x34\0\x65\0\x39\0\x39\0\x39\0\x30\0\x30\0\x39\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\xfc\0\0\0\0\0\0\x2\x8f\0\0\0{\0\xff\xff\xff\xfa\0\0\0\0\x1\0\0\0\x4\xfb\0\0\0 \0\x34\0\x33\0\x33\0\x33\0\x65\0\x34\0\x61\0\x31\0\x38\0\x33\0\x35\0\x30\0\x64\0\x63\0\x64\0\x38\x1\0\0\0\0\xff\xff\xff\xff\0\0\0H\0\xff\xff\xff\xfb\0\0\0\x1e\0\x33\0\x62\0\x62\0\x38\0\x32\0\x61\0\x66\0\x61\0\x37\0\x66\0\x32\0\x61\0\x64\0\x38\0\x38\x1\0\0\0\0\xff\xff\xff\xff\0\0\0H\0\xff\xff\xff\xfb\0\0\0 \0\x37\0\x32\0\x61\0\x30\0\x66\0\x32\0\x64\0\x65\0\x39\0\x35\0\x34\0\x32\0\x30\0\x64\0\x34\0\x66\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\xfb\0\0\0 \0\x64\0\x30\0\x36\0\x65\0\x39\0\x66\0\x66\0\x64\0\x34\0\x65\0\x66\0\x36\0\x32\0\x30\0\x63\0\x66\x1\0\0\0\0\xff\xff\xff\xff\0\0\0H\0\xff\xff\xff\xfb\0\0\0 \0\x64\0\x35\0\x38\0\x35\0\x37\0\x32\0\x35\0\x61\0\x64\0\x31\0\x62\0\x36\0\x30\0\x35\0\x66\0\x33\x1\0\0\x2\x95\0\0\x2\x64\0\0\0H\0\xff\xff\xff\0\0\x4\xf9\0\0\0\0\0\0\0\x4\0\0\0\x4\0\0\0\b\0\0\0\b\xfc\0\0\0\0) | ||
openEditors=103|d06e9ffd4ef620cf, 7242|4333e4a18350dcd8, 7243|3bb82afa7f2ad88, 7252|d585725ad1b605f3 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#version 330 | ||
|
||
// Passes on the packed depth value | ||
|
||
// Splits up a normalized depth value in the range (0..1) | ||
// into the vertex RGB values. | ||
// Alpha values below 1/255 are rendered transparent. | ||
|
||
uniform float alpha; | ||
uniform float far_clip_distance; | ||
|
||
const float minimum_alpha = 1.0 / 255.0; | ||
|
||
varying float depth; | ||
|
||
void main() | ||
{ | ||
float normalized_depth = depth / far_clip_distance; | ||
|
||
// split up float into rgb components | ||
const vec3 shift = vec3(256.0 * 256.0, 256.0, 1.0); | ||
const vec3 mask = vec3(0.0, 1.0 / 256.0, 1.0 / 256.0); | ||
vec3 depth_packed = fract(normalized_depth * shift); | ||
depth_packed -= depth_packed.xxy * mask; | ||
|
||
gl_FragColor = vec4( depth_packed.zyx, step( minimum_alpha, alpha )); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
#version 150 compatibility | ||
#version 330 | ||
|
||
// this merely passes over position and color, | ||
// as needed by box.geom | ||
|
||
out gl_PerVertex { | ||
vec4 gl_Position; | ||
vec4 gl_FrontColor; | ||
}; | ||
layout(location = 0) in vec3 vertex; | ||
layout(location = 3) in vec4 color; | ||
|
||
uniform mat4 uProjection; | ||
|
||
out PerVertex { | ||
vec4 frontColor; | ||
} perVertex; | ||
|
||
|
||
void main() { | ||
gl_Position = gl_Vertex; | ||
gl_FrontColor = gl_Color; | ||
gl_Position = uProjection * vec4(vertex, 1); | ||
perVertex.frontColor = color; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#version 330 | ||
|
||
// rasterizes a smooth square with ax,ay in [-0.5..0.5] | ||
|
||
uniform vec4 highlight; | ||
uniform float alpha; | ||
|
||
in vec4 texCoord[]; | ||
in vec4 frontColor; | ||
|
||
out vec4 fragColor; | ||
|
||
void main() | ||
{ | ||
float ax = texCoord[0].x-0.5; | ||
float ay = texCoord[0].y-0.5; | ||
|
||
float blend = smoothstep(-0.48, -0.45, ay) * (1.0 - smoothstep(0.45, 0.48, ay)) * | ||
smoothstep(-0.48, -0.45, ax) * (1.0 - smoothstep(0.45, 0.48, ax)); | ||
|
||
float inv_blend = 1.0 - blend; | ||
vec3 col = blend * frontColor.xyz + (sign(0.5 - length(vec3(frontColor.xyz))) * vec3(0.2, 0.2, 0.2) + frontColor.xyz) * inv_blend; | ||
|
||
//alternative version: make color at edge darker | ||
//vec3 col = (0.5 + 0.5*blend) * gl_Color.xyz; | ||
|
||
col = col + col * highlight.xyz; | ||
|
||
fragColor = vec4(col.r, col.g, col.b, alpha * frontColor.a ); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these are the only strictly necessary changes in this PR