-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from shader-slang/lsp
More demo updates.
- Loading branch information
Showing
6 changed files
with
165 additions
and
84 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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"files.associations": { | ||
"xstring": "cpp", | ||
"atomic": "cpp", | ||
"bit": "cpp", | ||
"cctype": "cpp", | ||
"charconv": "cpp", | ||
"clocale": "cpp", | ||
"cmath": "cpp", | ||
"compare": "cpp", | ||
"concepts": "cpp", | ||
"cstddef": "cpp", | ||
"cstdint": "cpp", | ||
"cstdio": "cpp", | ||
"cstdlib": "cpp", | ||
"cstring": "cpp", | ||
"ctime": "cpp", | ||
"cwchar": "cpp", | ||
"exception": "cpp", | ||
"format": "cpp", | ||
"initializer_list": "cpp", | ||
"ios": "cpp", | ||
"iosfwd": "cpp", | ||
"iostream": "cpp", | ||
"istream": "cpp", | ||
"iterator": "cpp", | ||
"limits": "cpp", | ||
"list": "cpp", | ||
"locale": "cpp", | ||
"memory": "cpp", | ||
"new": "cpp", | ||
"ostream": "cpp", | ||
"stdexcept": "cpp", | ||
"streambuf": "cpp", | ||
"string": "cpp", | ||
"system_error": "cpp", | ||
"tuple": "cpp", | ||
"type_traits": "cpp", | ||
"typeinfo": "cpp", | ||
"unordered_map": "cpp", | ||
"utility": "cpp", | ||
"vector": "cpp", | ||
"xfacet": "cpp", | ||
"xhash": "cpp", | ||
"xiosbase": "cpp", | ||
"xlocale": "cpp", | ||
"xlocbuf": "cpp", | ||
"xlocinfo": "cpp", | ||
"xlocmes": "cpp", | ||
"xlocmon": "cpp", | ||
"xlocnum": "cpp", | ||
"xloctime": "cpp", | ||
"xmemory": "cpp", | ||
"xtr1common": "cpp", | ||
"xutility": "cpp" | ||
} | ||
} |
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,20 +1,50 @@ | ||
// A simple shader ported from https://www.shadertoy.com/view/XdlSDs. | ||
// Author: dynamite | ||
|
||
import playground; | ||
|
||
typealias vec2 = float2; | ||
typealias vec3 = float3; | ||
typealias vec4 = float4; | ||
|
||
float4 imageMain(uint2 dispatchThreadID, int2 screenSize) | ||
{ | ||
float2 size = float2(screenSize.x, screenSize.y); | ||
float2 center = size / 2.0; | ||
|
||
float2 pos = float2(dispatchThreadID.xy); | ||
|
||
float stripSize = screenSize.x / 40; | ||
vec2 p = (dispatchThreadID.xy * 2 - screenSize.xy) / (float)screenSize.y; | ||
float tau = float.getPi() * 2.0; | ||
float a = atan2(p.x,p.y); | ||
float r = length(p)*0.75; | ||
vec2 uv = vec2(a/tau,r); | ||
|
||
float time = getTime() * 0.2; | ||
|
||
const float time = getTime(); // from playgournd | ||
float dist = distance(pos, center) + time; | ||
float strip = dist / stripSize % 2.0; | ||
//get the color | ||
float xCol = (uv.x - time/3) * 3.0; | ||
xCol = fmod(abs(xCol), 3.0f); | ||
vec3 horColour = vec3(0.25, 0.25, 0.25); | ||
|
||
if (xCol < 1.0) | ||
{ | ||
horColour.r += 1.0 - xCol; | ||
horColour.g += xCol; | ||
} | ||
else if (xCol < 2.0) | ||
{ | ||
xCol -= 1.0; | ||
horColour.g += 1.0 - xCol; | ||
horColour.b += xCol; | ||
} | ||
else | ||
{ | ||
xCol -= 2.0; | ||
horColour.b += 1.0 - xCol; | ||
horColour.r += xCol; | ||
} | ||
|
||
if (strip < 1.0f) | ||
return float4(1.0f, 0.0f, 0.0f, 1.0f); | ||
else | ||
return float4(0.0f, 1.0f, 1.0f, 1.0f); | ||
// draw color beam | ||
uv = (2.0 * uv) - 1.0; | ||
float beamWidth = (0.7 + | ||
0.5 * cos(uv.x * 10.0 * tau * 0.15 * clamp(floor(5.0 + 10.0 * cos(time)), 0.0, 10.0))) | ||
* abs(1.0 / (30.0 * uv.y)); | ||
vec3 horBeam = vec3(beamWidth); | ||
return vec4(((horBeam) * horColour), 1.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
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