first commit
This commit is contained in:
commit
fb98172573
287 files changed
+43090
No files matched your search
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"ShaderResources": "shaders"
|
||||
},
|
||||
"LibraryPath": "",
|
||||
"Name": "hdx",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2022 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"BoundingBoxVertex": {
|
||||
"source": [ "BoundingBox.Vertex" ]
|
||||
},
|
||||
"BoundingBoxFragment": {
|
||||
"source": [ "BoundingBox.Fragment" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- glsl BoundingBox.Vertex
|
||||
|
||||
void main(void)
|
||||
{
|
||||
const vec4 clipPos = worldViewProj[hd_InstanceID] * vec4(position,1.0);
|
||||
gl_Position = clipPos;
|
||||
|
||||
// Write out a flat (non-interpolated) screen space position for the
|
||||
// provoking vertex for a line so we can measure how far a fragment
|
||||
// is from that vertex in screen space.
|
||||
dashStart = (clipPos.xy/clipPos.w+vec2(1.0))*(viewport.zw/2.0)+viewport.xy;
|
||||
}
|
||||
|
||||
-- glsl BoundingBox.Fragment
|
||||
|
||||
void main(void)
|
||||
{
|
||||
// Skip any pattern styling if the uniform/constant dashSize is invalid.
|
||||
if (dashSize != 0.0) {
|
||||
// Otherwise create a dashed pattern with equal solid and blank pixel
|
||||
// sections for the line.
|
||||
const float pixelDist = distance(dashStart, gl_FragCoord.xy);
|
||||
if (mod(pixelDist, 2.0*dashSize) > dashSize) {
|
||||
discard;
|
||||
}
|
||||
}
|
||||
|
||||
hd_FragColor = color;
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2019 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"ColorChannelFragment": {
|
||||
"source": [ "ColorChannel.Fragment" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- glsl ColorChannel.Fragment
|
||||
|
||||
|
||||
// Display channel values. These should match the the indices of the entries in
|
||||
// HdxDisplayChannelTokens
|
||||
#define CHANNEL_COLOR 0
|
||||
#define CHANNEL_RED 1
|
||||
#define CHANNEL_GREEN 2
|
||||
#define CHANNEL_BLUE 3
|
||||
#define CHANNEL_ALPHA 4
|
||||
#define CHANNEL_LUMINANCE 5
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 fragCoord = uvOut * screenSize;
|
||||
vec4 color = HgiTexelFetch_colorIn(ivec2(fragCoord));
|
||||
|
||||
// Display Channel
|
||||
if (channel == CHANNEL_RED) {
|
||||
color.g = color.b = color.r;
|
||||
} else if (channel == CHANNEL_GREEN) {
|
||||
color.r = color.b = color.g;
|
||||
} else if (channel == CHANNEL_BLUE) {
|
||||
color.r = color.g = color.b;
|
||||
} else if (channel == CHANNEL_ALPHA) {
|
||||
color.r = color.g = color.b = color.a;
|
||||
} else if (channel == CHANNEL_LUMINANCE) {
|
||||
const vec3 W = vec3(0.30, 0.59, 0.11);
|
||||
color.r = color.g = color.b = dot(color.rgb, W);
|
||||
} // Do nothing if channel == CHANNEL_COLOR
|
||||
|
||||
hd_FragColor = color;
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2018 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"ColorCorrectionVertex": {
|
||||
"source": [ "ColorCorrection.Vertex" ]
|
||||
},
|
||||
"ColorCorrectionFragment": {
|
||||
"source": [ "ColorCorrection.Fragment" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- glsl ColorCorrection.Vertex
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = position;
|
||||
uvOut = uvIn;
|
||||
}
|
||||
|
||||
-- glsl ColorCorrection.Fragment
|
||||
|
||||
// Similar to D3DX_DXGIFormatConvert.inl, but branchless
|
||||
// https://www.shadertoy.com/view/wds3zM
|
||||
vec3 FloatToSRGB(vec3 val)
|
||||
{
|
||||
val = mix((val * 12.92),
|
||||
(1.055 * pow(val, vec3(1.0/2.4)) - 0.055),
|
||||
step(0.0031308, val));
|
||||
return val;
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 fragCoord = uvOut * screenSize;
|
||||
vec4 inCol = HgiTexelFetch_colorIn(ivec2(fragCoord));
|
||||
|
||||
#if defined(GLSLFX_USE_OCIO)
|
||||
inCol = OCIO_DISPLAY_FUNC(inCol);
|
||||
#else
|
||||
// Only color, not alpha is gamma corrected!
|
||||
inCol.rgb = FloatToSRGB(inCol.rgb);
|
||||
#endif
|
||||
|
||||
hd_FragColor = inCol;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2018 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"FullscreenVertex": {
|
||||
"source": [ "Fullscreen.Vertex" ]
|
||||
},
|
||||
"CompositeFragmentNoDepth": {
|
||||
"source": [ "Composite.FragmentNoDepth" ]
|
||||
},
|
||||
"CompositeFragmentWithDepth": {
|
||||
"source": [ "Composite.FragmentWithDepth" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- glsl Fullscreen.Vertex
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = position;
|
||||
uvOut = uvIn;
|
||||
}
|
||||
|
||||
-- glsl Composite.FragmentNoDepth
|
||||
|
||||
void main(void)
|
||||
{
|
||||
hd_FragColor = vec4(HgiGet_colorIn(uvOut));
|
||||
}
|
||||
|
||||
-- glsl Composite.FragmentWithDepth
|
||||
|
||||
void main(void)
|
||||
{
|
||||
float depth = HdGet_depth(uvOut).x;
|
||||
hd_FragColor = vec4(HgiGet_colorIn(uvOut));
|
||||
hd_FragDepth = depth;
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2018 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"fragmentShader": {
|
||||
"source": [ "OitResolve.Image" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- layout OitResolve.Image
|
||||
|
||||
[
|
||||
["buffer readWrite", "CounterBuffer", "hdxOitCounterBuffer",
|
||||
["atomic_int", "hdxOitCounterBuffer"]
|
||||
]
|
||||
]
|
||||
|
||||
-- glsl OitResolve.Image
|
||||
|
||||
vec4 imageShader(vec2 uv)
|
||||
{
|
||||
#if defined(HD_HAS_hdxOitDataBuffer)
|
||||
const int screenWidth = int(HdGet_oitScreenSize().x);
|
||||
const int screenHeight = int(HdGet_oitScreenSize().y);
|
||||
|
||||
// Must match the per-pixel sample count used when creating the OIT buffers.
|
||||
// (See HdxOitResolveTask::_PrepareOitBuffers)
|
||||
const int maxSamples = 8;
|
||||
|
||||
const int dataBufferSize = screenWidth * screenHeight * maxSamples;
|
||||
|
||||
// +1 because index 0 of counter buffer is reserved as atomic counter in
|
||||
// WriteOitLayersToBuffer
|
||||
int screenIndex = int(gl_FragCoord.x) + int(gl_FragCoord.y) * screenWidth;
|
||||
screenIndex += 1;
|
||||
|
||||
int nodeIndex = ATOMIC_LOAD(hdxOitCounterBuffer[screenIndex]);
|
||||
int numDepths = 0;
|
||||
|
||||
// XXX renderPass.WriteOitLayersToBuffer does not clamp the number of
|
||||
// depth samples we store for a pixel. Here we process no more than
|
||||
// 'maxSamples' for a pixel. (If there are greater than 'maxSamples'
|
||||
// samples stored for this pixel some will currently not contribute)
|
||||
vec4 sortedColor[maxSamples];
|
||||
float sortedDepth[maxSamples];
|
||||
|
||||
while (nodeIndex != -1 &&
|
||||
numDepths < maxSamples &&
|
||||
nodeIndex < dataBufferSize)
|
||||
{
|
||||
float currentDepth = hdxOitDepthBuffer[nodeIndex];
|
||||
int insertIndex = numDepths;
|
||||
// Recall that depths are in eye space, so inequality is flipped.
|
||||
while (insertIndex > 0 && sortedDepth[insertIndex - 1] < currentDepth) {
|
||||
sortedDepth[insertIndex] = sortedDepth[insertIndex - 1];
|
||||
sortedColor[insertIndex] = sortedColor[insertIndex - 1];
|
||||
insertIndex -= 1;
|
||||
}
|
||||
sortedColor[insertIndex] = hdxOitDataBuffer[nodeIndex];
|
||||
sortedDepth[insertIndex] = hdxOitDepthBuffer[nodeIndex];
|
||||
numDepths += 1;
|
||||
nodeIndex = hdxOitIndexBuffer[nodeIndex];
|
||||
}
|
||||
|
||||
// Assume color in sortedColor is pre-multiplied by alpha
|
||||
int depth = 0;
|
||||
vec4 colorAccum = vec4(0);
|
||||
while (depth < numDepths) {
|
||||
colorAccum += sortedColor[depth] * (1 - colorAccum.a);
|
||||
|
||||
if (colorAccum.a >= 1.0) break;
|
||||
|
||||
depth += 1;
|
||||
}
|
||||
|
||||
colorAccum = clamp(colorAccum, vec4(0), vec4(1));
|
||||
return colorAccum;
|
||||
#else
|
||||
return vec4(0);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2020 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"OutlineFragment": {
|
||||
"source": [ "Outline.Fragment" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- glsl Outline.Fragment
|
||||
|
||||
#define EPSILON 0.0001
|
||||
#define LARGE 100000
|
||||
|
||||
// The color texture with the highlighted areas.
|
||||
|
||||
// Given a delta x and y in relation to the current texel coordinates, check if
|
||||
// the colorIn texture has a non-black texel and its distance^2 to the current
|
||||
// texel is smaller than the one passed as dist2. The color of that texel will
|
||||
// be returned in the color output var.
|
||||
void testTexel(int x, int y, REF(thread,float) dist2, REF(thread,vec4) color)
|
||||
{
|
||||
vec2 texCoords = uvOut + vec2(x, y) * texelSize;
|
||||
vec4 c = HgiGet_colorIn(texCoords);
|
||||
|
||||
if ( c.r > EPSILON || c.g > EPSILON || c.b > EPSILON) {
|
||||
float d = float(x * x + y * y );
|
||||
if (d < dist2) {
|
||||
dist2 = d;
|
||||
color = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Used by testOctants() to scan each horizontal line in the circle.
|
||||
// Returns the distance^2 and color of the non-black texel that is closest to
|
||||
// the current texel.
|
||||
void testHLine(int x0, int x1, int y, REF(thread,float) dist2, REF(thread,vec4) color) {
|
||||
for (int x = x0; x < x1; x++) {
|
||||
testTexel(x, y, dist2, color);
|
||||
}
|
||||
}
|
||||
|
||||
// Part of the Bresenham algorithm: mirror the circle octant edge coords to
|
||||
// obtain a half circle and then mirror them horizontally to obtain the
|
||||
// horizontal lines that define the circle and its interior.
|
||||
// Returns the distance^2 and color of the non-black texel that is closest to
|
||||
// the current texel.
|
||||
void testOctants(int x, int y, REF(thread,float) dist2, REF(thread,vec4) color) {
|
||||
testHLine(-x, x, y, dist2, color);
|
||||
testHLine(-x, x, -y, dist2, color);
|
||||
testHLine(-y, y, x, dist2, color);
|
||||
testHLine(-y, y, -x, dist2, color);
|
||||
}
|
||||
|
||||
// Find the color and distance^2 to the closest texel in colorIn that is not
|
||||
// black and that is within a circle defined by the specified radius, centered
|
||||
// in the current texel. (Note: distance^2 is used to avoid sqrt).
|
||||
// This uses the Bresenham circle algorithm to discover the texels inside that
|
||||
// circle, to avoid having to read the colorIn texels outside of it.
|
||||
void testCircle(int r, REF(thread,float) dist2, REF(thread,vec4) color) {
|
||||
if (r < 0) { r = 0; }
|
||||
|
||||
int d = 3 - (2 * r);
|
||||
int x = 0;
|
||||
int y = r;
|
||||
|
||||
testOctants(x, y, dist2, color);
|
||||
|
||||
while (x < y) {
|
||||
x++;
|
||||
|
||||
if (d > 0) {
|
||||
y--;
|
||||
d = d + 4 * (x - y) + 10;
|
||||
} else {
|
||||
d = d + 4 * x + 6;
|
||||
}
|
||||
|
||||
testOctants(x, y, dist2, color);
|
||||
}
|
||||
}
|
||||
|
||||
// If radius is 0 then render colorIn as is. If radius > 0 then render only the
|
||||
// outline of the non-black areas in colorIn. The radius will define the
|
||||
// thickness of the outline. The color of each texel in the outline will be
|
||||
// defined by the closest color in colorIn, fading out when the distance to that
|
||||
// colorIn texel equals the radius. This will allow colorIn to potentially hold
|
||||
// several colors that will be respected by the outline.
|
||||
|
||||
void main()
|
||||
{
|
||||
hd_FragColor = vec4(0, 0, 0, 1);
|
||||
// Check if the current texel is not black - meaning that we are inside an
|
||||
// area of colorId that has been highlighted.
|
||||
vec4 color = HgiGet_colorIn(uvOut);
|
||||
bool isInside = color.r > EPSILON || color.g > EPSILON || color.b > EPSILON;
|
||||
|
||||
if (enableOutline==0) {
|
||||
if (isInside) {
|
||||
// Inside the highlighted areas in colorIn : render colorIn.
|
||||
hd_FragColor = color;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (!isInside) {
|
||||
// Outside the highlighted area: render the outline
|
||||
float r2 = float(radius * radius);
|
||||
float dist2 = LARGE;
|
||||
|
||||
// Check if there are any highlighted texels around the current one
|
||||
// inside the specified radius.
|
||||
testCircle(radius, dist2, color);
|
||||
|
||||
// Check if the distance^2 to the closest highlighted texel is within
|
||||
// radius^2.
|
||||
if (dist2 <= r2) {
|
||||
// Attenuate the texel color using the distance^2 to it.
|
||||
float factor = (r2 - dist2 ) / r2;
|
||||
factor *= factor;
|
||||
|
||||
hd_FragColor = color * factor;
|
||||
hd_FragColor.a = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,252 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2019 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdx/shaders/renderPass.glslfx
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
|
||||
-- layout HdxRenderPass.RenderOitOpaquePixels
|
||||
|
||||
[
|
||||
["out", "vec4", "colorOut"]
|
||||
]
|
||||
|
||||
-- glsl HdxRenderPass.RenderOitOpaquePixels
|
||||
|
||||
void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord)
|
||||
{
|
||||
if (color.a >= 1.0) {
|
||||
colorOut = vec4(color.rgb, 1);
|
||||
} else {
|
||||
discard;
|
||||
}
|
||||
}
|
||||
|
||||
-- layout HdxRenderPass.WriteOitLayersToBufferCommon
|
||||
|
||||
[
|
||||
["in", "early_fragment_tests"],
|
||||
["buffer readWrite", "CounterBuffer", "hdxOitCounterBuffer",
|
||||
["atomic_int", "hdxOitCounterBuffer"]
|
||||
]
|
||||
]
|
||||
|
||||
-- glsl HdxRenderPass.WriteOitLayersToBufferCommon
|
||||
|
||||
void RenderOutputImpl(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord)
|
||||
{
|
||||
#if defined(HD_HAS_hdxOitDataBuffer)
|
||||
|
||||
const int screenWidth = int(HdGet_oitScreenSize().x);
|
||||
const int screenHeight = int(HdGet_oitScreenSize().y);
|
||||
// Must match the per-pixel sample count used when creating the OIT buffers.
|
||||
// (See HdxOitResolveTask::_PrepareOitBuffers)
|
||||
const int numSamples = 8;
|
||||
|
||||
const int dataBufferSize = screenWidth * screenHeight * numSamples;
|
||||
const int counterBufferSize = screenWidth * screenHeight + 1;
|
||||
|
||||
// +1 because the counter buffer is cleared with -1, but we want the
|
||||
// first index to start at 0.
|
||||
int writeIndex = ATOMIC_ADD(hdxOitCounterBuffer[0], 1) + 1;
|
||||
|
||||
if (writeIndex < dataBufferSize) {
|
||||
int screenIndex =
|
||||
int(gl_FragCoord.x) + int(gl_FragCoord.y) * screenWidth;
|
||||
|
||||
if (screenIndex < counterBufferSize) {
|
||||
int prevIndex =
|
||||
ATOMIC_EXCHANGE(hdxOitCounterBuffer[screenIndex+1], writeIndex);
|
||||
hdxOitDataBuffer[writeIndex] = color;
|
||||
|
||||
// Note that we have a choice here to either pick gl_FragCoord.z or
|
||||
// the depth value from Peye. The former is obtained by applying
|
||||
// the perspective transform and cannot be changed by a shader.
|
||||
//
|
||||
// We pick Peye here so that a shader has an opportunity to change
|
||||
// the depth of the sample inserted into the OIT list.
|
||||
//
|
||||
// This is used by volumes. However, non-volume translucent
|
||||
// geometry should never modify Peye value and call RenderOutput
|
||||
// with the Peye value from the vertex shader so that it is
|
||||
// consistent with gl_FragCoord. This is because such geometry is
|
||||
// subject to a opaque pixel render pass performing a z-test
|
||||
// against gl_FragCoord.z.
|
||||
//
|
||||
// Note there are implications of using the depth value from Peye
|
||||
// instead of gl_FragCoord.z here for the subsequent OIT resolve
|
||||
// shader: the depth sorting order needs to be flipped and the
|
||||
// OIT resolve shader cannot compare depths in the OIT list
|
||||
// against the depth buffer unless it takes the perspective
|
||||
// transform into account.
|
||||
hdxOitDepthBuffer[writeIndex] = Peye.z / Peye.w;
|
||||
hdxOitIndexBuffer[writeIndex] = prevIndex;
|
||||
}
|
||||
} else {
|
||||
// We may overrun the counter buffer integer and wrap back to 0 if
|
||||
// we have a lot of OIT samples.
|
||||
ATOMIC_ADD(hdxOitCounterBuffer[0], -1);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
-- glsl HdxRenderPass.WriteOitLayersToBufferTranslucent
|
||||
|
||||
void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord)
|
||||
{
|
||||
// There are two render passes for ordinary OIT geometry.
|
||||
// Fragments with alpha >= 1.0 are handled in the first (opaque)
|
||||
// render pass.
|
||||
if (color.a < 1.0 && color.a > 0.0001) {
|
||||
RenderOutputImpl(Peye, Neye, color, patchCoord);
|
||||
}
|
||||
}
|
||||
|
||||
-- glsl HdxRenderPass.WriteOitLayersToBufferVolume
|
||||
|
||||
void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord)
|
||||
{
|
||||
// Unlike ordinary OIT geometry, volumes have only one render pass,
|
||||
// so insert into OIT buffers even if alpha is 1.
|
||||
if (any(greaterThan(color, vec4(0.0001)))) {
|
||||
RenderOutputImpl(Peye, Neye, color, patchCoord);
|
||||
}
|
||||
}
|
||||
|
||||
-- layout HdxRenderPass.RenderPick
|
||||
|
||||
[
|
||||
["out", "vec4", "primIdOut"],
|
||||
["out", "vec4", "instanceIdOut"],
|
||||
["out", "vec4", "elementIdOut"],
|
||||
["out", "vec4", "edgeIdOut"],
|
||||
["out", "vec4", "pointIdOut"],
|
||||
["out", "vec4", "neyeOut"]
|
||||
]
|
||||
|
||||
-- glsl HdxRenderPass.RenderPick
|
||||
|
||||
vec4 IntToVec4(int id)
|
||||
{
|
||||
return vec4(((id >> 0) & 0xff) / 255.0,
|
||||
((id >> 8) & 0xff) / 255.0,
|
||||
((id >> 16) & 0xff) / 255.0,
|
||||
((id >> 24) & 0xff) / 255.0);
|
||||
}
|
||||
|
||||
// Fwd declare necessary methods to determine the subprim id of a fragment.
|
||||
FORWARD_DECL(int GetElementID()); // generated via codeGen
|
||||
FORWARD_DECL(int GetPrimitiveEdgeId()); // defined in edgeId.glslfx, or generated via codeGen
|
||||
FORWARD_DECL(int GetPointId()); // defined in pointId.glslfx
|
||||
|
||||
void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord)
|
||||
{
|
||||
int primId = HdGet_primID();
|
||||
primIdOut = IntToVec4(primId);
|
||||
|
||||
// instanceIndex is a tuple of integers (num nested levels).
|
||||
// for picking, we store global instanceId (instanceIndex[0]) in the
|
||||
// selection framebuffer and then reconstruct the tuple in postprocess.
|
||||
int instanceId = GetDrawingCoord().instanceIndex[0];
|
||||
instanceIdOut = IntToVec4(instanceId);
|
||||
|
||||
elementIdOut = IntToVec4(GetElementID());
|
||||
edgeIdOut = IntToVec4(GetPrimitiveEdgeId());
|
||||
pointIdOut = IntToVec4(GetPointId());
|
||||
|
||||
neyeOut = IntToVec4(hd_vec4_2_10_10_10_set(vec4(Neye,0)));
|
||||
}
|
||||
|
||||
-- layout HdxRenderPass.RenderColorAndSelection
|
||||
|
||||
[
|
||||
["out", "vec4", "colorOut"],
|
||||
["out", "float", "selectedOut"]
|
||||
]
|
||||
|
||||
-- glsl HdxRenderPass.RenderColorAndSelection
|
||||
|
||||
// Note: This mixin expects color and selected color attachments in the bound
|
||||
// FBO. It writes out the computed fragment color and whether it is selected
|
||||
// (as a float, so, 1.0 or 0.0).
|
||||
|
||||
bool IsSelected(); // defined in selection.glslfx
|
||||
|
||||
void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord)
|
||||
{
|
||||
colorOut = color;
|
||||
selectedOut = float(IsSelected());
|
||||
}
|
||||
|
||||
-- layout HdxRenderPass.RenderColorWithOccludedSelection
|
||||
|
||||
[
|
||||
["out", "vec4", "colorOut"]
|
||||
]
|
||||
|
||||
-- glsl HdxRenderPass.RenderColorWithOccludedSelection
|
||||
|
||||
// Note: This mixin expects color and selected color attachments in the bound
|
||||
// FBO. The alpha component of the computed fragment color is adjusted to blend
|
||||
// the existing (destination) fragment color if it is selected.
|
||||
|
||||
bool
|
||||
HasOccludedSelection(vec2 fragcoord)
|
||||
{
|
||||
#ifdef HD_HAS_selectedReadback
|
||||
const float isSelected = texelFetch(HdGetSampler_selectedReadback(),
|
||||
ivec2(fragcoord),
|
||||
0).x;
|
||||
return bool(isSelected);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
float
|
||||
GetShowThroughOpacity()
|
||||
{
|
||||
#ifdef HD_HAS_occludedSelectionOpacity
|
||||
// Note: occludedSelectionOpacity flows in as a parameter to the selection
|
||||
// setup task (HdxSelectionTask)
|
||||
const float dstOpacity = HdGet_occludedSelectionOpacity();
|
||||
// adjust source alpha used to blend source and dst colors.
|
||||
return 1.0 - dstOpacity;
|
||||
#else
|
||||
return 0.5;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Input AOV textures are provided by the task.
|
||||
void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord)
|
||||
{
|
||||
if (HasOccludedSelection(gl_FragCoord.xy)) {
|
||||
color.a = GetShowThroughOpacity();
|
||||
}
|
||||
|
||||
colorOut = color;
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2020 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdx/shaders/renderPassColorAndSelectionShader.glslfx
|
||||
// Render pass shader configuration that writes color and selection information
|
||||
// (whether the fragment is selected).
|
||||
|
||||
#import $TOOLS/hdSt/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/selection.glslfx
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"vertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"postTessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"postTessVertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessEvalShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"geometryShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"fragmentShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.CameraFS",
|
||||
"Selection.DecodeUtils",
|
||||
"Selection.ComputeColor",
|
||||
"Selection.Fragment",
|
||||
"RenderPass.ApplyColorOverrides",
|
||||
"HdxRenderPass.RenderColorAndSelection" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2019 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdx/shaders/renderPassColorShader.glslfx
|
||||
|
||||
#import $TOOLS/hdSt/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/selection.glslfx
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"vertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"postTessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"postTessVertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessEvalShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"geometryShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"fragmentShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.CameraFS",
|
||||
"Selection.DecodeUtils",
|
||||
"Selection.ComputeColor",
|
||||
"RenderPass.ApplyColorOverrides",
|
||||
"RenderPass.RenderColor" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2020 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdx/shaders/renderPassColorWithOccludedSelectionShader.glslfx
|
||||
// Render pass shader configuration that writes color and selection information
|
||||
// (whether the fragment is selected).
|
||||
|
||||
#import $TOOLS/hdSt/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/selection.glslfx
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"vertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"postTessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"postTessVertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessEvalShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"geometryShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"fragmentShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.CameraFS",
|
||||
"Selection.DecodeUtils",
|
||||
"Selection.ComputeColor",
|
||||
"RenderPass.ApplyColorOverrides",
|
||||
"HdxRenderPass.RenderColorWithOccludedSelection" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdx/shaders/renderPassIdShader.glslfx
|
||||
|
||||
#import $TOOLS/hdSt/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/renderPass.glslfx
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"vertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"postTessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"postTessVertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessEvalShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"geometryShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"fragmentShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.CameraFS",
|
||||
"RenderPass.NoSelection",
|
||||
"RenderPass.NoColorOverrides",
|
||||
"RenderPass.RenderId" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2019 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdx/shaders/renderPassOitOpaqueShader.glslfx
|
||||
|
||||
#import $TOOLS/hdSt/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/selection.glslfx
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"vertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"postTessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"postTessVertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessEvalShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"geometryShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"fragmentShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.CameraFS",
|
||||
"Selection.DecodeUtils",
|
||||
"Selection.ComputeColor",
|
||||
"RenderPass.ApplyColorOverrides",
|
||||
"HdxRenderPass.RenderOitOpaquePixels" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2019 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdx/shaders/renderPassOitShader.glslfx
|
||||
|
||||
#import $TOOLS/hdSt/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/selection.glslfx
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"vertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"postTessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"postTessVertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessEvalShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"geometryShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"fragmentShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.CameraFS",
|
||||
"Selection.DecodeUtils",
|
||||
"Selection.ComputeColor",
|
||||
"RenderPass.ApplyColorOverrides",
|
||||
"HdxRenderPass.WriteOitLayersToBufferCommon",
|
||||
"HdxRenderPass.WriteOitLayersToBufferTranslucent" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2019 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdx/shaders/renderPassOitVolumeShader.glslfx
|
||||
|
||||
#import $TOOLS/hdSt/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/selection.glslfx
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"vertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"postTessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"postTessVertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessEvalShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"geometryShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"fragmentShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"Selection.DecodeUtils",
|
||||
"Selection.ComputeColor",
|
||||
"RenderPass.ApplyColorOverrides",
|
||||
"HdxRenderPass.WriteOitLayersToBufferCommon",
|
||||
"HdxRenderPass.WriteOitLayersToBufferVolume" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2019 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdx/shaders/renderPassPickingShader.glslfx
|
||||
|
||||
#import $TOOLS/hdSt/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/renderPass.glslfx
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"vertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"postTessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"postTessVertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessEvalShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"geometryShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"fragmentShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.CameraFS",
|
||||
"RenderPass.NoSelection",
|
||||
"RenderPass.NoColorOverrides",
|
||||
"HdxRenderPass.RenderPick" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdx/shaders/renderPassShadowShader.glslfx
|
||||
|
||||
#import $TOOLS/hdSt/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/renderPass.glslfx
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"vertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"postTessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"postTessVertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessEvalShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"geometryShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"fragmentShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.CameraFS",
|
||||
"RenderPass.NoSelection",
|
||||
"RenderPass.NoColorOverrides",
|
||||
"RenderPass.RenderColor" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,544 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2018 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdx/shaders/selection.glslfx
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Selection.DecodeUtils
|
||||
/// Decoding utilities for selection highlighting.
|
||||
/// This mixin may be safely included by any shader stage. Its lone dependency
|
||||
/// on code generation is the hdxSelectionBuffer SSBO that holds the encoded
|
||||
/// selection state.
|
||||
|
||||
// This should match the HdSelection enum.
|
||||
int GetMaxNumSelectionHighlightModes()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
#if defined(HD_HAS_hdxSelectionBuffer)
|
||||
// helper methods to decode hdxSelectionBuffer
|
||||
// ------ selection highlight mode specifics -------
|
||||
bool HighlightModeHasSelection(int offset)
|
||||
{
|
||||
return (offset != 0);
|
||||
}
|
||||
|
||||
int GetIndexOffsetForHighlightMode(int mode)
|
||||
{
|
||||
return HdGet_hdxSelectionBuffer(mode + 1/*[0] holds #modes*/);
|
||||
}
|
||||
|
||||
int GetNumSelectionHighlightModes()
|
||||
{
|
||||
return HdGet_hdxSelectionBuffer(0);
|
||||
}
|
||||
|
||||
// ------ selection offset specifics -------
|
||||
// Note: This should match the selection offset encoding in
|
||||
// hdx/SelectionTracker.cpp
|
||||
void DecodeSelOffset(int selOffset, REF(thread, bool) isSelected,
|
||||
REF(thread, int) nextOffset)
|
||||
{
|
||||
isSelected = bool(selOffset & 0x1); // bit 0
|
||||
nextOffset = selOffset >> 1; // bits 31:1
|
||||
}
|
||||
|
||||
// --------- subprim decoding ----------
|
||||
// Each subprims offsets' buffer encoding is:
|
||||
// [subprim-type][min][max][ selOffsets ]
|
||||
// <----------3 ----------><--- max - min + 1 -->
|
||||
struct SubprimHeader {
|
||||
int type;
|
||||
int min;
|
||||
int max;
|
||||
};
|
||||
SubprimHeader DecodeSubprimHeader(int offset)
|
||||
{
|
||||
SubprimHeader header;
|
||||
header.type = HdGet_hdxSelectionBuffer(offset );
|
||||
header.min = HdGet_hdxSelectionBuffer(offset + 1);
|
||||
header.max = HdGet_hdxSelectionBuffer(offset + 2);
|
||||
return header;
|
||||
}
|
||||
|
||||
bool IsSubprimSelected(int id, int min, int max, int headerStart,
|
||||
REF(thread, int) nextSubprimOffset)
|
||||
{
|
||||
const int SUBPRIM_SELOFFSETS_HEADER_SIZE = 3;
|
||||
|
||||
nextSubprimOffset = 0; // initialize
|
||||
bool isSelected = false;
|
||||
|
||||
if (id >= min && id < max) {
|
||||
int netSubprimIndex =
|
||||
headerStart + SUBPRIM_SELOFFSETS_HEADER_SIZE + id - min;
|
||||
int selOffset = HdGet_hdxSelectionBuffer(netSubprimIndex);
|
||||
|
||||
DecodeSelOffset(selOffset, /*out*/isSelected, /*out*/nextSubprimOffset);
|
||||
} else {
|
||||
// The subprim id does not fall in the selected id range, so the subprim
|
||||
// in question isn't selected. However, we can still have other
|
||||
// subprim(s) selected. To get the offset to jump to, we mimic decoding
|
||||
// the "min" subprim id.
|
||||
int minSubprimIndex = headerStart + SUBPRIM_SELOFFSETS_HEADER_SIZE;
|
||||
DecodeSelOffset(HdGet_hdxSelectionBuffer(minSubprimIndex),
|
||||
/*out*/isSelected, /*out*/nextSubprimOffset);
|
||||
isSelected = false;
|
||||
}
|
||||
|
||||
return isSelected;
|
||||
}
|
||||
#endif // HD_HAS_hdxSelectionBuffer
|
||||
|
||||
// Keep the result struct definition outside guards.
|
||||
struct SubprimSelectionResult {
|
||||
bool elementSelected;
|
||||
bool edgeSelected;
|
||||
bool pointSelected;
|
||||
int pointColorId;
|
||||
};
|
||||
|
||||
SubprimSelectionResult InitSubprimSelectionResult(
|
||||
bool _elementSelected,
|
||||
bool _edgeSelected,
|
||||
bool _pointSelected,
|
||||
int _pointColorId)
|
||||
{
|
||||
SubprimSelectionResult res;
|
||||
|
||||
res.elementSelected = _elementSelected;
|
||||
res.edgeSelected = _edgeSelected;
|
||||
res.pointSelected = _pointSelected;
|
||||
res.pointColorId = _pointColorId;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool IsAnySubprimSelected(SubprimSelectionResult s)
|
||||
{
|
||||
return (s.elementSelected || s.edgeSelected || s.pointSelected);
|
||||
}
|
||||
bool HasCustomizedPointColor(SubprimSelectionResult s)
|
||||
{
|
||||
// Use -1 to encode selected points that don't have a custom point color.
|
||||
return (s.pointColorId != -1);
|
||||
}
|
||||
|
||||
#if defined(HD_HAS_hdxSelectionBuffer)
|
||||
// Note: These should match the SubprimType enum in hdx/SelectionTracker.cpp
|
||||
#define SUBPRIM_TYPE_ELEMENT 0
|
||||
#define SUBPRIM_TYPE_EDGE 1
|
||||
#define SUBPRIM_TYPE_POINT 2
|
||||
#define SUBPRIM_TYPE_INSTANCE 3
|
||||
|
||||
SubprimSelectionResult GetSubprimSel(int offset,
|
||||
int elementId, int edgeId, int pointId)
|
||||
{
|
||||
SubprimSelectionResult s = InitSubprimSelectionResult(false, false, false, 0);
|
||||
|
||||
int nextSubprimOffset = 0;
|
||||
SubprimHeader header = DecodeSubprimHeader(offset);
|
||||
|
||||
if (header.type == SUBPRIM_TYPE_ELEMENT) {
|
||||
s.elementSelected =
|
||||
IsSubprimSelected(elementId, header.min, header.max,
|
||||
offset, /*out*/nextSubprimOffset);
|
||||
|
||||
if (nextSubprimOffset != 0) {
|
||||
// fragment has additional subprim(s) selected. update header.
|
||||
header = DecodeSubprimHeader(nextSubprimOffset);
|
||||
offset = nextSubprimOffset;
|
||||
}
|
||||
}
|
||||
|
||||
if (header.type == SUBPRIM_TYPE_EDGE) {
|
||||
s.edgeSelected =
|
||||
IsSubprimSelected(edgeId, header.min, header.max,
|
||||
offset, /*out*/nextSubprimOffset);
|
||||
|
||||
if (nextSubprimOffset != 0) {
|
||||
// fragment has points selected. update header.
|
||||
header = DecodeSubprimHeader(nextSubprimOffset);
|
||||
offset = nextSubprimOffset;
|
||||
}
|
||||
}
|
||||
|
||||
if (header.type == SUBPRIM_TYPE_POINT) {
|
||||
s.pointSelected =
|
||||
IsSubprimSelected(pointId, header.min, header.max,
|
||||
offset, /*unused*/nextSubprimOffset);
|
||||
// For points alone, since there isn't any subprim to follow it, the
|
||||
// offset field is overriden to represent the index into the
|
||||
// selectedPointColors buffer to support customized coloring of a set of
|
||||
// selected points.
|
||||
s.pointColorId = nextSubprimOffset;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
// --------- instance decoding ----------
|
||||
bool IsInstanceSelected(int offset, REF(thread, int) nextOffset)
|
||||
{
|
||||
// If we don't find an instance subprim block, pass the same offset to
|
||||
// GetSubprimSel.
|
||||
nextOffset = offset;
|
||||
bool sel = false;
|
||||
|
||||
int instanceId = GetDrawingCoord().instanceIndex[0];
|
||||
|
||||
SubprimHeader header = DecodeSubprimHeader(offset);
|
||||
if (header.type == SUBPRIM_TYPE_INSTANCE) {
|
||||
sel =
|
||||
IsSubprimSelected(instanceId, header.min, header.max,
|
||||
offset, /*out*/nextOffset);
|
||||
}
|
||||
|
||||
return sel;
|
||||
}
|
||||
#endif // HD_HAS_hdxSelectionBuffer
|
||||
|
||||
// --------- selection buffer decoding entry point ----------
|
||||
struct SelectionResult {
|
||||
bool primOrInstanceSel;
|
||||
SubprimSelectionResult subprimSel;
|
||||
};
|
||||
|
||||
SelectionResult InitSelectionResult(
|
||||
bool _primOrInstanceSel,
|
||||
bool _elementSelected,
|
||||
bool _edgeSelected,
|
||||
bool _pointSelected,
|
||||
int _pointColorId)
|
||||
{
|
||||
SelectionResult res;
|
||||
|
||||
res.primOrInstanceSel = _primOrInstanceSel;
|
||||
res.subprimSel = InitSubprimSelectionResult(
|
||||
_elementSelected, _edgeSelected,
|
||||
_pointSelected, _pointColorId);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
// Decodes the selection buffer encoding scheme for a given mode, and returns
|
||||
// the selection result.
|
||||
SelectionResult GetSelectionResult(int mode,
|
||||
int elementId, int edgeId, int pointId)
|
||||
{
|
||||
SelectionResult res = InitSelectionResult(false, false, false, false, 0);
|
||||
|
||||
#if defined(HD_HAS_hdxSelectionBuffer)
|
||||
// The hdxSelectionBuffer layout is:
|
||||
// [#modes] [per-mode offset] [data mode0] ... [data modeM]
|
||||
// [---------header---------]
|
||||
// Each mode's data is laid out as:
|
||||
// [ prims | points | edges | elements | instance level-N | ... | level 0 ]
|
||||
// <-------- subprims -------> <----------- instances --------->
|
||||
// <---------------------- per prim ---------------------------->
|
||||
// See hdx/SelectionTracker.cpp for details on the encoding scheme.
|
||||
int modeOffset = GetIndexOffsetForHighlightMode(mode);
|
||||
if (!HighlightModeHasSelection(modeOffset)) {
|
||||
// highlight mode has no selected objects (prims/instances/elements)
|
||||
return res;
|
||||
}
|
||||
|
||||
const int PRIM_SELOFFSETS_HEADER_SIZE = 2;
|
||||
const int primId = HdGet_primID();
|
||||
int smin = HdGet_hdxSelectionBuffer(modeOffset);
|
||||
int smax = HdGet_hdxSelectionBuffer(modeOffset + 1);
|
||||
|
||||
if (primId >= smin && primId < smax) {
|
||||
int offset = modeOffset + PRIM_SELOFFSETS_HEADER_SIZE + primId - smin;
|
||||
int nextOffset = 0;
|
||||
bool sel = false;
|
||||
DecodeSelOffset(HdGet_hdxSelectionBuffer(offset),
|
||||
/*out*/sel, /*out*/nextOffset);
|
||||
|
||||
// At this point, sel indicates whether the fragment corresponds to
|
||||
// a prim that needs to be fully highlighted, while a non-zero
|
||||
// nextOffset indicates whether additional decoding may be done.
|
||||
|
||||
// We don't currently differentiate between prim, instance and
|
||||
// subprim selection highlighting (i.e., visually, they look the
|
||||
// same), and thus can skip additional decoding if sel is true.
|
||||
// We choose not to, for ease of future customization.
|
||||
if (nextOffset != 0) {
|
||||
// check if instance (or) subprim(s) are selected
|
||||
offset = nextOffset;
|
||||
sel = sel || IsInstanceSelected(offset, /*out*/nextOffset);
|
||||
|
||||
if (nextOffset != 0) {
|
||||
res.subprimSel =
|
||||
GetSubprimSel(nextOffset, elementId, edgeId, pointId);
|
||||
}
|
||||
}
|
||||
res.primOrInstanceSel = sel;
|
||||
}
|
||||
#endif // HD_HAS_hdxSelectionBuffer
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// Returns the logical OR of the inputs
|
||||
SelectionResult
|
||||
_CombineWithOr(SelectionResult a, SelectionResult b)
|
||||
{
|
||||
SelectionResult res = InitSelectionResult(false, false, false, false, 0);
|
||||
|
||||
res.primOrInstanceSel = a.primOrInstanceSel || b.primOrInstanceSel;
|
||||
res.subprimSel.elementSelected = a.subprimSel.elementSelected ||
|
||||
b.subprimSel.elementSelected;
|
||||
res.subprimSel.edgeSelected = a.subprimSel.edgeSelected ||
|
||||
b.subprimSel.edgeSelected;
|
||||
res.subprimSel.pointSelected = a.subprimSel.pointSelected ||
|
||||
b.subprimSel.pointSelected;
|
||||
// pointColorIndex is ignored.
|
||||
return res;
|
||||
}
|
||||
|
||||
// Returns the net selection result aggregating the result of each selection
|
||||
// mode.
|
||||
SelectionResult GetNetSelectionResult(int elementId, int edgeId, int pointId)
|
||||
{
|
||||
SelectionResult netResult = InitSelectionResult(false, false, false, false, 0);
|
||||
|
||||
#if defined(HD_HAS_hdxSelectionBuffer)
|
||||
const int numSelectionModes = GetNumSelectionHighlightModes();
|
||||
for (int mode = 0; mode < numSelectionModes; mode++) {
|
||||
SelectionResult modeResult =
|
||||
GetSelectionResult(mode, elementId, edgeId, pointId);
|
||||
netResult = _CombineWithOr(modeResult, netResult);
|
||||
}
|
||||
#endif
|
||||
return netResult;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Selection.Vertex.PointSel
|
||||
// Mixin for use in the vertex shader stage.
|
||||
// Decodes the selection buffer to find out if the current vertex (point) is
|
||||
// selected. This is called from hdSt/shaders/pointId.glslfx
|
||||
bool IsPointSelected(int pointId)
|
||||
{
|
||||
bool sel = false;
|
||||
#if defined(HD_HAS_hdxSelectionBuffer)
|
||||
const int numSelectionModes = GetNumSelectionHighlightModes();
|
||||
for (int mode = 0; mode < numSelectionModes; mode++) {
|
||||
// At the VS stage, we don't carry enough state to determine the
|
||||
// elementId and edgeId. So, use fallback values instead.
|
||||
SelectionResult res =
|
||||
GetSelectionResult(mode, /*elementId*/-1, /*edgeId*/-1, pointId);
|
||||
if (res.subprimSel.pointSelected &&
|
||||
!HasCustomizedPointColor(res.subprimSel)) {
|
||||
sel = true;
|
||||
break;
|
||||
}
|
||||
} // for each highlight mode
|
||||
#endif
|
||||
return sel;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Selection.Geometry.ElementSel
|
||||
// Mixin for use in the geometry shader stage.
|
||||
// Helper functions to determine if the element (face) is selected for either
|
||||
// a given selection mode, or any of the modes.
|
||||
|
||||
FORWARD_DECL(int GetElementID()); // code gen
|
||||
|
||||
bool IsElementSelected(int mode)
|
||||
{
|
||||
bool sel = false;
|
||||
#if defined(HD_HAS_hdxSelectionBuffer)
|
||||
const int numSelectionModes = GetNumSelectionHighlightModes();
|
||||
if (mode < numSelectionModes) {
|
||||
SelectionResult res =
|
||||
GetSelectionResult(mode, GetElementID(),
|
||||
/*edgeId*/-1, /*pointId*/-1);
|
||||
if (res.subprimSel.elementSelected) {
|
||||
sel = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return sel;
|
||||
}
|
||||
|
||||
bool IsSelected()
|
||||
{
|
||||
// Edge and point selection aren't relevant at the GS stage.
|
||||
SelectionResult res = GetNetSelectionResult(
|
||||
GetElementID(), /*edgeId*/-1, /*pointId*/-1);
|
||||
|
||||
return res.primOrInstanceSel || res.subprimSel.elementSelected;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Selection.Geometry.WireSelOffset
|
||||
// Mixin for use in the geometry shader stage for wireframe rendering.
|
||||
// See comment below.
|
||||
|
||||
FORWARD_DECL(int GetMaxNumSelectionHighlightModes());
|
||||
FORWARD_DECL(bool IsElementSelected(int mode));
|
||||
FORWARD_DECL(int GetElementID()); // code gen
|
||||
|
||||
vec4 ComputeSelectionOffset()
|
||||
{
|
||||
// For wireframe, we only render the edges of faces. Because we don't have
|
||||
// a way to control which face gets rasterized first, if face A is selected
|
||||
// and face B is unselected, it's possible for face B to draw over face A
|
||||
// and for the highlight to be dropped.
|
||||
|
||||
// To compensate for this, since we're running the geometry shader anyway,
|
||||
// add a small polygon offset for selected faces, to push them in front of
|
||||
// unselected faces.
|
||||
|
||||
// For doubly-selected faces (e.g. rollover & selection), apply a double
|
||||
// offset. The code below chooses a unique offset for each combination
|
||||
// of selection modes by constructing a bitmask of selection modes for
|
||||
// this face, and reinterpreting it as an integer.
|
||||
|
||||
int offset = 0;
|
||||
|
||||
int numModes = GetMaxNumSelectionHighlightModes();
|
||||
for (int mode = 0; mode < numModes; ++mode) {
|
||||
if (IsElementSelected(mode)) {
|
||||
offset += (1 << mode);
|
||||
}
|
||||
}
|
||||
|
||||
// Note: for our base epsilon, we're choosing this somewhat arbitrarily.
|
||||
// This is an eye space epsilon, so it's not dependent on distance-from-
|
||||
// camera. Rather, it's dependent on scene scale. 1e-3 works well for
|
||||
// our scenes, but if this causes trouble we could use an epsilon based on
|
||||
// the eye-space distance of a z-buffer bit flip, which would match the
|
||||
// behavior of glPolygonOffset better, at the cost of more math and some
|
||||
// extra shader uniforms.
|
||||
float eps = 1e-3;
|
||||
|
||||
return vec4(0, 0, offset * eps, 0);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Selection.Geometry.WireSelNoOffset
|
||||
|
||||
vec4 ComputeSelectionOffset()
|
||||
{
|
||||
return vec4(0);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Selection.Fragment
|
||||
// Mixin for use in the fragment shader stage to determine if the fragment is
|
||||
// selected.
|
||||
|
||||
FORWARD_DECL(int GetElementID()); // generated via codeGen
|
||||
FORWARD_DECL(int GetPrimitiveEdgeId()); // defined in edgeId.glslfx, or generated via codeGen
|
||||
FORWARD_DECL(int GetPointId()); // defined in pointId.glslfx
|
||||
|
||||
bool IsSelected()
|
||||
{
|
||||
SelectionResult res = GetNetSelectionResult(
|
||||
GetElementID(), GetPrimitiveEdgeId(), GetPointId());
|
||||
|
||||
return res.primOrInstanceSel || res.subprimSel.elementSelected;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Selection.ComputeColor
|
||||
|
||||
#if defined(HD_HAS_hdxSelectionBuffer)
|
||||
vec4 GetSelectionColor(int mode)
|
||||
{
|
||||
vec4 s = vec4(0,0,0,0);
|
||||
// XXX: Make selection colors an array so we can avoid the branching.
|
||||
if (mode == 0)
|
||||
s = HdGet_selColor();
|
||||
else if (mode == 1)
|
||||
s = HdGet_selLocateColor();
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
// fwd decl fn defined in edgeId.glslfx or generated via codeGen
|
||||
FORWARD_DECL(float GetSelectedEdgeOpacity());
|
||||
|
||||
vec4 GetSubprimSelectionColor(int mode, SubprimSelectionResult res)
|
||||
{
|
||||
vec4 s = GetSelectionColor(mode);
|
||||
if (res.edgeSelected) {
|
||||
s.a = GetSelectedEdgeOpacity();
|
||||
}
|
||||
if (res.pointSelected && HasCustomizedPointColor(res)) {
|
||||
#if defined(HD_HAS_selectionPointColors)
|
||||
s = HdGet_selectionPointColors(res.pointColorId);
|
||||
#endif
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Fwd declare necessary methods to determine the subprim id of a fragment.
|
||||
FORWARD_DECL(int GetElementID()); // generated via codeGen
|
||||
FORWARD_DECL(int GetPrimitiveEdgeId()); // defined in edgeId.glslfx, or generated via codeGen
|
||||
FORWARD_DECL(int GetPointId()); // defined in pointId.glslfx
|
||||
|
||||
// Decodes the selection buffer to find out if the current fragment is from
|
||||
// a prim/instance/subprim that is selected, applies selection highlighting to
|
||||
// the incoming color, and returns the resulting color.
|
||||
vec4 ApplySelectionColor(vec4 color)
|
||||
{
|
||||
#if defined(HD_HAS_hdxSelectionBuffer)
|
||||
int elementId = GetElementID();
|
||||
int edgeId = GetPrimitiveEdgeId();
|
||||
int pointId = GetPointId();
|
||||
|
||||
const int numSelectionModes = GetNumSelectionHighlightModes();
|
||||
|
||||
bool isSelected = false;
|
||||
for (int mode = 0; mode < numSelectionModes; mode++) {
|
||||
SelectionResult res =
|
||||
GetSelectionResult(mode, elementId, edgeId, pointId);
|
||||
|
||||
if (res.primOrInstanceSel) {
|
||||
isSelected = true;
|
||||
vec4 s = GetSelectionColor(mode);
|
||||
color.rgb = mix(color.rgb, s.rgb, s.a);
|
||||
}
|
||||
if (IsAnySubprimSelected(res.subprimSel)) {
|
||||
isSelected = true;
|
||||
vec4 ss = GetSubprimSelectionColor(mode, res.subprimSel);
|
||||
color.rgb = mix(color.rgb, ss.rgb, ss.a);
|
||||
}
|
||||
} // for each highlight mode
|
||||
|
||||
#endif
|
||||
return color;
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2021 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"SkydomeFragment": {
|
||||
"source": [ "Skydome.Fragment" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- glsl Skydome.Fragment
|
||||
|
||||
const float PI = 3.1415926535898;
|
||||
const float farPlane = 1.0;
|
||||
|
||||
float wrapSampleValue(float value)
|
||||
{
|
||||
if (value < 0.0) {
|
||||
value += 1.0;
|
||||
}
|
||||
else if (value > 1.0) {
|
||||
value -= 1.0;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
// from PreviewSurface.glslfx
|
||||
vec2 projectToLatLong(vec3 sample3D)
|
||||
{
|
||||
// project spherical coord onto latitude-longitude map with
|
||||
// latitude: +y == pi/2 and longitude: +z == 0, +x == pi/2
|
||||
float x = (atan(sample3D.z, sample3D.x) + 0.5 * PI) / (2.0 * PI);
|
||||
float y = acos(sample3D.y) / PI;
|
||||
|
||||
return vec2(wrapSampleValue(x), wrapSampleValue(y));
|
||||
}
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
// Transform the UV coordinates into NDC space and place at the far plane
|
||||
// (z = 1) before transforming into view space.
|
||||
vec2 uvOut_ndc = (uvOut * vec2(2.0)) - vec2(1.0);
|
||||
vec4 uvOut_view = invProjMatrix * vec4(uvOut_ndc, farPlane, 1.0);
|
||||
|
||||
// Normalize to use as the initial sampleDirection
|
||||
vec3 sampleDirection = normalize(uvOut_view.xyz);
|
||||
|
||||
// Apply the camera rotation and lightTransform to the sampleDirection
|
||||
sampleDirection =
|
||||
( lightTransform * viewToWorld * vec4(sampleDirection, 0.0) ).xyz;
|
||||
|
||||
// Sample Skydome Texture with the sampleDirection
|
||||
vec2 sampleCoord = projectToLatLong(sampleDirection);
|
||||
hd_FragColor = vec4(HgiGet_skydomeTexture(sampleCoord).xyz, 1.0);
|
||||
gl_FragDepth = farPlane;
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2021 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"VisualizeVertex": {
|
||||
"source": [ "Visualize.Vertex" ]
|
||||
},
|
||||
"VisualizeFragmentDepth": {
|
||||
"source": [ "Visualize.Fragment.Depth" ]
|
||||
},
|
||||
"VisualizeFragmentId": {
|
||||
"source": [ "Visualize.Fragment.Id" ]
|
||||
},
|
||||
"VisualizeFragmentNormal": {
|
||||
"source": [ "Visualize.Fragment.Normal" ]
|
||||
},
|
||||
"VisualizeFragmentFallback": {
|
||||
"source": [ "Visualize.Fragment.Fallback" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- glsl Visualize.Vertex
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = position;
|
||||
uvOut = uvIn;
|
||||
}
|
||||
|
||||
-- glsl Visualize.Fragment.Depth
|
||||
|
||||
// Re-normalize clip space depth in the range [0.0, 1.0] to the range [min, max]
|
||||
// to allow better visualization of depth differences.
|
||||
float normalizeDepth(float depth)
|
||||
{
|
||||
float min = minMaxDepth.x, max = minMaxDepth.y;
|
||||
return (depth - min) / (max - min);
|
||||
}
|
||||
|
||||
// Display the renormalized depth as a grayscale image.
|
||||
void main(void)
|
||||
{
|
||||
vec2 fragCoord = uvOut * screenSize;
|
||||
float depth = HgiTexelFetch_depthIn(ivec2(fragCoord)).x;
|
||||
hd_FragColor = vec4( vec3(normalizeDepth(depth)), 1.0 );
|
||||
}
|
||||
|
||||
-- glsl Visualize.Fragment.Id
|
||||
|
||||
// Convert a 32 bit integer into a vec3 color.
|
||||
vec3 IntToVec3(int id)
|
||||
{
|
||||
// Create a 24 bit value by XORing the leading 8 bits with the remaining
|
||||
// 24 bits.
|
||||
int leadBits = id >> 24;
|
||||
int restBits = (id << 8) >> 8;
|
||||
int result = restBits ^ leadBits;
|
||||
|
||||
return vec3(((result >> 0) & 0xff) / 255.0,
|
||||
((result >> 8) & 0xff) / 255.0,
|
||||
((result >> 16) & 0xff) / 255.0);
|
||||
}
|
||||
|
||||
// Convert a 32 bit integer representing the ID of a primitive or sub-primitive
|
||||
// into a color such that consecutive IDs generally map to different colors.
|
||||
void main(void)
|
||||
{
|
||||
vec2 fragCoord = uvOut * screenSize;
|
||||
int id = int(HgiTexelFetch_idIn(ivec2(fragCoord)).x);
|
||||
int vizId = id * 11629091; // prime number near ln(2) * 2^24
|
||||
hd_FragColor = vec4(IntToVec3(vizId), 1.0);
|
||||
}
|
||||
|
||||
-- glsl Visualize.Fragment.Normal
|
||||
|
||||
// [-1,1] to [0,1]
|
||||
vec3 renormalize(vec3 normal)
|
||||
{
|
||||
return 0.5 * normal + 0.5;
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 fragCoord = uvOut * screenSize;
|
||||
vec3 normal = HgiTexelFetch_normalIn(ivec2(fragCoord)).xyz;
|
||||
hd_FragColor = vec4(renormalize(normal), 1.0);
|
||||
}
|
||||
|
||||
-- glsl Visualize.Fragment.Fallback
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 fragCoord = uvOut * screenSize;
|
||||
// Force conversion to a vector of floats.
|
||||
hd_FragColor = vec4(HgiTexelFetch_aovIn(ivec2(fragCoord)));
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user