{"id":18979634,"url":"https://github.com/reputeless/sivshader","last_synced_at":"2025-11-11T07:02:00.452Z","repository":{"id":67723714,"uuid":"68719225","full_name":"Reputeless/SivShader","owner":"Reputeless","description":null,"archived":false,"fork":false,"pushed_at":"2018-09-24T08:21:12.000Z","size":327,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-01T10:44:38.075Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Reputeless.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-20T14:18:40.000Z","updated_at":"2018-09-24T08:21:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"c36a642a-80ee-4dd3-9a48-a0dcdbf15426","html_url":"https://github.com/Reputeless/SivShader","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Reputeless%2FSivShader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Reputeless%2FSivShader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Reputeless%2FSivShader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Reputeless%2FSivShader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Reputeless","download_url":"https://codeload.github.com/Reputeless/SivShader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239985688,"owners_count":19729512,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T15:44:16.112Z","updated_at":"2025-11-11T07:02:00.374Z","avatar_url":"https://github.com/Reputeless.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SivShader\n\n### 使い方\n- Main.cpp と Shader.hlsl を Siv3D プロジェクトにコピー\n\n### 操作\n- HLSL ファイルを更新するとシェーダを更新\n- 画像ファイルを画面にドロップするとテクスチャを更新\n- スペースキーを押すと再読み込み\n\n### シェーダ入力\n\n|型|名前|説明|\n|----|----|----|\n|float2|g_resolution|ウィンドウの解像度|\n|float|g_time|経過時間（秒）|\n|float|g_frame|経過フレーム|\n|float2|g_mouse|マウス座標|\n|float|g_leftPressed|左クリック|\n|float|g_rightPressed|右クリック|\n|float2|g_textureResolution|テクスチャのサイズ|\n|Texture2D|texture0|テクスチャ|\n|SamplerState|sampler0|サンプラー|\n\n### サンプルシェーダ 1\n\u003cimg src=\"s1.png\" wifth=\"640\" height=\"480\"\u003e\n\n```cpp\nfloat4 PS(float4 position : SV_POSITION, float2 uv : TEXCOORD0) : SV_Target\n{\n\treturn float4(uv, 1, 1);\n}\n```\n\n### サンプルシェーダ 2\n\u003cimg src=\"s2.png\" wifth=\"640\" height=\"480\"\u003e\n\n```cpp\nfloat4 PS(float4 position : SV_POSITION, float2 uv : TEXCOORD0) : SV_Target\n{\n\tfloat d = 1.0 - distance(position.xy, g_mouse) / 200;\n\t\n\tif (g_leftPressed)\n\t{\n\t\td = (d \u003e 0.0);\n\t}\n\n\treturn float4(d, d, d, 1) * texture0.Sample(sampler0, uv);\n}\n```\n\n### サンプルシェーダ 3\n\u003cimg src=\"s3.png\" wifth=\"640\" height=\"480\"\u003e\n\n```cpp\nfloat4 PS(float4 position : SV_POSITION, float2 uv : TEXCOORD0) : SV_Target\n{\n\tconst float2 p = (position.xy - g_resolution / 2) / min(g_resolution.x, g_resolution.y);\n\t\n\tfloat3 c = float3(0, 0, 0);\n\t\n\tfor (int i = 0; i \u003c 20; ++i)\n\t{\n\t\tconst float x = 0.4 * cos(2.0 * 3.14 * i / 20);\n\t\tconst float y = 0.4 * sin(2.0 * 3.14 * i / 20);\n\t\tc += 0.01 / (distance(p, float2(x, y))) * float3(1, 1, 1);\n\t}\n\n\treturn float4(c,1);\n}\n```\n\n### サンプルシェーダ 4\n\u003cimg src=\"s4.png\" wifth=\"640\" height=\"480\"\u003e\n\n```cpp\n// Endless Tunnel\n// By: Brandon Fogerty\n// bfogerty at gmail dot com\n// http://glslsandbox.com/e#35101.0\n\nstatic const float  HorizontalAmplitude = 0.80;\nstatic const float  VerticleAmplitude = 0.80;\nstatic const float  HorizontalSpeed = 0.90;\nstatic const float  VerticleSpeed = 0.50;\nstatic const float  ParticleMinSize = 1.76;\nstatic const float  ParticleMaxSize = 1.71;\nstatic const float  ParticleBreathingSpeed = 0.30;\nstatic const float  ParticleColorChangeSpeed = 0.70;\nstatic const float  ParticleCount = 7.0;\nstatic const float3 ParticleColor1 = float3(9.0, 5.0, 3.0);\nstatic const float3 ParticleColor2 = float3(1.0, 3.0, 9.0);\n\nfloat3 checkerBoard(float2 uv, float2 pp)\n{\n\tfloat2 p = floor(uv * 4.6);\n\tfloat t = fmod(p.x + p.y, 2.2);\n\tfloat3 c = float3(t + pp.x, t + pp.y, t + (pp.x*pp.y));\n\n\treturn c;\n}\n\nfloat3 tunnel(float2 p, float scrollSpeed, float rotateSpeed)\n{\n\tfloat a = 2.0 * atan2(p.y, p.x);\n\tfloat po = 2.0;\n\tfloat px = pow(p.x*p.x, po);\n\tfloat py = pow(p.y*p.y, po);\n\tfloat r = pow(px + py, 1.0 / (2.0*po));\n\tfloat2 uvp = float2(1.0 / r + (g_time*scrollSpeed), a + (g_time*rotateSpeed));\n\tfloat3 finalColor = checkerBoard(uvp, p).xyz;\n\tfinalColor *= r;\n\n\treturn finalColor;\n}\n\nfloat3 particles(float2 uv)\n{\n\tfloat2 pos = uv * 2.0 - 1.0;\n\tpos.x *= (g_resolution.x / g_resolution.y);\n\n\tfloat3 c = float3(0, 0, 0);\n\n\tfor (float i = 1.0; i \u003c ParticleCount + 1.0; ++i)\n\t{\n\t\tfloat cs = cos(g_time * HorizontalSpeed * (i / ParticleCount)) * HorizontalAmplitude;\n\t\tfloat ss = sin(g_time * VerticleSpeed   * (i / ParticleCount)) * VerticleAmplitude;\n\t\tfloat2 origin = float2(cs, ss);\n\n\t\tfloat t = sin(g_time * ParticleBreathingSpeed * i) * 0.5 + 0.5;\n\t\tfloat particleSize = lerp(ParticleMinSize, ParticleMaxSize, t);\n\t\tfloat d = clamp(sin(length(pos - origin) + particleSize), 0.0, particleSize);\n\n\t\tfloat t2 = sin(g_time * ParticleColorChangeSpeed * i) * 0.5 + 0.5;\n\t\tfloat3 color = lerp(ParticleColor1, ParticleColor2, t2);\n\t\tc += color * pow(d, 70.0);\n\t}\n\n\treturn c;\n}\n\nfloat4 PS(float4 position : SV_POSITION, float2 uv : TEXCOORD0) : SV_Target\n{\n\tfloat timeSpeedX = g_time * 0.3;\n\tfloat timeSpeedY = g_time * 0.2;\n\tfloat2 p = uv + float2(-0.50 + cos(timeSpeedX)*0.2, -0.5 - sin(timeSpeedY)*0.3);\n\tfloat3 finalColor = tunnel(p, 1.0, 0.0);\n\n\ttimeSpeedX = g_time * 0.30001;\n\ttimeSpeedY = g_time * 0.20001;\n\tp = uv + float2(-0.50 + cos(timeSpeedX)*0.2, -0.5 - sin(timeSpeedY)*0.3);\n\n\tfinalColor += particles(uv);\n\n\treturn float4(finalColor,1);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freputeless%2Fsivshader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freputeless%2Fsivshader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freputeless%2Fsivshader/lists"}