isidisi Posted June 25, 2010 Share Posted June 25, 2010 I'm using Leadwerks Engine 2.28 It seems as if some versions ago there was a shader for cube maps. Now there's some code in mesh.vert shader, and no code in mesh.frag shader (only a uniform samplerCube LW_CUBEMAP declaration, but later this is not using in shader). But if I download some versions older, I see there was some code related to cube maps in mesh.frag shader. Was deleted by error?, is not needed to implement a cube map? What's the right way to do a cube map with current version of Leadwerks? Thanks Quote Link to comment Share on other sites More sharing options...
Masterxilo Posted June 25, 2010 Share Posted June 25, 2010 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). Quote Hurricane-Eye Entertainment - Site, blog. Link to comment Share on other sites More sharing options...
isidisi Posted June 30, 2010 Author Share Posted June 30, 2010 Thanks Masterxilo, I'll try :-D Quote Link to comment Share on other sites More sharing options...
isidisi Posted July 14, 2010 Author Share Posted July 14, 2010 Thanks Masterxilo, I'll try :-D I tried and works ok, but trying to understand the code, what mat and nmat matrix are in vertex shader? Quote Link to comment Share on other sites More sharing options...
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.