Michael Betke Posted March 15, 2010 Posted March 15, 2010 Is is possible with a .lua script to load and display a second UV-channel which contains a lightmap? I have an object. UV1 is my texture. UV5 are my lightmap UVs. The Lightmap is a huge texture for a bunch of objects whith baked shaodws. I now want to blend it over my UV1. Is there a way with .lua so I can use it for every level I do? Quote Pure3d Visualizations Germany - digital essences AAA 3D Model Shop specialized on nature and environments
DaDonik Posted March 15, 2010 Posted March 15, 2010 I'm afraid that is something you have to use a shader for. You can only do PaintEntity, but that needs a material and a shader that supports your lightmap. Quote (Win7 64bit) && (i7 3770K @ 3,5ghz) && (16gb DDR3 @ 1600mhz) && (Geforce660TI)
Michael Betke Posted March 15, 2010 Author Posted March 15, 2010 Thanks for your reply. In the old LE forums a guy posted this: (This is the .vert shader?!) uniform mat4 MeshMatrix; varying vec3 Normal; varying vec4 pos; varying vec2 texCoord0; varying vec2 texCoord1; #ifdef BUMPMAP varying vec3 bump_t; varying vec3 bump_b; #endif void main(void) { gl_FrontColor = gl_Color; mat3 nmat = mat3(MeshMatrix[0].xyz,MeshMatrix[1].xyz,MeshMatrix[2].xyz); Normal=nmat*gl_Normal; pos=MeshMatrix*gl_Vertex; texCoord0=gl_MultiTexCoord0.xy; texCoord1=gl_MultiTexCoord1.xy; #ifdef BUMPMAP bump_t = nmat * gl_MultiTexCoord2.xyz; bump_b = nmat * gl_MultiTexCoord3.xyz; #endif gl_Position = gl_ModelViewProjectionMatrix * pos; } And this as a .frag uniform vec3 CameraPosition; varying vec3 Normal; varying vec4 pos; varying vec2 texCoord0; varying vec2 texCoord1; #ifdef DIFFUSEMAP uniform sampler2D DIFFUSEMAP; #endif #ifdef BUMPMAP uniform sampler2D BUMPMAP; varying vec3 bump_t; varying vec3 bump_b; #endif #ifdef LIGHTMAP uniform sampler2D LIGHTMAP; #endif void main(void) { #ifdef BUMPMAP vec3 nNormal = texture2D ( BUMPMAP, texCoord0 ).rgb * 2.0 - vec3 ( 1.0 ); #else vec3 nNormal = normalize( Normal ); #endif vec3 CamVector = normalize( CameraPosition - pos.xyz ); vec3 LightVector; vec3 HalfVector; #ifdef DIFFUSEMAP vec3 color = texture2D(DIFFUSEMAP,texCoord0).rgb; #else vec3 color = vec3(1.0,1.0,1.0); #endif vec3 diff = vec3(AMBIENT); float spec = 0.0; float SHINE = 50.0; float SHINESTRENGHT = 0.2; float dist; #ifdef LIGHTMAP diff = texture2D(LIGHTMAP,texCoord1).rgb; #endif #ifdef LO1pos LightVector = normalize(LO1pos-pos.xyz); HalfVector = normalize(CamVector+LightVector); dist = length(LO1pos-pos.xyz); #ifdef BUMPMAP vec3 lt = vec3 ( dot ( LightVector, bump_t ), dot ( LightVector, bump_b ), dot ( LightVector, Normal ) ); vec3 ht = vec3 ( dot ( HalfVector, bump_t ), dot ( HalfVector, bump_b ), dot ( HalfVector, Normal ) ); #ifndef LIGHTMAP if (dist<LO1range) { diff = vec3(max ( (1.0-dist/LO1range)*dot ( nNormal, lt ), AMBIENT )); } #endif spec = pow ( max ( dot ( nNormal, ht ), 0.0 ), SHINE ); #else #ifndef LIGHTMAP if (dist<LO1range) { diff = vec3(max ( (1.0-dist/LO1range)*dot ( nNormal, LightVector ), AMBIENT )); } #endif spec = pow ( max ( dot ( nNormal, HalfVector ), 0.0 ), SHINE ); #endif #endif float shine=min(SHINESTRENGHT * spec,1.0); gl_FragColor = vec4 ( color * diff + vec3 ( shine ), 1.0 ); } Taken from this thread: http://www.leadwerks.com/forum/viewtopic.php?f=6&t=4628&p=40933&hilit=lightmap#p40933 So what are the steps I have to do? In 3dmax: rendering my lightmap and exporting it with the model In LE: -saving above shaders as .vert and .frag -doing a material using these new shaders for my lightmap textre (?) - then ?? Quote Pure3d Visualizations Germany - digital essences AAA 3D Model Shop specialized on nature and environments
Josh Posted March 16, 2010 Posted March 16, 2010 Unwrap3D can save a second texcoord set to GMF files. Quote Let's build cool stuff and have fun.
Michael Betke Posted March 16, 2010 Author Posted March 16, 2010 I think Arbuz exporter does it too? Quote Pure3d Visualizations Germany - digital essences AAA 3D Model Shop specialized on nature and environments
ArBuZ Posted March 16, 2010 Posted March 16, 2010 Yes, it does. Quote Q6600@2.4GHz - 9600GT - 4GB DDR2@800MHz - Windows7 x64 3ds max / photoshop CS3 / C++ http://www.arbuznikov.com
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.