-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
115 additions
and
12 deletions.
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
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
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,20 @@ | ||
#include<clipPlaneFragmentDeclaration> | ||
|
||
uniform color: vec4f; | ||
|
||
#include<logDepthDeclaration> | ||
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS | ||
|
||
@fragment | ||
fn main(input: FragmentInputs) -> FragmentOutputs { | ||
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN | ||
|
||
#include<logDepthFragment> | ||
|
||
#include<clipPlaneFragment> | ||
fragmentOutputs.color = uniforms.color; | ||
|
||
#define CUSTOM_FRAGMENT_MAIN_END | ||
} |
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,58 @@ | ||
// Uniforms | ||
#define ADDITIONAL_VERTEX_DECLARATION | ||
|
||
#include<instancesDeclaration> | ||
|
||
#include<clipPlaneVertexDeclaration> | ||
|
||
#include<sceneUboDeclaration> | ||
#include<meshUboDeclaration> | ||
|
||
// Attributes | ||
attribute position: vec3f; | ||
attribute normal: vec4f; | ||
|
||
uniform width: f32; | ||
uniform aspectRatio: f32; | ||
|
||
#include<logDepthDeclaration> | ||
|
||
#define CUSTOM_VERTEX_DEFINITIONS | ||
|
||
@vertex | ||
fn main(input : VertexInputs) -> FragmentInputs { | ||
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN | ||
|
||
#include<instancesVertex> | ||
|
||
var worldViewProjection: mat4x4f = scene.viewProjection * finalWorld; | ||
|
||
var viewPosition: vec4f = worldViewProjection * vec4f(input.position, 1.0); | ||
var viewPositionNext: vec4f = worldViewProjection * vec4f(input.normal.xyz, 1.0); | ||
|
||
var currentScreen: vec2f = viewPosition.xy / viewPosition.w; | ||
var nextScreen: vec2f = viewPositionNext.xy / viewPositionNext.w; | ||
|
||
currentScreen = vec2f(currentScreen.x * uniforms.aspectRatio, currentScreen.y); | ||
nextScreen = vec2f(nextScreen.x * uniforms.aspectRatio, nextScreen.y); | ||
|
||
var dir: vec2f = normalize(nextScreen - currentScreen); | ||
var normalDir: vec2f = vec2f(-dir.y, dir.x); | ||
|
||
normalDir *= uniforms.width / 2.0; | ||
normalDir = vec2f(normalDir.x / uniforms.aspectRatio, normalDir.y); | ||
|
||
var offset: vec4f = vec4f(normalDir * input.normal.w, 0.0, 0.0); | ||
vertexOutputs.position = viewPosition + offset; | ||
|
||
#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6) | ||
var worldPos: vec4f = finalWorld * vec4f(input.position, 1.0); | ||
#include<clipPlaneVertex> | ||
#endif | ||
|
||
#include<logDepthVertex> | ||
|
||
#define CUSTOM_VERTEX_MAIN_END | ||
|
||
} |