Skip to content

Commit 0dfe10d

Browse files
authored
Merge pull request #54 from shader-slang/lsp
Shader improvement.
2 parents c8170db + 419dee3 commit 0dfe10d

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

demos/ocean.slang

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ float3 getRay(float2 fragCoord, float2 resolution) {
113113
// for fisheye, uncomment following line and comment the next one
114114
//float3 proj = normalize(float3(uv.x, uv.y, 1.0) + float3(uv.x, uv.y, -1.0) * pow(length(uv), 2.0) * 0.05);
115115
float3 proj = normalize(float3(uv.x, uv.y, 1.5));
116-
if(resolution.x < 600.0) {
116+
if (resolution.x < 40.0 || resolution.y < 40.0) {
117117
return proj;
118118
}
119-
var NormalizedMouse = getMousePosition().xy/float2(resolution);
120-
float3x3 mat = mul(createRotationMatrixAxisAngle(float3(0.0, -1.0, 0.0), 3.0 * ((1.0-NormalizedMouse.x + 0.5) * 2.0 - 1.0)) ,
121-
createRotationMatrixAxisAngle(float3(1.0, 0.0, 0.0), 0.5 + 1.5 * (((NormalizedMouse.y == 0.0 ? 0.35 : NormalizedMouse.y) * 1.0) * 2.0 - 1.0)));
119+
var normalizedMouse = getMousePosition().xy / float2(resolution);
120+
float3x3 mat = mul(createRotationMatrixAxisAngle(float3(0.0, -1.0, 0.0), 3.0 * ((1.0-normalizedMouse.x + 0.5) * 2.0 - 1.0)) ,
121+
createRotationMatrixAxisAngle(float3(1.0, 0.0, 0.0), 0.5 + 1.5 * (((normalizedMouse.y == 0.0 ? 0.35 : normalizedMouse.y) * 1.0) * 2.0 - 1.0)));
122122
return mul(mat, proj);
123123
}
124124

playgroundShader.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ internal struct UniformInput
88
99
internal uniform UniformInput uniformInput;
1010
11-
// Return the current time in milliseconds
11+
// Returns the current time in milliseconds.
1212
public float getTime()
1313
{
1414
return uniformInput.time;
1515
}
1616
1717
// Returns mouse position info.
18-
// xy: mouse position during last button down.
18+
// xy: mouse position (in pixels) during last button down.
1919
// abs(zw): mouse position during last button click.
20-
// sign(mouze.z) = button is down
21-
// sign(mouze.w) = button is clicked
22-
20+
// sign(mouze.z): button is down
21+
// sign(mouze.w): button is clicked
22+
//
2323
public float4 getMousePosition() { return uniformInput.mousePosition; }
2424
2525
// type field: 1 for format string, 2 for normal string, 3 for integer, 4 for float, 5 for double,

0 commit comments

Comments
 (0)