Some shader issues
by Aleksander Elvemo · in Torque 3D Professional · 09/08/2009 (3:26 pm) · 11 replies
Updated, see post 2.
#2
post your shaders code.
09/12/2009 (10:06 am)
I got noise, scratches and flickering to work, its for a nightvision effect, but may help.post your shaders code.
#3
It's also fairly unchanged from the one I linked.
Tried changing some things, but ended up reverting them, as I couldn't get it to work that way.
09/12/2009 (10:08 am)
Huh? It's right there in my second post?It's also fairly unchanged from the one I linked.
Tried changing some things, but ended up reverting them, as I couldn't get it to work that way.
#4
09/12/2009 (10:40 am)
scanning posts to fast :(
#5
just post back here the cs and shader when you get it working.
sorry dont have time to go into it now, I'm right in the middle of porting Ron Nelsons new projectile/vehicle/decals resource to T3D.
.cs
shader
09/12/2009 (10:47 am)
heres my nightVision.cs and shader, compare it, and rip out what works for you.just post back here the cs and shader when you get it working.
sorry dont have time to go into it now, I'm right in the middle of porting Ron Nelsons new projectile/vehicle/decals resource to T3D.
.cs
singleton ShaderData( PFX_NightVisionShader )
{
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl"
DXPixelShaderFile = "shaders/common/postFx/nightVision/nightVisionP.hlsl";
samplerNames[0] = "$FineNoise";
samplerNames[1] = "$ColorSpectrum";
samplerNames[2] = "$BBuffer";
pixVersion = 3.0;
};
singleton GFXStateBlockData( NightVisionStateBlock : PFX_DefaultStateBlock )
{
blendDefined = true;
blendEnable = true;
blendSrc = GFXBlendSrcAlpha;
blendDest = GFXBlendInvSrcAlpha;
samplersDefined = true;
samplerStates[0] = SamplerWrapLinear;
samplerStates[1] = SamplerClampLinear;
samplerStates[2] = SamplerClampLinear;
};
singleton PostEffect( NightVisionPostEffect )
{
requirements = "None";
isEnabled = false;
allowReflectPass = true;
renderTime = "PFXAfterDiffuse";
renderBin = "ObjTranslucentBin";
shader = PFX_NightVisionShader;
stateBlock = NightVisionStateBlock;
texture[0] = "textures/nightvision.dds";
texture[1] = "textures/nightvisionSpectrum.png";
texture[2] = "$backbuffer";
renderPriority = 0.1;
};
function NightVisionPostEffect::setShaderConsts(%this)
{
%this.setShaderConst( "$time", $Sim::time - %this.timeStart );
%this.setShaderConst( "$randomFrac", getRandom(1) );
}shader
uniform sampler2D FineNoise : register(S0);
uniform sampler2D ColorSpectrum : register(S1);
uniform sampler2D BBuffer : register(S2);
uniform float time;
uniform float randomFrac;
float4 main(float2 texCoord : TEXCOORD0) : COLOR
{
half distToCenter = length((texCoord * 2.0f) - 1.0f);
half darken = saturate(1.0f - distToCenter*0.7);
float3 screenColor = tex2D(BBuffer, texCoord).xyz * darken;
float2 noiseCoords = texCoord + float2(time * randomFrac, time * randomFrac);
screenColor += tex2D(FineNoise, noiseCoords).xyz * darken * 0.15f;
//Flare-out brighter (whiter) areas
float3 outColor = 1.0f - exp(-4.0f * screenColor);
float lum = dot(outColor, 1.5f);
float3 finalColor = tex2D(ColorSpectrum, lum);
return float4(finalColor, 1.0f);
}
#6
09/12/2009 (12:24 pm)
Turned out that those parameters were slightly more complex than I originally thought, will have to rethink those.
#7
look at the caustics shader
//I'm not quite sure what I'm supposed to set this to.
maybe frame rate?
09/12/2009 (2:00 pm)
//How do I set a two-dimensional float for these two?look at the caustics shader
//I'm not quite sure what I'm supposed to set this to.
maybe frame rate?
#8
09/12/2009 (2:30 pm)
Nevermind.
Torque 3D Owner Aleksander Elvemo