Jump to content

  • Log In with Google      Sign In   
  • Create Account

evillgames

Member Since 31 Oct 2004
Offline Last Active Oct 14 2013 11:57 AM

Topics I've Started

GLSL Geometry Shader does not show anything

25 September 2013 - 01:23 PM



GPUGrassVertex growPoint[1];
  Float3Set(growPoint[0].origin,0,0,0);
  PackNormalizedVector(growPoint[0].growDir,CVector3f(0,0,1));
  growPoint[0].grassTileID[0]=0;

  
  grassGeometryBasedAmbient.Enable();
  grassGeometryBasedAmbient.SetGeometryShaderParameter(GL_GEOMETRY_VERTICES_OUT_ARB, 4);
  grassGeometryBasedAmbient.SetGeometryShaderParameter(GL_GEOMETRY_OUTPUT_TYPE_ARB, GL_TRIANGLE_STRIP);
  grassGeometryBasedAmbient.SetGeometryShaderParameter(GL_GEOMETRY_INPUT_TYPE_ARB, GL_POINTS);
  
  
  glDisable(GL_CULL_FACE);
  glDisable(GL_TEXTURE_2D);
  glDisable(GL_BLEND);

  glPointSize(12);
  glColor3f(1,1,1);

  glEnableClientState(GL_VERTEX_ARRAY);
  glDisableClientState(GL_COLOR_ARRAY);
  glDisableClientState(GL_NORMAL_ARRAY);
  glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
  glDisableClientState(GL_TEXTURE_COORD_ARRAY);

  size_t vbsize = sizeof(GPUGrassVertex);
  glVertexPointer(3, GL_FLOAT, vbsize, &growPoint[0].origin);

  int numIndexes = 1;
  ushort ids[1]={0};
  glDrawElements( GL_POINTS, numIndexes,GL_UNSIGNED_SHORT,ids);

  glEnableClientState(GL_TEXTURE_COORD_ARRAY);  // dont allow to cache this!
  glEnableClientState(GL_VERTEX_ARRAY);
  glEnableClientState(GL_COLOR_ARRAY);
  glDisableClientState(GL_NORMAL_ARRAY);
  glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
  
  glEnable(GL_TEXTURE_2D);
  glEnable(GL_CULL_FACE);

  grassGeometryBasedAmbient.Disable();




[vertex]

void main()
{
   	gl_Position.xyz = gl_Vertex.xyz;
	gl_FrontColor = gl_Color;
}

[geometry]

void main()
{
	float size_scale = 1;
	float GRASS_HEIGHT = 50 * size_scale;
	float GRASS_WIDTH = 30 * size_scale;
	vec3 origin = vec3(-17.000000, 15.000000, -136.000000); //gl_PositionIn[0].xyz;

	// construct billboard
	vec3 verts[4];
	verts[0]=vec3(-GRASS_WIDTH,0,0);
	verts[1]=vec3(GRASS_WIDTH,0,0);
	verts[2]=vec3(GRASS_WIDTH,0,GRASS_HEIGHT);
	verts[3]=vec3(-GRASS_WIDTH,0,GRASS_HEIGHT);
	//
	
	
	gl_Position = gl_ModelViewProjectionMatrix * vec4(origin + verts[0],1);
	//gl_FrontColor = 1; // gl_FrontColorIn[0];	
	EmitVertex();

	gl_Position = gl_ModelViewProjectionMatrix * vec4(origin + verts[1],1);
	//gl_FrontColor = 1; //gl_FrontColorIn[0];	
	EmitVertex();

	gl_Position = gl_ModelViewProjectionMatrix * vec4(origin + verts[2],1);
	//gl_FrontColor = 1; // gl_FrontColorIn[0];
	EmitVertex();

	gl_Position = gl_ModelViewProjectionMatrix * vec4(origin + verts[3],1);
	//gl_FrontColor = 1; //gl_FrontColorIn[0];
	EmitVertex();
	
	EndPrimitive();
}

hey guys - it just does not work... but i have no errors....
 
here is debug code - some lines are commented out

 

i expect to see quad ,at least....

GS is supported


Chapter 27. Motion Blur as a Post-Processing Effect bugs

29 March 2013 - 11:31 AM

hey

 

my blur effect shivers when i move mouse.... this does occur when i have various fps... 

 

if i move camera by keyboard it is ok

if i connect mouse to fps - it is ok too - but it is not correct from logical point

 

here i just did: mouseX +=1

 

and it shivers.. can not understand WHY

 

i guess that have to be GENTLY with different fps...

 

here is movie - cuzz images does not give info

 

 

https://dl.dropbox.com/u/5862637/moblur/moblurSHIT.flv
(30mb)

 

shaders:

 

vs gbuffer
// moblur

 









gl_TexCoord[5] = gl_Position;
gl_TexCoord[6] = prevMVP * gl_Vertex;
 

 


ps gbuffer







// out velocity for motion blur
vec2 a = gl_TexCoord[5].xy / gl_TexCoord[5].w;
vec2 b = gl_TexCoord[6].xy / gl_TexCoord[6].w;

gl_FragData[2].xy = (a - b) * 0.5 + 0.5;
gl_FragData[2].xy = pow(gl_FragData[2].xy, 3.0);

 



ps blur

 










#extension GL_ARB_texture_rectangle: enable

uniform sampler2DRect sceneSampler;
uniform sampler2DRect depthTexture; <------------ here is veltex actually

uniform int g_numSamples;
uniform float velocityScale;

void main()
{
vec2 scale = vec2(1024.0,768.0);

vec2 velocity = texture2DRect(depthTexture, gl_FragCoord.xy ).rg;

velocity = pow(velocity, 1.0 / 3.0);
velocity = velocity * 2.0 - 1.0;
velocity*=velocityScale;

// float speed = length(velocity*scale);
int nSamples = g_numSamples;//(int)clamp(speed, 1.0, (float)g_numSamples);

vec4 oResult = texture2DRect(sceneSampler, gl_FragCoord.xy);

for (int i = 1; i < nSamples; ++i)
{
vec2 offset = velocity * (float(i) / float(nSamples - 1) - 0.5);
oResult += texture2DRect(sceneSampler,gl_FragCoord.xy + offset*scale);
}

gl_FragColor = oResult / float(nSamples);

//gl_FragColor=velocity.xyxy;
}

 

velocity tex is GL_RG32F

 

 

float currentFps = 1.0/timer->frametime;
float targetFps = 30;
float velocityScale = currentFps / targetFps;

maxSamples = 16;

 

 

float oldMVP3D[16];
MultMatrices_GL(world->current_cam->prevModelview,world->current_cam->Projection4x4GL,oldMVP3D);
glUniformMatrix4fvARB(constructGBufferShader.m_paramsHash["prevMVP"], 1, GL_FALSE, oldMVP3D);

 

 

void camera_s::BuildModelview()
{

for(i=0;i<16;i++)
        prevModelview[i]=modelview[i];


Mat4x4 result;
result.identity();

// in q3 +z is up, -z is down
result.rotateX(-pitch);
result.rotateY(-roll);
result.rotateZ(-yaw);
result.translate(-pos[0],-pos[1],-pos[2]);

result.ConvertToGl(modelview);
}


Evsm artifacts - light bleeding after shadow's preblur

21 June 2012 - 10:59 AM

hey guys - i use standart code from INTEL:

shadow generation


static const float2 g_EVSMExponents = float2(
	 // 20.0f, 10.0f
	  40.0f, 20.0f
	  );

// Convert depth to EVSM coefficients
// Input depth should be in [0, 1]
float2 WarpDepth(float depth, float2 exponents)
{
	// Rescale depth into [-1, 1]
	depth = 2.0f * depth - 1.0f;
	float pos =  exp( exponents.x * depth);
	float neg = -exp(-exponents.y * depth);
	return float2(pos, neg);
}

// Convert depth value to EVSM representation
float4 ShadowDepthToEVSM(float depth)
{
float2 exponents = g_EVSMExponents;
float2 warpedDepth = WarpDepth(depth, exponents);
return  float4(warpedDepth.xy, warpedDepth.xy * warpedDepth.xy);
}

lighting:

float ChebyshevUpperBound(float2 moments, float mean, float minVariance)
{
	// Compute variance
	float variance = moments.y - (moments.x * moments.x);
	variance = max(variance, minVariance);
  
	// Compute probabilistic upper bound
	float d = mean - moments.x;
	float pMax = variance / (variance + (d * d));
  
	// One-tailed Chebyshev
	return (mean <= moments.x ? 1.0f : pMax);
}

static const float2 g_EVSMExponents = float2(
	  40.0f, 20.0f
	  //20.0f, 10.0f
	  );

static const float g_EVSM_Derivation =
	 //0.0001f
	 0.00001f
	 ;

// Convert depth to EVSM coefficients
// Input depth should be in [0, 1]
float2 WarpDepth(float depth, float2 exponents)
{
	// Rescale depth into [-1, 1]
	depth = 2.0f * depth - 1.0f;
	float pos =  exp( exponents.x * depth);
	float neg = -exp(-exponents.y * depth);
	return float2(pos, neg);
}

float EVSM(float2 uv,float depth)
{
//	if(uv.x>1||uv.y>1||uv.x<0||uv.y<0) return 0; // discard fragments outside spot projector

	float2 exponents = g_EVSMExponents;
	float2 warpedDepth = WarpDepth(depth, exponents);

// Perform the linear filtering
float4 occluder = texture2D(advancedShadowMap, uv);

// Derivative of warping at depth
	float2 depthScale = g_EVSM_Derivation * exponents * warpedDepth;
	float2 minVariance = depthScale * depthScale;

// Compute the upper bounds of the visibility function both for x and y
	float posContrib = ChebyshevUpperBound(occluder.xz, warpedDepth.x, minVariance.x);
	float negContrib = ChebyshevUpperBound(occluder.yw, warpedDepth.y, minVariance.y);

	return min(posContrib, negContrib);
}

when i use that without any preblur - it is ok, but after blurring i get this shit - it looks like light bleeding - i guess....... what is wrong ? i can give you additive info if u do wish

Posted Image

Posted Image


Posted Image

PCSS troubles

27 September 2011 - 02:46 PM

ok guys.. i just fuck my head with that bug:

i use nvidia composer code and that does not work as it needs

http://dl.dropbox.co.../pcssf.d001.jpg


i do not understand - why do i get harsh edges of shadow ,when pcf has to blur my shadow edges softly.. and here we see sharp..
that looks like blocker's zone is incorrect.. i do not know

there is formulas:


float BlockersearchWidth = SceneScale * LightSize / zReceiver;

float penumbraWidth = (receiver - Blocker) * LightSize / Blocker;

i suppose: SceneScale , LightSize are not correct - but in which limits these values must be ?



Spherical clipmapping one more time

19 April 2009 - 08:36 PM

Hey guys. At first - sorry for rethreating. I am trying to implement spherical terrain using 6 independent planar clipmaps. Problem that i am getting is that i can not synchronize lods of cube faces. You can see that on these screenshots: http://img134.imageshack.us/img134/3033/sc1j.jpg - it is right for each cube face http://img134.imageshack.us/img134/6405/sc2z.jpg - it is NOT right for both faces. Because of incorrect cube i get incorrect sphere here: http://img90.imageshack.us/img90/618/sphericalclipmaps2t.jpg I saw lot of people here that made this thing, therefore source will be great

PARTNERS