-
Posts
379 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Posts posted by Masterxilo
-
-
Check the sample @ http://www.leadwerks.com/wiki/index.php?title=OcclusionCulling.
Make sure you enable occlusion culling for the objects you want to use it with EntityOcclusionMode.
It's off by default for non animated objects/meshes. It's on for lights.
However, it looks like it doesn't take into account the terrain so it can't be used to hide buildings in a valley...
-
In the vertex shader, add:
varying vec3 modelnormal;
in the declarations before the code.
Then in the code, after "modelvertex = ":
modelnormal = nmat * gl_Normal;
Now go to the frag shader and extend the declaration of the cube map to this:
#ifdef LW_CUBEMAP uniform samplerCube LW_CUBEMAP; uniform float cubemapIntensity = 1.0; varying vec3 modelnormal; #endif
and extend:
//Diffuse gl_FragData[0] = diffuse;
to
//Diffuse #ifdef LW_CUBEMAP // Add cubemap diffuse = mix(diffuse, textureCube(LW_CUBEMAP, reflect(normalize(cameraposition - vertexposition.xyz), normalize(modelnormal)) * vec3(1.0,-1.0,1.0)), cubemapIntensity); #endif gl_FragData[0] = diffuse;
Now the only thing left to do is the declaration of an "intermediate" (= include) shader.
Mine looks like:
// Requires meshModelnormal.vert #define LW_DIFFUSE texture0 #define LW_CUBEMAP texture3 Include "abstract::meshCubemap.frag"
And is called mesh_diffuse_cubemap.frag
This should do the trick (it does for 2.32, shouldn't be much different in 2.28).
-
The physics/newton & LE water plane implementation only allows for one infinite waterplane...
-
Can't be done, because it uses m_entity.
What about Shader::Disable() ==> SetShader(NULL); ?
-
WOOt!
All bugs in the tracker are gone. (EDIT: At least the Pending ones, CONFIRMED ones to go) Great.
Thanks for this!
-
It's actually quite easily possible to get all that info by just retrieving the ogl id of the shader by setting it and getting the current shader program.
You can then get the name and type of each uniform defined in the shader. And you can also get the current value of any uniform with known name
(http://forum.leadwerks.com/viewtopic.php?f=16&t=3109).
This class extends the LEO::Shader class and implements the mentioned functionality:
#pragma once #include "eleoCommon.h" ELEO_NAMESPACE_BEGIN struct Uniform { std::string name; GLint size; /* Any of GL_FLOAT, GL_FLOAT_VEC2, GL_FLOAT_VEC3, GL_FLOAT_VEC4, GL_INT, GL_INT_VEC2, GL_INT_VEC3, GL_INT_VEC4, GL_BOOL, GL_BOOL_VEC2, GL_BOOL_VEC3, GL_BOOL_VEC4, GL_FLOAT_MAT2, GL_FLOAT_MAT3, GL_FLOAT_MAT4, GL_FLOAT_MAT2x3, GL_FLOAT_MAT2x4, GL_FLOAT_MAT3x2, GL_FLOAT_MAT3x4, GL_FLOAT_MAT4x2, GL_FLOAT_MAT4x3, GL_SAMPLER_1D, GL_SAMPLER_2D, GL_SAMPLER_3D, GL_SAMPLER_CUBE, GL_SAMPLER_1D_SHADOW, GL_SAMPLER_2D_SHADOW See http://www.opengl.org/sdk/docs/man/xhtml/glGetActiveUniform.xml*/ GLenum type; }; class EShader : public LEO::Shader { public: EShader( TEntity buf = NULL) : LEO::Shader(buf) {m_glProgram = -1;} void LoadPostfilter(const std::string& fragshader, const std::string& defines = "") { EShader::Load("abstract::postfilter.vert", fragshader, defines); } void Load( const std::string& vertpath, const std::string& fragpath, const std::string& defines = "" ) { __super::Load(vertpath, fragpath, defines); GrabGLInfo(); } const std::list<Uniform>& GetUniforms() const {return m_uniforms;} void GetUniformf(const std::string& uniformname, GLfloat* flts) const { glGetUniformfv(m_glProgram, glGetUniformLocation(m_glProgram, uniformname.c_str()), flts); } void GetUniformi(const std::string& uniformname, GLint* ints) const { glGetUniformiv(m_glProgram, glGetUniformLocation(m_glProgram, uniformname.c_str()), ints); } bool IsValid() {return __super::IsValid() && glIsProgram(m_glProgram);} private: void GrabGLInfo() { Set(); glGetIntegerv(GL_CURRENT_PROGRAM, &m_glProgram); GLint iUniforms; glGetProgramiv(m_glProgram, GL_ACTIVE_UNIFORMS, &iUniforms); for (int i = 0; i < iUniforms; i++) { Uniform uniform; GLint x; char namebuffer[200] = {0}; glGetActiveUniform (m_glProgram, i, sizeof(namebuffer), NULL, &uniform.size, &uniform.type, namebuffer); uniform.name = namebuffer; m_uniforms.push_back(uniform); } Set(false); } GLint m_glProgram; std::list<Uniform> m_uniforms; }; ELEO_NAMESPACE_END
Just thought I might share.
This is very handy for testing and tweaking shaders without manually copying the uniform names, types and default values to the program:
-
-
-
Could this please be added? I don't think this takes long to make.
-
Why would you call it GetEntityAverageSize?
-
r5?
Maybe 2.32 should have stayed in "beta" a little longer.
But that's also just a name.
Looking forward to trying this out.
-
You shouldn't use scales that differ too much from this because you'll get problems with the shadow map depth bias error (the "missing shadow pixels").
-
Best would be to have the choice. In C++, I can override a method but still (if I want to) call the base method.
-
This is my desktop after cleaning .. i had big mess on my desktop before
After cleaning?!?
I wonder how it looked before that xD
-
and mantain an hashtable to let me copy if already loaded.
You don't have to do this yourself. If oildrum.gmf is already loaded, calling LoadModel("abstract::oildrum.gmf"); again will automatically return an instanced copy of it.
-
Depends on how long the assets take to load. Loading stuff only when it's needed is generally the better approach.
-
When disabling vsync things do move to fast for like 1 second because the AppSpeed has to recalculate.
But except for that, objects fall at the same speed at no matter what framerate for me.
Really can't say why it doesn't work for you. Make sure UpdateAppTime() and UpdateWorld() are called once and only once per loop.
-
Hmm, it works fine for me.
Do AppSpeed() and AppTime() work? Print them to the screen to ensure that they do.
-
For anyone interested, here's a cleaned up version of that shader that works with LE:
// from http://www.gamedev.net/community/forums/topic.asp?topic_id=556187&whichpage=9 // / http://www.pasteall.org/12282 (newer) uniform sampler2D texture0; //RenderedTexture; uniform sampler2D texture1; //DepthTexture; //uniform sampler2D LuminanceTexture; uniform float apptime; uniform vec2 buffersize; uniform vec2 camerarange; // Math constants const float _2PI = 2.0*3.14159265; // Effect settings const int samples = 6; // samples on each ring (3-7) ! This gets multiplied by the current ring index ! -> very expensive const int rings = 4; // ring count (2-8) const float aoCap = 1.0; const float aoMultiplier = 100.0; const float aoMultiplier2 = 1.0; const float depthTolerance = 0.0000; const float aorange = 60.0;// units in space the AO effect extends to (this gets divided by the camera camerarange.y range const float radius = 0.5; const float aoexp = 1; const float noiseMultiplier = 1.0; const vec3 treshold = vec3(0.3); const bool allowEarlyOut = true; // Globals vec2 texCoord; // Functions inline vec2 rand(in vec2 coord) //generating random noise { float noiseX = (fract(sin(apptime*0.0001+dot(coord, vec2(12.9898,78.233))) * 43758.5453)); float noiseY = (fract(sin(apptime*0.0001+dot(coord, vec2(12.9898,78.233)*2.0)) * 43758.5453)); return vec2(noiseX,noiseY) * 0.004; } inline float readDepth(in vec2 coord) { float depth = texture2D(texture1, coord ).x; return (2.0 * camerarange.x) / (camerarange.y + camerarange.x - depth * (camerarange.y-camerarange.x)); } inline float compareDepths( in float depth1, in float depth2 ) { float diff = sqrt(clamp(1.0-(depth1-depth2) / (aorange/(camerarange.y-camerarange.x)),0.0,1.0)); float ao = min(aoCap, max(0.0,depth1-depth2-depthTolerance) * aoMultiplier) * diff; return ao; } void main(void) { // Calculate texCoord of current pixel texCoord = gl_FragCoord.xy/buffersize; // Get color and calculate luminance vec3 color = texture2D(texture0,texCoord).rgb; vec3 luminance = color; luminance = clamp(max(vec3(0.0),luminance-treshold) * vec3(3.0), vec3(0.0), vec3(1.0)); // high pass, original code // Early out if the luminance is nearly white if (allowEarlyOut && any(greaterThanEqual(luminance, vec3(0.7)))){gl_FragColor = vec4(color,1.0); return;} // Calculate ao float depth = readDepth(texCoord); if (allowEarlyOut && depth >= 1.0){gl_FragColor = vec4(color,1.0); return;} float aspect = buffersize.x/buffersize.y; vec2 noise = rand(texCoord); vec2 pixelSize = (vec2(1.0) / buffersize)/ vec2(clamp(depth,0.05,1.0))+(noise*(vec2(1.0)-noise)) * vec2(noiseMultiplier); float ao = 0.0, // Total ao s = 0.0; // Steps float fade = 1.0; for (int i = 0 ; i < rings; ++i) { float _step = _2PI / (samples*i); fade *= 0.5; for (int j = 0 ; j < samples*i; ++j) { float pw = (cos(j * _step) * i * radius); float ph = (sin(j * _step) * i * radius) * aspect; float d = readDepth( vec2(texCoord.s + pw * pixelSize.x, texCoord.t + ph * pixelSize.y)); ao += compareDepths(depth, d)*fade; s += 1.0*fade; } } ao /= s; ao *= aoMultiplier2; ao = 1.0-ao; ao = clamp(ao, 0.0, 1.0); ao = pow(ao,aoexp); gl_FragColor = vec4(color * mix(vec3(ao), vec3(1.0), vec3(luminance)), 1.0); return; }
Doesn't look too bad:
-
This happens because their models are intended to be used with real alpha blending where semi-transparency is possible.
You have to change the alphatest shaders to allow lower alpha values to be rendered or change the alpha maps (increase contrast/brightness).
-
-
Yeah, but this makes pirating the engine even easier, everything people need is an engine.dll, and that is included in any le game.
On the old forum, we were told to NEVER post any engine headers.
On the forum here it's ok, since only registered people can access the programming section.
But everyone can go to the showcase forum, download any game (or even just the evaluation), then go to that google code page,
download the wrapper and he'll be ready for programming le without paying for it...
-
You don't have to use AppSpeed() for controller movement as the controller is just a special physics body and the movement is achieved with forces.
Use AppSpeed() as the parameter to UpdateWorld and make sure you call UpdateAppTime() every frame.
-
I'm quite sure that you shouldn't put the headers on a publicly available SVN. Only licensees should have access to the headers.
Max Batch Size?
in Programming
Posted
Some things changed weirdly in the log hardware info output lately. For example, prior to 2.3, the log always read
"Conditional render supported: 1", not "0" for me...