Skip to content

Instantly share code, notes, and snippets.

View tobspr's full-sized avatar
💭
I may be slow to respond.

Tobias tobspr

💭
I may be slow to respond.
View GitHub Profile
// This function looks up in the vertice table wheter a vertice at that position already exists
// - If yes, return the vertice index
// - If no, create a new vertice and return the created vertice index
//
// @param cfg: Pointer to a chunkConfig struct
// @param w_vertex: Pointer to the vertex writer
// @param w_texcoord: Pointer to the texcoord writer
// @param x: x position of the vertice
// @param y: y position of the vertice
geomFormat = GeomVertexFormat.getV3t2()
vertexData = GeomVertexData("vertices", geomFormat, Geom.UHStatic)
vertexWriter = GeomVertexWriter(vertexData, "vertex")
texcoordWriter = GeomVertexWriter(vertexData, "texcoord")
triangle = GeomTriangles(Geom.UHStatic)
vertexWriter.reserveNumRows(len(text) * 6)
texcoordWriter.reserveNumRows(len(text) * 6)
triangle.reserveNumVertices(len(text) * 2)
Index: panda/src/glstuff/glGraphicsStateGuardian_src.cxx
===================================================================
RCS file: /cvsroot/panda3d/panda/src/glstuff/glGraphicsStateGuardian_src.cxx,v
retrieving revision 1.471
diff -u -r1.471 glGraphicsStateGuardian_src.cxx
--- panda/src/glstuff/glGraphicsStateGuardian_src.cxx 20 Jun 2014 15:04:39 -0000 1.471
+++ panda/src/glstuff/glGraphicsStateGuardian_src.cxx 21 Jun 2014 21:29:25 -0000
@@ -1115,6 +1115,19 @@
_supports_compute_shaders = true;
}
@classmethod
def simplifyGeom(self, geom, state):
print "Simplifying geom", geom
v1 = Vertex(Vec3(0, 0, 1), Vec3(0, 1, 0), Vec2(0, 1), Vec3(1,0,0))
v2 = Vertex(Vec3(0, 1, 0), Vec3(0, 1, 0), Vec2(1, 0), Vec3(0,1,0))
v3 = Vertex(Vec3(0, 0, 0), Vec3(0, 1, 0), Vec2(0, 0), Vec3(0,0,1))
tri = Triangle(v1, v2, v3)
for (int i = 0; i < 4096; i++) {
lightingResult += lightData[i%64][0] * 0.01;
}
// Cut light transition starting at 80%. Otherwise it's exponential and never gets really 0
float cutoff = light.radius * 0.8;
float cutoffFactor = 0.25;
attenuation *= 1.0 - smoothstep(0.0, 1.0, ((distanceToLight / cutoff) - 1.0) * 4.0 );
attenuation = max(0.0, attenuation);
vec4 result = vec4(0, 0, 0, 1);
int abc = 0;
for (int i = 0; i < 2000; i ++) {
abc += i;
}
result.x = float(abc) / 200000.0;
ivec2 storePos = ivec2(gl_GlobalInvocationID.xy);
imageStore(destTex, storePos, result);
#version 430
layout (rgba8) uniform image2D destTex;
layout (local_size_x = 32, local_size_y = 32) in;
void main() {
vec4 result = vec4(0, 0, 0, 1);
int abc = 0;
for (int i = 0; i < 2000; i ++) {
abc += i;
}
from panda3d.core import *
from direct.directbase import DirectStart
import math
# Shader
compute_source = """#version 430
layout (rgba8) uniform image2D destTex;
layout (local_size_x = 32, local_size_y = 32) in;
void main() {
from panda3d.core import *
loadPrcFileData("","""
show-frame-rate-meter #t
""".strip())
from direct.directbase import DirectStart
import math