forked from playcanvas/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix gsplat example (playcanvas#6754)
- Loading branch information
Showing
1 changed file
with
35 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,44 @@ | ||
uniform float uTime; | ||
varying float height; | ||
|
||
void animate() { | ||
// modify center | ||
float heightIntensity = center.y * 0.2; | ||
center.x += sin(uTime * 5.0 + center.y) * 0.3 * heightIntensity; | ||
|
||
// output y-coordinate | ||
height = center.y; | ||
} | ||
|
||
vec4 discardVec = vec4(0.0, 0.0, 2.0, 1.0); | ||
|
||
void main(void) | ||
{ | ||
// evaluate center of the splat in object space | ||
vec3 centerLocal = evalCenter(); | ||
// calculate splat uv | ||
if (!calcSplatUV()) { | ||
gl_Position = discardVec; | ||
return; | ||
} | ||
|
||
// modify it | ||
float heightIntensity = centerLocal.y * 0.2; | ||
centerLocal.x += sin(uTime * 5.0 + centerLocal.y) * 0.3 * heightIntensity; | ||
// read data | ||
readData(); | ||
|
||
// output y-coordinate | ||
height = centerLocal.y; | ||
// animate | ||
animate(); | ||
|
||
vec4 pos; | ||
if (!evalSplat(pos)) { | ||
gl_Position = discardVec; | ||
return; | ||
} | ||
|
||
gl_Position = pos; | ||
|
||
texCoord = vertex_position.xy; | ||
color = getColor(); | ||
|
||
#ifndef DITHER_NONE | ||
id = float(splatId); | ||
#endif | ||
|
||
// evaluate the rest of the splat using world space center | ||
vec4 centerWorld = matrix_model * vec4(centerLocal, 1.0); | ||
gl_Position = evalSplat(centerWorld); | ||
} |