Hey Boris and anyone else looking in!
Recently then just tweaking got boring and like Kyo I have decided to spend time writing shaders instead. So far I am still in the early learning phase, and I still get kicked over by semantics every other line! But getting there!
However I do have a few questions, since I am trying to figure out what the limitations of what we can do is.
Atm I am writing in the effect.txt and have made basic Color correction stuff, noise, sharpening code etc. work. All stuff that I have ported to enbeffect.fx since it can do the same. And might as well save those texture fetches I guess.
However yesterday when I was trying to make a Gaussian blur shader just for fun then I got what you see below.
Today I am trying to copy in example 1 from your sunsprite file too see if I could make that work. However I get the same issue.
Namely this.
So far the only way I found to fix it is by renaming the texture sampler names. But would like to know what is the reason for this happening.
Hope I was clear enough in explaining! And thanks for any info!
Issues writing my own shader!
- Author
- Message
-
Offline
- Posts: 43
- Joined: 27 Jul 2013, 21:36
Re: Issues writing my own shader!
this looks like something I encountered when using programs like Afterburner or Precision which uses RTSS for statistics and screenshots...
_________________
i5 2500K @ 4.5 GHz
ASRock Z68 Pro3
EVGA GeForce GTX780 SC
Corsair Vengeance 16GB RAM
Corsair AX750
Windows 7 Professional
i5 2500K @ 4.5 GHz
ASRock Z68 Pro3
EVGA GeForce GTX780 SC
Corsair Vengeance 16GB RAM
Corsair AX750
Windows 7 Professional
-
Offline
- *sensei*
- Posts: 373
- Joined: 07 Mar 2013, 10:14
Re: Issues writing my own shader!
I am not using anything like that, and it is not a general problem. It only happens when I have for some reason put in some stupid values for either textures it seems. So just want to understand what I am doing wrong with my texture calls!
-
Offline
- *blah-blah-blah maniac*
- Posts: 17562
- Joined: 27 Dec 2011, 08:53
- Location: Rather not to say
Re: Issues writing my own shader!
It's just content of texture or underlying render target when shader failed to work or when it's render states are set to don't draw object (CullMode f.e. not forced to None).
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7
-
Offline
- *sensei*
- Posts: 373
- Joined: 07 Mar 2013, 10:14
Re: Issues writing my own shader!
Code: Select all
/*********************************
-- Defines --
*********************************/
float BlurAmount <
string UIName="Blur Amount"; string UIWidget="Spinner"; float UIMin=0.0; float UIMax=500.0; float UIStep=0.01;
> = {1.0};
static const float sampleOffsets[5] = { 0.0, 1.4347826, 3.3478260, 5.2608695, 7.1739130 };
static const float sampleWeights[5] = { 0.16818994, 0.27276957, 0.11690125, 0.024067905, 0.0021112196 };
/*********************************
-- Textures --
*********************************/
texture2D texColor;
sampler2D SamplerColor = sampler_state
{
Texture = <texColor>;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = NONE;//NONE;
AddressU = Clamp;
AddressV = Clamp;
SRGBTexture=FALSE;
MaxMipLevel=0;
MipMapLodBias=0;
};
/*********************************
-- Vertex Shader --
*********************************/
struct VS_OUTPUT_POST {
float4 vpos : POSITION;
float2 txcoord : TEXCOORD0;
};
struct VS_INPUT_POST {
float3 pos : POSITION;
float2 txcoord : TEXCOORD0;
};
VS_OUTPUT_POST VS_Test(VS_INPUT_POST IN)
{
VS_OUTPUT_POST OUT;
float4 pos=float4(IN.pos.x,IN.pos.y,IN.pos.z,1.0);
OUT.vpos=pos;
OUT.txcoord.xy=IN.txcoord.xy;
return OUT;
}
/*********************************
-- Pixel Shader --
*********************************/
float4 HGaussianBlurPS(VS_OUTPUT_POST IN) : COLOR
{
float2 fvTexelSize = float2(1.0 / 2560.0, 1.0 / 1440.0);
float px = fvTexelSize.x;
float py = fvTexelSize.y;
float4 color = tex2D(SamplerColor, IN.txcoord.xy) * sampleWeights[0];
for(int i = 1; i < 5; ++i) {
color += tex2D(SamplerColor, IN.txcoord.xy + float2(sampleOffsets[i]*px*BlurAmount, 0.0)) * sampleWeights[i];
color += tex2D(SamplerColor, IN.txcoord.xy - float2(sampleOffsets[i]*px*BlurAmount, 0.0)) * sampleWeights[i];
}
return color;
}
float4 VGaussianBlurPS(VS_OUTPUT_POST IN) : COLOR
{
float2 fvTexelSize = float2(1.0 / 2560.0, 1.0 / 1440.0);
float px = fvTexelSize.x;
float py = fvTexelSize.y;
float4 color = tex2D(SamplerColor, IN.txcoord.xy) * sampleWeights[0];
for(int i = 1; i < 5; ++i) {
color += tex2D(SamplerColor, IN.txcoord.xy + float2(0.0,sampleOffsets[i]*py*BlurAmount)) * sampleWeights[i];
color += tex2D(SamplerColor, IN.txcoord.xy - float2(0.0,sampleOffsets[i]*py*BlurAmount)) * sampleWeights[i];
}
return color;
}
/*********************************
-- Techniques --
*********************************/
technique PostProcess
{
pass P0
{
VertexShader = compile vs_3_0 VS_Test();
PixelShader = compile ps_3_0 HGaussianBlurPS();
DitherEnable = FALSE;
ZEnable = FALSE;
CullMode = NONE;
ALPHATESTENABLE = FALSE;
SEPARATEALPHABLENDENABLE = FALSE;
AlphaBlendEnable = FALSE;
StencilEnable = FALSE;
FogEnable = FALSE;
SRGBWRITEENABLE = FALSE;
}
pass P1
{
VertexShader = compile vs_3_0 VS_Test();
PixelShader = compile ps_3_0 VGaussianBlurPS();
DitherEnable = FALSE;
ZEnable = FALSE;
CullMode = NONE;
ALPHATESTENABLE = FALSE;
SEPARATEALPHABLENDENABLE = FALSE;
AlphaBlendEnable = FALSE;
StencilEnable = FALSE;
FogEnable = FALSE;
SRGBWRITEENABLE = FALSE;
}
}
However if I alter
technique PostProcess
to seemingly anything else I will get the red screen above.
Also I have tried to copy the sunsprite shader into the effect.txt but get a similar screen.
So my questions are
1: What sort of weird semantic rules apply to the techniques ? Why does it matter what their name is? Is it an ENB limit of sorts?
2: What are the limits to the effect.txt when it comes to writing shaders for ENB ? For example is it possible to create a second sunsprite shader in it or?
Ultimately what I am trying to do is create a shader that will create a dynamic blur around the sun to simulate a heat haze from it. Which I figure would be possible since the sunsprite can be provided the sun position, but can the effect.txt ? Or am I going to have to do this work in the sunsprite file ?
-
Offline
- *blah-blah-blah maniac*
- Posts: 17562
- Joined: 27 Dec 2011, 08:53
- Location: Rather not to say
Re: Issues writing my own shader!
In short, technique names are predefined internally you can't change it, except the case of shaders, which support this feature (in GUI select technique then).
Copy-paste trick do not work, shader is code, not texture or even not mesh, it have strict rules.
All limits described in hlsl files, global variables actually and textures are all you have, other from different shaders - not exist. This also applied to sun sprite shader, it have own properties for sun which other shaders do not have and to get it data (of sun) somehow is tricky thing, for example by drawing to alpha channel or one pixel in the corner.
Copy-paste trick do not work, shader is code, not texture or even not mesh, it have strict rules.
All limits described in hlsl files, global variables actually and textures are all you have, other from different shaders - not exist. This also applied to sun sprite shader, it have own properties for sun which other shaders do not have and to get it data (of sun) somehow is tricky thing, for example by drawing to alpha channel or one pixel in the corner.
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7
-
Offline
- *sensei*
- Posts: 373
- Joined: 07 Mar 2013, 10:14
Re: Issues writing my own shader!
Ah okay thanks Boris, I thought as much, but wanted to be sure!
Guess I will have to try to move the future experiments into the sunsprite shader then!
Guess I will have to try to move the future experiments into the sunsprite shader then!