Last active
November 26, 2016 12:30
Star
You must be signed in to star a gist
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
#include <Siv3D.hpp> | |
struct ParamScale | |
{ | |
float scale; | |
float unused[3]; | |
}; | |
void setScale(const int scale) | |
{ | |
ConstantBuffer<ParamScale> cb; | |
cb->scale = scale; | |
PostEffect::SetConstant(ShaderStage::Pixel, 1, cb); | |
} | |
void Main() | |
{ | |
Window::Resize(640, 480); | |
Graphics::SetBackground(Palette::Black); | |
int scale = 2; | |
PostEffect::Register(PixelShader(L"scale.hlsl")); | |
setScale(scale); | |
const Texture texture(L"Example/Siv3D-kun.png"); | |
while (System::Update()) | |
{ | |
if (Input::KeyUp.clicked) | |
{ | |
scale = Min(scale + 1, 4); | |
setScale(scale); | |
} | |
else if (Input::KeyDown.clicked) | |
{ | |
scale = Max(scale - 1, 1); | |
setScale(scale); | |
} | |
texture.draw(); | |
PutText(L"scale = ", scale).from(2, 2); | |
} | |
} |
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
Texture2D texture0 : register( t0 ); | |
SamplerState sampler0 : register( s0 ); | |
struct VS_OUTPUT | |
{ | |
float4 position : SV_POSITION; | |
float2 tex : TEXCOORD0; | |
float4 color : COLOR0; | |
}; | |
cbuffer psConstants1 : register( b1 ) | |
{ | |
float g_scale; | |
}; | |
float4 PS(VS_OUTPUT input) : SV_Target | |
{ | |
return texture0.Sample(sampler0, input.tex / g_scale) * input.color; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment