Forward+ working
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
|
||||
|
||||
#define TILE_SIZE 16
|
||||
#define NUM_LIGHTS 25
|
||||
#define NUM_LIGHTS 5000
|
||||
|
||||
|
||||
#include "../Core/EventBroker.h"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Transform>
|
||||
<Scale X="100" Y="100" Z="100"/>
|
||||
<Scale X="10000" Y="10000" Z="10000"/>
|
||||
</c:Transform>
|
||||
<c:Model>
|
||||
<Resource>Models/Core/UnitPlane.obj</Resource>
|
||||
|
||||
@@ -57,7 +57,7 @@ struct LightResult {
|
||||
};
|
||||
|
||||
float CalcAttenuation(float radius, float dist) {
|
||||
return 1.0 - smoothstep(radius * 1.0, radius, dist);
|
||||
return 1.0 - smoothstep(radius * 0.3, radius, dist);
|
||||
}
|
||||
|
||||
vec4 CalcSpecular(vec4 lightColor, vec4 viewVec, vec4 lightVec, vec4 normal) {
|
||||
@@ -115,11 +115,11 @@ void main()
|
||||
}
|
||||
|
||||
fragmentColor += Input.DiffuseColor * (totalLighting.Diffuse + totalLighting.Specular) * texel * Color;
|
||||
fragmentColor += vec4(0.0, LightGrids.Data[currentTile].Amount/3.0, 0, 1);
|
||||
//fragmentColor += vec4(0.0, LightGrids.Data[currentTile].Amount/3.0, 0, 1);
|
||||
//fragmentColor = texel * Input.DiffuseColor * Color;
|
||||
if(int(gl_FragCoord.x)%16 == 0 || int(gl_FragCoord.y)%16 == 0 )
|
||||
{
|
||||
fragmentColor += vec4(0.5, 0, 0, 0);
|
||||
//fragmentColor += vec4(0.5, 0, 0, 0);
|
||||
} else {
|
||||
//fragmentColor += vec4(LightGrids.Data[int(tilePos.x + tilePos.y*80)].Amount/3.0, 0, 0, 1);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ vec4 ConvertToView(vec4 ScreenCoords)
|
||||
vec2 normalizedScreenCoords = ScreenCoords.xy / ScreenDimensions;
|
||||
vec4 clipSpace = vec4( vec2(normalizedScreenCoords.x, normalizedScreenCoords.y) * 2.0 - 1.0, ScreenCoords.z, ScreenCoords.w);
|
||||
vec4 view = inverse(P) * clipSpace;
|
||||
//view = view / view.w;
|
||||
view = view / view.w;
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -51,12 +51,14 @@ void main ()
|
||||
ScreenCoords[2] = vec4(gl_GlobalInvocationID.x * TILE_SIZE, (gl_GlobalInvocationID.y) * TILE_SIZE, -1.0, 1.0);
|
||||
ScreenCoords[3] = vec4((gl_GlobalInvocationID.x + 1) * TILE_SIZE, (gl_GlobalInvocationID.y) * TILE_SIZE, -1.0, 1.0);
|
||||
|
||||
|
||||
|
||||
vec3 ViewVectors[4];
|
||||
for(int i = 0; i < 4; i++) {
|
||||
ViewVectors[i] = vec3(ConvertToView(ScreenCoords[i]));
|
||||
}
|
||||
|
||||
vec3 EyePos = vec3(0,0,0);
|
||||
vec3 EyePos = vec3(0.0, 0.0 ,0.0);
|
||||
|
||||
Frustum f;
|
||||
f.Planes[0] = ComputePlane(EyePos, ViewVectors[2], ViewVectors[0]); // left plane
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
|
||||
|
||||
#define NUM_LIGHTS 25
|
||||
#define MAX_LIGHTS_PER_TILE 1024
|
||||
#define NUM_TILES 3600
|
||||
#define TILE_SIZE 16
|
||||
@@ -71,7 +70,7 @@ int GroupIndex;
|
||||
|
||||
bool SphereInsidePlane(vec3 center, float radius, Plane plane)
|
||||
{
|
||||
return dot(plane.Normal, center) + plane.d > -radius;
|
||||
return dot(plane.Normal, center) - plane.d > -radius;
|
||||
}
|
||||
|
||||
bool SphereInsideFrustrum(vec3 center, float radius, Frustum frustum/*, float zNear, float zFar*/)
|
||||
|
||||
@@ -4,7 +4,7 @@ void Renderer::Initialize()
|
||||
{
|
||||
InitializeWindow();
|
||||
// Create default camera
|
||||
m_DefaultCamera = new ::Camera((float)m_Resolution.Width / m_Resolution.Height, glm::radians(45.f), 0.01f, 5000.f);
|
||||
m_DefaultCamera = new ::Camera((float)m_Resolution.Width / m_Resolution.Height, glm::radians(90.0f), 0.01f, 5000.f);
|
||||
m_DefaultCamera->SetPosition(glm::vec3(0, 1, 10));
|
||||
if (m_Camera == nullptr) {
|
||||
m_Camera = m_DefaultCamera;
|
||||
@@ -266,13 +266,13 @@ void Renderer::CalculateFrustum()
|
||||
|
||||
void Renderer::TEMPCreateLights()
|
||||
{
|
||||
for (int z = 0; z < 5; z++)
|
||||
for (int x = 0; x < 5; x++)
|
||||
{
|
||||
m_PointLights[x + z*5].Position = glm::vec4(x*2.f, 0.2f, z * 2.f, 1.f);
|
||||
m_PointLights[x + z*5].Color = glm::vec4(1.f, 0.5f, 1.f, 1.f);
|
||||
m_PointLights[x + z*5].Radius = 0.5f;
|
||||
}
|
||||
for (int i = 0; i < NUM_LIGHTS; i++)
|
||||
{
|
||||
glm::vec3 pos = glm::vec3(cos(i) * i/10.f , 0.5f, sin(i) * i/10.f);
|
||||
m_PointLights[i].Position = glm::vec4(pos, 1.f);
|
||||
m_PointLights[i].Color = glm::vec4(rand()%255 / 255.f, rand()%255 / 255.f, rand()%255 / 255.f, 1.f);
|
||||
m_PointLights[i].Radius = 5.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::CullLights()
|
||||
|
||||
Reference in New Issue
Block a user