• Advertisement

Daywalker313

Member
  • Content count

    157
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Daywalker313

  • Rank
    Member
  1. cg shaders: enabled/disable blending?

    Thanks for your reply but this is really bad now. I could define some keyword that I add as a comment to the shaders and parse the shader file manually to find out wheter the shader requires blending enabled etc. But it's not clean in any way. Does someone know how professional games that are using cg/glsl/hlsl shaders handle this issue?
  2. Hi there, I want to enabled/disable blending an the blend function with my cg shaders. The problem is, I usually have to change their states inside my code but how should my program know wheter a shader makes a material semi-translucent? I googled a bit and found the CgFX standard, but it seems like it's hard to implement and I'd like to continue with simple cg shaders. Is there any way how I could manage this or is it true that I have to know which shaders will require blending related stuff at compile-time?
  3. Hi there, I am currently learning cg shaders and took the simple per fragment lighting from the "Cg Tutorial" book. It works fine on my computer with a GeforceFX, however, on my laptop which runs in mesa software mode, no lighting except for ambient and emissive shows up. It compiles fine on the laptop and the shaders are working (ambient+emissive+multitexturing) but I do no get diffuse and specular components. cgc compiles without an error too. Here are vertex and pixel shader (I know they are ... far from being fast especially the static parameters in the fragment shader but it's just a tryout): Vertex: struct vertex { float4 position : POSITION; float4 color : COLOR; float2 texcoord0 : TEXCOORD0; float2 texcoord1 : TEXCOORD1; // for per-fragment lighting: float3 vertex_position : TEXCOORD2; float3 vertex_normal : TEXCOORD3; }; vertex main( float4 position : POSITION, float3 normal : NORMAL, float4 color : COLOR, float2 texcoord0 : TEXCOORD0, float2 texcoord1 : TEXCOORD1, uniform float4x4 modelviewproj ) { vertex OUT; OUT.color = color; OUT.position = mul(modelviewproj, position); OUT.texcoord0 = texcoord0; OUT.texcoord1 = texcoord1; OUT.vertex_position = position.xyz; OUT.vertex_normal = normal; return OUT; } Fragment: struct pixel { float4 color : COLOR; }; pixel main( float4 position : POSITION, float4 color0 : COLOR0, float2 texcoord0 : TEXCOORD0, float2 texcoord1 : TEXCOORD1, float4 vertex_position : TEXCOORD2, float3 vertex_normal : TEXCOORD3, uniform sampler2D texture0, uniform sampler2D texture1, uniform float3 light_position, uniform float3 camera_position ) { pixel OUT; // vertex data: float3 P = vertex_position.xyz; float3 N = normalize(vertex_normal); // shininess: float shininess = 0.4; // light color: float3 light_color; light_color.x=0.3; light_color.y=0.3; light_color.z=0.3; // diffuse intensity: float3 diff_int; diff_int.x=0.3; diff_int.y=0.3; diff_int.z=0.3; // specular intensity: float3 spec_int; spec_int.x=0.4; spec_int.y=0.4; spec_int.z=0.4; // emissive: float3 emissive; emissive.x=0.1; emissive.y=0.1; emissive.z=0.1; // ambient: float3 ambient; ambient.x=0.1; ambient.y=0.1; ambient.z=0.1; // diffuse: float3 L = normalize ( light_position - P ); float diff_light = max (dot(N,L),0); // Prevent going below 0 float3 diffuse = diff_int * light_color * diff_light; // specular (highlights): float V = normalize (camera_position - P); float H = normalize (L + V); float spec_light = pow ( max (dot(N,H),0), shininess ); // Prevent going below 0 if (diff_light<=0) spec_light=0; float3 specular = spec_int * light_color * spec_light; float4 texelColor0 = tex2D( texture0, texcoord0 ); float4 texelColor1 = tex2D( texture1, texcoord0 ); OUT.color.xyz = (texelColor0+texelColor1)/2 * color0 * (emissive + ambient + specular + diffuse); OUT.color.w = 1; return OUT; } Related extensions supported by mesa: GL_ARB_fragment_program, GL_ATI_fragment_shader, GL_NV_fragment_program,GL_ARB_vertex_program, GL_NV_vertex_program, GL_NV_vertex_program1_1,... So anyone knows what might be wrong, maybe too many textures passes or some unsupported instruction on mesa? Thanks, Daywalker
  4. Hi, for my final exams I'm writing and designing a p2p filesharing tool, focussed on the serverless approach using the XOR metric of Kademlia. I think I have quite well understood the theory of connecting nodes and searching for keys, but a question still remains: How to implement a XOR based network in a filesharing application where each user serves n different files with completly different hashes without relation to his own hash? In Kademlia each node holds data with similar hashes (called keys) as the hash of the node itself (called node id). Node XY has a lot of documents to offer, but the hashes generated from the document-names (via SHA-1) will most likely have nothing to do with the hash of the node with is a requirement for the idea behind Kademlia. So how do we find nodes that have file XY if we just compare the hash of the files with the (unique) hashes of the nodes to jump closer? Because the nodes whose hash (ID) is closest to the hash of the search string obviously won't have requested informations... Sorry for the bad explaination but it's quite hard to describe the situation if your native language is not english and I hope that someone in here knows the Kademlia protocol quite well ;). PS: Please don't forward me to emule or other software because the source is a pain to understand *g*. Thanks ~Daywalker
  5. Hi, I want to write a backup-program as project at school under dos which should support saving restoring FAT32 (+NTFS if there's some DOS version with stable support) partitions. Unfortunately I wasn't able to locate any tutorial covering the backup / restore process of whole partitions and not single files. Does anybody know how it's done in Norton Ghost or others and how I can read/write disks/partitions? Thx, Daywalker
  • Advertisement