Can't believe it, sorry for the troubles.
Basically I was executing the wrong shader still the pointlight shader... Totally stressed because of coursework... thanks for the advice ![]()
Not Telling
trevex hasn't added any contacts yet.
No latest visitors to show
12 January 2013 - 09:53 AM
Can't believe it, sorry for the troubles.
Basically I was executing the wrong shader still the pointlight shader... Totally stressed because of coursework... thanks for the advice ![]()
11 January 2013 - 04:13 AM
Oh god can't believe I didn't notice that! Thank you so much!
11 January 2013 - 04:09 AM
I am totally confused right now when I use sample the screen is simply red, but the general problem persists.
Why is Load only returning the red value?
the color variable always just receives the red value and the rest are underscores in pix...
The shader with vertex shader
float4 VSMain(in float3 Position : POSITION) : SV_Position
{
return float4(Position, 1.0f);
}
float PSDisabledMain(in float4 screenPos : SV_Position) : SV_Target0
{
//BackBufferMap.Sample(TexureSampler, screenPos.xy);
int3 sampleIndices = int3(screenPos.xy, 0);
float4 color = BackBufferMap.Load(sampleIndices);
return color;
}
The vertices used:
glm::vec3 vertices[] =
{
glm::vec3(-1.0f, -1.0f, 0.0f),
glm::vec3(-1.0f, 1.0f, 0.0f),
glm::vec3( 1.0f, -1.0f, 0.0f),
glm::vec3( 1.0f, 1.0f, 0.0f),
};
The vertices and Load function is simply the same I am using in my deferred rendering shaders...
And here's how I create the backbuffer:
D3D11_TEXTURE2D_DESC backTextureDesc; D3D11_RENDER_TARGET_VIEW_DESC backTargetViewDesc; D3D11_SHADER_RESOURCE_VIEW_DESC backResourceViewDesc; ZeroMemory(&backTextureDesc, sizeof(backTextureDesc)); backTextureDesc.Width = width; backTextureDesc.Height = height; backTextureDesc.MipLevels = 1; backTextureDesc.ArraySize = 1; backTextureDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; backTextureDesc.SampleDesc.Count = 1; backTextureDesc.Usage = D3D11_USAGE_DEFAULT; backTextureDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE; backTextureDesc.CPUAccessFlags = 0; backTextureDesc.MiscFlags = 0; HR(m_d3dDevice->CreateTexture2D(&backTextureDesc, NULL, &m_BackTargetTexture)); backTargetViewDesc.Format = backTextureDesc.Format; backTargetViewDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; backTargetViewDesc.Texture2D.MipSlice = 0; HR(m_d3dDevice->CreateRenderTargetView(m_BackTargetTexture, &backTargetViewDesc, &m_BackTargetView)); backResourceViewDesc.Format = backTextureDesc.Format; backResourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; backResourceViewDesc.Texture2D.MostDetailedMip = 0; backResourceViewDesc.Texture2D.MipLevels = 1; HR(m_d3dDevice->CreateShaderResourceView(m_BackTargetTexture, &backResourceViewDesc, &m_BackResourceView));
24 December 2012 - 11:43 AM
You are right, thanks alot for all the help, I am successfully rendering loads of pointlight, spotlight etc. now... Best christmas present so far ![]()
24 December 2012 - 03:41 AM
float3 CalcLighting(in float3 normal, in float3 position, in float3 diffuseAlbedo, in float3 specularAlbedo, in float specularPower, uniform int gLightingMode)
{
float3 L = 0;
float attenuation = 1.0f;
if (gLightingMode == POINTLIGHT || gLightingMode == SPOTLIGHT)
{
L = LightPos - position;
float dist = length(L);
attenuation = max(0, 1.0f - (dist / LightRange.x));
L /= dist;
}
else if (gLightingMode == DIRECTIONALLIGHT)
{
L = -LightDirection; }if (gLightingMode == SPOTLIGHT)
{
float3 L2 = LightDirection;
float rho = dot(-L, L2);
attenuation *= saturate((rho - SpotlightAngles.y) / (SpotlightAngles.x - SpotlightAngles.y));
}
float nDotL = saturate(dot(normal, L));
float3 diffuse = nDotL * LightColor * diffuseAlbedo;
float3 V = CameraPos - position;
float3 H = normalize(L + V);
float3 specular = pow(saturate(dot(normal, H)), specularPower) * LightColor * specularAlbedo.xyz * nDotL;
return (diffuse + specular) * attenuation;
}
The basic algorithm is basically out of a book so I assumed there would be nothing wrong the only thing I changed is using if and a uniform to embed it in an effects file.
Find content