Merge branch 'master' of git://github.com/Shyotl/SingularityViewer

This commit is contained in:
Latif Khalifa
2013-11-10 11:14:08 +01:00
8 changed files with 52 additions and 44 deletions

View File

@@ -60,6 +60,7 @@ uniform sampler2DShadow shadowMap0;
uniform sampler2DShadow shadowMap1;
uniform sampler2DShadow shadowMap2;
uniform sampler2DShadow shadowMap3;
uniform sampler2D noiseMap;
uniform vec2 shadow_res;
@@ -198,12 +199,13 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec
}
#if HAS_SHADOW
float pcfShadow(sampler2DShadow shadowMap, vec4 stc)
float pcfShadow(sampler2DShadow shadowMap, vec4 stc, vec2 pos_screen)
{
stc.xyz /= stc.w;
stc.z += shadow_bias;
stc.x = floor(stc.x*shadow_res.x + fract(stc.y*shadow_res.y*12345))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here
stc.x += (((texture2D(noiseMap, pos_screen/128.0).x)-.5)/shadow_res.x);
//stc.x = floor(stc.x*shadow_res.x + fract(stc.y*shadow_res.y*12345))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here
float cs = shadow2D(shadowMap, stc.xyz).x;
float shadow = cs;
@@ -451,14 +453,14 @@ vec3 fullbrightScaleSoftClip(vec3 light)
void main()
{
vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
frag *= screen_res;
vec4 pos = vec4(vary_position, 1.0);
float shadow = 1.0;
#if HAS_SHADOW
vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
frag *= screen_res;
vec4 spos = pos;
if (spos.z > -shadow_clip.w)
@@ -478,7 +480,7 @@ void main()
float w = 1.0;
w -= max(spos.z-far_split.z, 0.0)/transition_domain.z;
shadow += pcfShadow(shadowMap3, lpos)*w;
shadow += pcfShadow(shadowMap3, lpos,frag.xy)*w;
weight += w;
shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
}
@@ -490,7 +492,7 @@ void main()
float w = 1.0;
w -= max(spos.z-far_split.y, 0.0)/transition_domain.y;
w -= max(near_split.z-spos.z, 0.0)/transition_domain.z;
shadow += pcfShadow(shadowMap2, lpos)*w;
shadow += pcfShadow(shadowMap2, lpos,frag.xy)*w;
weight += w;
}
@@ -501,7 +503,7 @@ void main()
float w = 1.0;
w -= max(spos.z-far_split.x, 0.0)/transition_domain.x;
w -= max(near_split.y-spos.z, 0.0)/transition_domain.y;
shadow += pcfShadow(shadowMap1, lpos)*w;
shadow += pcfShadow(shadowMap1, lpos,frag.xy)*w;
weight += w;
}
@@ -512,7 +514,7 @@ void main()
float w = 1.0;
w -= max(near_split.x-spos.z, 0.0)/transition_domain.x;
shadow += pcfShadow(shadowMap0, lpos)*w;
shadow += pcfShadow(shadowMap0, lpos,frag.xy)*w;
weight += w;
}

View File

@@ -82,18 +82,20 @@ uniform sampler2DShadow shadowMap0;
uniform sampler2DShadow shadowMap1;
uniform sampler2DShadow shadowMap2;
uniform sampler2DShadow shadowMap3;
uniform sampler2D noiseMap;
uniform mat4 shadow_matrix[6];
uniform vec4 shadow_clip;
uniform vec2 shadow_res;
uniform float shadow_bias;
float pcfShadow(sampler2DShadow shadowMap, vec4 stc)
float pcfShadow(sampler2DShadow shadowMap, vec4 stc, vec2 pos_screen)
{
stc.xyz /= stc.w;
stc.z += shadow_bias;
stc.x = floor(stc.x*shadow_res.x + fract(stc.y*shadow_res.y*12345))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here
stc.x += (((texture2D(noiseMap, pos_screen/128.0).x)-.5)/shadow_res.x);
//stc.x = floor(stc.x*shadow_res.x + fract(stc.y*shadow_res.y*12345))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here
float cs = shadow2D(shadowMap, stc.xyz).x;
float shadow = cs;
@@ -598,6 +600,7 @@ void main()
vec3 pos = vary_position;
#if HAS_SUN_SHADOW
vec2 frag = vary_fragcoord.xy;
float shadow = 0.0;
vec4 spos = vec4(pos,1.0);
@@ -617,7 +620,7 @@ void main()
float w = 1.0;
w -= max(spos.z-far_split.z, 0.0)/transition_domain.z;
shadow += pcfShadow(shadowMap3, lpos)*w;
shadow += pcfShadow(shadowMap3, lpos,frag.xy)*w;
weight += w;
shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
}
@@ -629,7 +632,7 @@ void main()
float w = 1.0;
w -= max(spos.z-far_split.y, 0.0)/transition_domain.y;
w -= max(near_split.z-spos.z, 0.0)/transition_domain.z;
shadow += pcfShadow(shadowMap2, lpos)*w;
shadow += pcfShadow(shadowMap2, lpos,frag.xy)*w;
weight += w;
}
@@ -640,7 +643,7 @@ void main()
float w = 1.0;
w -= max(spos.z-far_split.x, 0.0)/transition_domain.x;
w -= max(near_split.y-spos.z, 0.0)/transition_domain.y;
shadow += pcfShadow(shadowMap1, lpos)*w;
shadow += pcfShadow(shadowMap1, lpos,frag.xy)*w;
weight += w;
}
@@ -651,7 +654,7 @@ void main()
float w = 1.0;
w -= max(near_split.x-spos.z, 0.0)/transition_domain.x;
shadow += pcfShadow(shadowMap0, lpos)*w;
shadow += pcfShadow(shadowMap0, lpos,frag.xy)*w;
weight += w;
}

View File

@@ -41,7 +41,7 @@ uniform sampler2DShadow shadowMap2;
uniform sampler2DShadow shadowMap3;
uniform sampler2DShadow shadowMap4;
uniform sampler2DShadow shadowMap5;
uniform sampler2D noiseMap;
// Inputs
uniform mat4 shadow_matrix[6];
@@ -100,15 +100,16 @@ float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float scl, vec2 pos_screen)
stc.xyz /= stc.w;
stc.z += shadow_bias;
stc.x = floor(stc.x*shadow_res.x + fract(pos_screen.y*0.666666666))/shadow_res.x; // add some jitter to X sample pos according to Y to disguise the snapping going on here
stc.x += (((texture2D(noiseMap, pos_screen/128.0).x)-.5)/shadow_res.x);
//stc.x = floor(stc.x*shadow_res.x + fract(pos_screen.y*0.666666666))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here
float cs = shadow2D(shadowMap, stc.xyz).x;
float shadow = cs;
shadow += shadow2D(shadowMap, stc.xyz+vec3(2.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x;
shadow += shadow2D(shadowMap, stc.xyz+vec3(1.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x;
shadow += shadow2D(shadowMap, stc.xyz+vec3(-2.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x;
shadow += shadow2D(shadowMap, stc.xyz+vec3(-1.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x;
shadow += shadow2D(shadowMap, stc.xyz+vec3(-1.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x;
shadow += shadow2D(shadowMap, stc.xyz+vec3(-2.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x;
return shadow*0.2;
@@ -118,7 +119,8 @@ float pcfSpotShadow(sampler2DShadow shadowMap, vec4 stc, float scl, vec2 pos_scr
{
stc.xyz /= stc.w;
stc.z += spot_shadow_bias*scl;
stc.x = floor(proj_shadow_res.x * stc.x + fract(pos_screen.y*0.666666666)) / proj_shadow_res.x; // snap
stc.x += (((texture2D(noiseMap, pos_screen/128.0).x)-.5)/proj_shadow_res.x);
//stc.x = floor(proj_shadow_res.x * stc.x + fract(pos_screen.y*0.666666666)) / proj_shadow_res.x; // snap
float cs = shadow2D(shadowMap, stc.xyz).x;
float shadow = cs;

View File

@@ -156,7 +156,8 @@ float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float scl, vec2 pos_screen)
stc.xyz /= stc.w;
stc.z += shadow_bias;
stc.x = floor(stc.x*shadow_res.x + fract(pos_screen.y*0.666666666))/shadow_res.x;
stc.x += (((texture2D(noiseMap, pos_screen/128.0).x)-.5)/shadow_res.x);
//stc.x = floor(stc.x*shadow_res.x + fract(pos_screen.y*0.666666666))/shadow_res.x;
float cs = shadow2D(shadowMap, stc.xyz).x;
float shadow = cs;
@@ -173,7 +174,8 @@ float pcfSpotShadow(sampler2DShadow shadowMap, vec4 stc, float scl, vec2 pos_scr
{
stc.xyz /= stc.w;
stc.z += spot_shadow_bias*scl;
stc.x = floor(proj_shadow_res.x * stc.x + fract(pos_screen.y*0.666666666)) / proj_shadow_res.x; // snap
stc.x += (((texture2D(noiseMap, pos_screen/128.0).x)-.5)/proj_shadow_res.x);
//stc.x = floor(proj_shadow_res.x * stc.x + fract(pos_screen.y*0.666666666)) / proj_shadow_res.x; // snap
float cs = shadow2D(shadowMap, stc.xyz).x;
float shadow = cs;

View File

@@ -656,7 +656,6 @@ void LLViewerPartSim::updateSimulation()
static LLFrameTimer update_timer;
//reset VBO cursor
LLVOPartGroup::sVBSlotCursor = 0;
const F32 dt = llmin(update_timer.getElapsedTimeAndResetF32(), 0.1f);

View File

@@ -55,18 +55,18 @@ const F32 MAX_PART_LIFETIME = 120.f;
extern U64 gFrameTime;
LLPointer<LLVertexBuffer> LLVOPartGroup::sVB = NULL;
/*S32 LLVOPartGroup::sVBSlotFree[];
S32* LLVOPartGroup::sVBSlotCursor = NULL;*/
S32 LLVOPartGroup::sVBSlotCursor = 0;
S32 LLVOPartGroup::sVBSlotFree[];
S32* LLVOPartGroup::sVBSlotCursor = NULL;
//S32 LLVOPartGroup::sVBSlotCursor = 0;
void LLVOPartGroup::initClass()
{
/*for (S32 i = 0; i < LL_MAX_PARTICLE_COUNT; ++i)
for (S32 i = 0; i < LL_MAX_PARTICLE_COUNT; ++i)
{
sVBSlotFree[i] = i;
}
sVBSlotCursor = sVBSlotFree;*/
sVBSlotCursor = sVBSlotFree;
}
//static
@@ -131,22 +131,22 @@ void LLVOPartGroup::destroyGL()
//static
S32 LLVOPartGroup::findAvailableVBSlot()
{
if (sVBSlotCursor >= /*sVBSlotFree+*/LL_MAX_PARTICLE_COUNT)
if (sVBSlotCursor >= sVBSlotFree+LL_MAX_PARTICLE_COUNT)
{ //no more available slots
return -1;
}
/*S32 ret = *sVBSlotCursor;
S32 ret = *sVBSlotCursor;
sVBSlotCursor++;
return ret;*/
return ret;
return sVBSlotCursor++;
//return sVBSlotCursor++;
}
bool ll_is_part_idx_allocated(S32 idx, S32* start, S32* end)
{
/*while (start < end)
while (start < end)
{
if (*start == idx)
{ //not allocated (in free list)
@@ -156,14 +156,14 @@ bool ll_is_part_idx_allocated(S32 idx, S32* start, S32* end)
}
//allocated (not in free list)
return true;*/
return false;
return true;
//return false;
}
//static
void LLVOPartGroup::freeVBSlot(S32 idx)
{
/*llassert(idx < LL_MAX_PARTICLE_COUNT && idx >= 0);
llassert(idx < LL_MAX_PARTICLE_COUNT && idx >= 0);
llassert(sVBSlotCursor > sVBSlotFree);
llassert(ll_is_part_idx_allocated(idx, sVBSlotCursor, sVBSlotFree+LL_MAX_PARTICLE_COUNT));
@@ -171,7 +171,7 @@ void LLVOPartGroup::freeVBSlot(S32 idx)
{
sVBSlotCursor--;
*sVBSlotCursor = idx;
}*/
}
}
LLVOPartGroup::LLVOPartGroup(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp)
@@ -881,7 +881,7 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group)
LLFace* facep = *i;
LLAlphaObject* object = (LLAlphaObject*) facep->getViewerObject();
//if (!facep->isState(LLFace::PARTICLE))
if (!facep->isState(LLFace::PARTICLE))
{ //set the indices of this face
S32 idx = LLVOPartGroup::findAvailableVBSlot();
if (idx >= 0)
@@ -890,7 +890,7 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group)
facep->setIndicesIndex(idx*6);
facep->setVertexBuffer(LLVOPartGroup::sVB);
facep->setPoolType(LLDrawPool::POOL_ALPHA);
//facep->setState(LLFace::PARTICLE);
facep->setState(LLFace::PARTICLE);
}
else
{

View File

@@ -48,9 +48,9 @@ public:
//vertex buffer for holding all particles
static LLPointer<LLVertexBuffer> sVB;
/*static S32 sVBSlotFree[LL_MAX_PARTICLE_COUNT];
static S32* sVBSlotCursor;*/
static S32 sVBSlotCursor;
static S32 sVBSlotFree[LL_MAX_PARTICLE_COUNT];
static S32* sVBSlotCursor;
//static S32 sVBSlotCursor;
static void initClass();
static void restoreGL();

View File

@@ -9715,7 +9715,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera
renderMaskedObjects(LLRenderPass::PASS_ALPHA_MASK, mask, TRUE, TRUE);
renderMaskedObjects(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, mask, TRUE, TRUE);
gDeferredShadowAlphaMaskProgram.setMinimumAlpha(0.598f);
//renderObjects(LLRenderPass::PASS_ALPHA, mask, TRUE, TRUE);
renderObjects(LLRenderPass::PASS_ALPHA, mask, TRUE, TRUE);
mask = mask & ~LLVertexBuffer::MAP_TEXTURE_INDEX;