置紫外光協調從紋理值,無噪音,我有UV渲染通道(RG圖像)
我想設置的UV過程紋理值進行UV座標無噪音 當我測試它的結果應該pixlate噪音像下面的圖片
我如何在HLSL
我已經在其他着色器語言,如cgprogramm和GLSL
測試它 也測試團結
並嘗試使用Zdepth的紋理貼圖,但我不能讓反鋸齒RESU LT
所有的結果都是一樣的
float4x4 World;
float4x4 View;
float4x4 Projection;
float4x4 WorldInverseTranspose;
float4 AmbientColor = float4(1, 1, 1, 1);
float AmbientIntensity = 0.1;
float3 DiffuseLightDirection = float3(1, 0, 0);
float4 DiffuseColor = float4(1, 1, 1, 1);
float DiffuseIntensity = 1.0;
float Shininess = 200;
float4 SpecularColor = float4(1, 1, 1, 1);
float SpecularIntensity = 1;
float3 ViewVector = float3(1, 0, 0);
texture ModelTexture;
texture UvTexture;
sampler2D textureSampler = sampler_state {
Texture = (ModelTexture);
MinFilter = Point;
MagFilter = Point;
AddressU = Wrap;
AddressV = Wrap;
};
sampler2D textureSamplerUV = sampler_state {
Texture = (UvTexture);
MinFilter = Linear;
MagFilter = Linear;
AddressU = Clamp;
AddressV = Clamp;
};
struct VertexShaderInput
{
float4 Position : POSITION0;
float4 Normal : NORMAL0;
float2 TextureCoordinate : TEXCOORD0;
};
struct VertexShaderOutput
{
float4 Position : POSITION0;
float2 Color : COLOR0;
float3 Normal : TEXCOORD0;
float2 TextureCoordinate : TEXCOORD1;
};
VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
VertexShaderOutput output;
float4 worldPosition = mul(input.Position, World);
float4 viewPosition = mul(worldPosition, View);
output.Position = mul(viewPosition, Projection);
float4 normal = normalize(mul(input.Normal, WorldInverseTranspose));
float lightIntensity = dot(normal, DiffuseLightDirection);
output.Color = saturate(DiffuseColor * DiffuseIntensity * lightIntensity);
output.Normal = normal;
output.TextureCoordinate = input.TextureCoordinate;
return output;
}
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
//******* is here
float4 textureColorUV = tex2D(textureSamplerUV, input.TextureCoordinate);
float2 cord = float2(textureColorUV[0],textureColorUV[1]);
float4 textureColor = tex2D(textureSampler, cord);
return saturate(textureColor);
}
technique Textured
{
pass Pass1
{
VertexShader = compile vs_1_1 VertexShaderFunction();
PixelShader = compile ps_2_0 PixelShaderFunction();
}
}
感謝名單GALOP但是當我想試試我有誤差的位置:(和.rg –
@ehsanwwe那是因爲你使用的是很舊的着色模式的,1.1和2.0。除非您嘗試支持以前的硬件,並且您或不在DX11中,否則不能這樣做。如果您只是修正採樣器狀態,則原始着色器代碼將起作用。 – galop1n
thanx幫助,但我嘗試它我在Unity着色器中使用DX11 - 但結果是相同的 - 我用我的對象替換input.position紫外線(平面對象0,0 1,0,11,1,0):(我認爲MIP過濾不適用於像素紫外線只是與矢量紫外線 - 我的評論是真的嗎? –