[resource] tweakable variables
- kingeric1992
- Topic Author
Less
More
tweakable variables stored in 10x10 buffer,
to get stored values, just read the storage texture.
numpad 8,4,2,6 to move cursor
+- to increase/decrease value where cursor is pointing.
numpad 5 to show debug screen ( storage buffer & cursor)
it took about 0.006ms for 100 variables with R32f format.
Tested in Mad Max,
also I'm having trouble reading previous frame with multiple render target setup.
code:
to get stored values, just read the storage texture.
numpad 8,4,2,6 to move cursor
+- to increase/decrease value where cursor is pointing.
numpad 5 to show debug screen ( storage buffer & cursor)
it took about 0.006ms for 100 variables with R32f format.
Tested in Mad Max,
also I'm having trouble reading previous frame with multiple render target setup.
code:
Warning: Spoiler!
uniform bool Cursor_Up < source = "key"; keycode = 0x68; toggle = false; >;//numpad 8
uniform bool Cursor_Down < source = "key"; keycode = 0x62; toggle = false; >;//numpad 2
uniform bool Cursor_Right < source = "key"; keycode = 0x66; toggle = false; >;//numpad 6
uniform bool Cursor_Left < source = "key"; keycode = 0x64; toggle = false; >;//numpad 4
uniform bool Cursor_Add < source = "key"; keycode = 0x6B; toggle = false; >;//Add
uniform bool Cursor_Sub < source = "key"; keycode = 0x6D; toggle = false; >;//Substract
texture2D RFX_CursorOldTex { Width = 1; Height = 1; Format = RG16F;};
texture2D RFX_CursorTex { Width = 1; Height = 1; Format = RG16F;};
sampler2D RFX_CursorBuffer { Texture = RFX_CursorTex; };
sampler2D RFX_CursorOldBuffer { Texture = RFX_CursorOldTex;};
texture2D RFX_StoreTex { Width = 10; Height = 10; Format = R32F;};
texture2D RFX_StoreOldTex { Width = 10; Height = 10; Format = R32F;};
sampler2D RFX_StoreBuffer { Texture = RFX_StoreTex; };
sampler2D RFX_StoreOldBuffer { Texture = RFX_StoreOldTex;};
float2 RFX_PS_Cursor(in float4 position : SV_Position, in float2 texcoord : TEXCOORD0) : SV_Target0
{
float2 offset = 0;
if(Cursor_Up ) offset.y--;
if(Cursor_Down ) offset.y++;
if(Cursor_Right) offset.x++;
if(Cursor_Left ) offset.x--;
return saturate(tex2D(RFX_CursorOldBuffer, 0.5).xy + offset * 0.01);
}
float2 RFX_PS_CursorOld(in float4 position : SV_Position, in float2 texcoord : TEXCOORD0) : SV_Target0
{
return tex2D(RFX_CursorBuffer, 0.5).xy;
}
float RFX_PS_Store(in float4 position : SV_Position, in float2 texcoord : TEXCOORD0) : SV_Target0
{
float2 center = tex2D(RFX_CursorBuffer, 0.5).xy;
center = floor(center * 9) + 0.5;
center = abs(texcoord - center * 0.1);
float index = (center.x < 0.05 && center.y < 0.05)? 1:0;
float value = tex2D(RFX_StoreOldBuffer, texcoord).x;
value += (Cursor_Add)? 0.001 * index:0;
value -= (Cursor_Sub)? 0.001 * index:0;
return value;
}
float RFX_PS_StoreOld(in float4 position : SV_Position, in float2 texcoord : TEXCOORD0) : SV_Target0
{
return tex2D(RFX_StoreBuffer, texcoord).x;
}
float4 RFX_PS_Debug(in float4 position : SV_Position, in float2 texcoord : TEXCOORD0) : SV_Target0
{
float2 center = tex2D(RFX_CursorBuffer, 0.5).xy;
center = floor(center * 9) + 0.5;
center = abs(texcoord - center * 0.1);
float temp = (center.x < 0.050 && center.y < 0.050)? 1:0;
center.x = (center.x < 0.045 && center.y < 0.045)? 0:temp;
center.y = 0;
return tex2D(RFX_StoreBuffer, texcoord).xxxx + center.xyyy;
}
technique Storage < enabled = true; >//numpad 5
{
pass
{
VertexShader = RFX_VS_PostProcess;
PixelShader = RFX_PS_Cursor;
RenderTarget = RFX_CursorTex;
}
pass
{
VertexShader = RFX_VS_PostProcess;
PixelShader = RFX_PS_CursorOld;
RenderTarget = RFX_CursorOldTex;
}
pass
{
VertexShader = RFX_VS_PostProcess;
PixelShader = RFX_PS_Store;
RenderTarget = RFX_StoreTex;
}
pass
{
VertexShader = RFX_VS_PostProcess;
PixelShader = RFX_PS_StoreOld;
RenderTarget = RFX_StoreOldTex;
}
}
technique Debug < enabled = false; toggle = 0x65;>//numpad 5
{
pass
{
VertexShader = RFX_VS_PostProcess;
PixelShader = RFX_PS_Debug;
}
}
The following user(s) said Thank You: crosire
Please Log in or Create an account to join the conversation.
- piltrafus
Less
More
That looks very neat. Maybe an ingame config tool is coming soon but this gives you freedom to do it now and in your terms.
Thanks.
Thanks.
Please Log in or Create an account to join the conversation.
- Marty McFly
Less
More
8 years 5 months ago #3
by Marty McFly
Replied by Marty McFly on topic [resource] tweakable variables
Use point sampling, then you can distinguish the single pixels better.
Please Log in or Create an account to join the conversation.