Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
uniform sampler2D world; uniform vec2 resolution; uniform vec2 sun; void main (void) { float stepSize=1.0; vec4 texel=texture2D(world,gl_TexCoord[0].st); vec2 pos=vec2(floor(gl_FragCoord.x),floor(gl_FragCoord.y)); vec2 texFac=vec2(1.0/resolution.x,1.0/resolution.y); if (texel.a!=0.0) discard; if (sun.y<pos.y) discard; float alpha=atan(sun.y-pos.y,sun.x-pos.x); vec2 delta=vec2(cos(alpha),sin(alpha)); vec2 checkPos=pos; vec2 checkTex; for (;checkPos.y<sun.y;checkPos.y+=delta.y*stepSize) { checkTex.x=checkPos.x*texFac.x; checkTex.y=checkPos.y*texFac.y; texel=texture2D(world,checkTex); if (texel.a!=0.0) { gl_FragColor=vec(0.0,0.0,0.0,0.95); return; } checkPos.x+=delta.x*stepSize; } } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
uniform sampler2D world; uniform vec2 texFac; uniform vec2 sun; void main (void) { float stepSize=256.0; vec4 texel=texture2D(world,gl_TexCoord[0].st); vec2 pos=vec2(floor(gl_FragCoord.x),floor(gl_FragCoord.y)); if (texel.a!=0.0) discard; if (sun.y<pos.y) discard; vec2 delta=normalize(vec2(sun.y-pos.y,sun.x-pos.x)); vec2 checkPos=pos; vec2 checkTex; for (;checkPos.y<sun.y;checkPos.y+=stepSize*delta.y) { checkTex.x=checkPos.x*texFac.x; checkTex.y=checkPos.y*texFac.y; texel=texture2D(world,checkTex); if (texel.a!=0.0) { gl_FragColor=vec4(0.0,0.0,0.0,0.95); return; } checkPos.x+=delta.x*stepSize; } } |
HLSL-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
uniform vec2 lightpos; uniform vec3 lightColor; uniform float screenHeight; uniform vec3 lightAttenuation; uniform float radius; uniform sampler2D texture; void main() { vec2 pixel=gl_FragCoord.xy; pixel.y=screenHeight-pixel.y; vec2 aux=lightpos-pixel; float distance=length(aux); float attenuation=1.0/(lightAttenuation.x+lightAttenuation.y*distance+lightAttenuation.z*distance*distance); vec4 color=vec4(attenuation,attenuation,attenuation,1.0)*vec4(lightColor,1.0); gl_FragColor = color;//*texture2D(texture,gl_TexCoord[0].st); } |
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »appfyr« (01.06.2012, 06:25)
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
#version 120 uniform sampler2D world; uniform vec2 texFac; uniform vec2 sun; void main (void) { float stepSize=8.0; vec4 texel=texture2D(world,gl_TexCoord[0].st); vec2 pos=vec2(floor(gl_FragCoord.x),floor(gl_FragCoord.y)); if (texel.a!=0.0) discard; if (sun.y<pos.y) discard; vec2 delta=normalize(vec2(sun.y-pos.y,sun.x-pos.x)); if (delta.y<0.0) { gl_FragColor=vec4(1.0,0.0,1.0,1.0); return; } vec2 checkPos=pos; vec2 checkTex; while (checkPos.y<sun.y) { checkTex.x=checkPos.x*texFac.x; checkTex.y=checkPos.y*texFac.y; texel=texture2D(world,checkTex); if (texel.a!=0.0) { gl_FragColor=vec4(0.0,0.0,0.0,0.95); checkPos.y=sun.y+100000000.0; break; } checkPos.x+=delta.x*stepSize; checkPos.y+=delta.y*stepSize; } } |
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
Werbeanzeige