Jump to content

rd-rend2 (old thread)


eezstreet

Recommended Posts

  • 5 weeks later...
Posted

is the rend2 available in the builds? or do i have to compile it? does the rend2 have support for widescreen resolution of 1366 x 768?

Posted

It's not :P haven't touched it since whenever my last update was. I always update this thread if I'm working on it in some worthwhile way, so that's one way of knowing if progress is happening or not.

Tempust85 likes this
Posted

is the rend2 available in the builds? or do i have to compile it? does the rend2 have support for widescreen resolution of 1366 x 768?

You must build it yourself or have one provided by someone who can build it.

 

Not sure what you are on about with widescreen resolution support?  You've been able to use any resolution since ever... Without any special renderer.

 

Open console and enter these lines:

r_mode -1
r_customWidth 1366
r_customHeight 768
vid_restart

If you are using vanilla JAMP there is a bug which does not let you host a local server at custom resolutions though.  But you can still join servers.  And this bug is fixed in OpenJK.

  • 3 weeks later...
Posted

I'm not really sure tbh what will motivate me to work on this again. It's not just this; I'm having trouble motivating myself do work on anything for an extended amount of time. I think I need to take a break away from any sort of coding where someone's relying on me. I really do want to finish it, but when I start the coding it all just fizzles out :(

 

And I make more than 100 dollars in a single day's work, so that's not really worth it for me :P

Posted

Shame, it's more useful in SP to the community. I only wish I could help somehow.

I'm sure that's how you all feel of course but in reality its not going to be very easy to support the SP community.  SP still has way too much shit different, hence why supporting just MP for now was the correct route to take.

 

SP is also less modifiable in a generic sense than MP is which is another reason to steer towards MP first.  (A lot of things are more attached between server/client, and the game dll and engine/renderer).

Posted

I'm not really sure tbh what will motivate me to work on this again. It's not just this; I'm having trouble motivating myself do work on anything for an extended amount of time. I think I need to take a break away from any sort of coding where someone's relying on me. I really do want to finish it, but when I start the coding it all just fizzles out :(

 

And I make more than 100 dollars in a single day's work, so that's not really worth it for me :P

Perhaps just choose one or two days where you spend no more than a couple of hours (a session) coding... then set it aside the rest of the week and do things you find enjoyable-- that bring you joy.

Mandalorian, Tempust85 and Stoiss like this
  • 4 weeks later...
Posted

I can no longer run rend2:

 

 

 

OpenJK-MP: v1.0.1.0 win_msvc-x86 Oct 21 2014
----- FS_Startup -----
Current search path:
C:\Users\Jon\Documents\My Games\OpenJK\base
C:\Users\Jon\Desktop\OpenJK Rend2\base\zzzz_rend2_zbrush_test.pk3 (12 files)
C:\Users\Jon\Desktop\OpenJK Rend2\base\zzzz_rend2_menu.pk3 (6 files)
C:\Users\Jon\Desktop\OpenJK Rend2\base\zzzz_rend2_map.pk3 (16 files)
C:\Users\Jon\Desktop\OpenJK Rend2\base\mapextras.pk3 (52 files)
C:\Users\Jon\Desktop\OpenJK Rend2\base\assets3.pk3 (16 files)
C:\Users\Jon\Desktop\OpenJK Rend2\base\assets2.pk3 (62 files)
C:\Users\Jon\Desktop\OpenJK Rend2\base\assets1.pk3 (8320 files)
C:\Users\Jon\Desktop\OpenJK Rend2\base\assets0.pk3 (15346 files)
C:\Users\Jon\Desktop\OpenJK Rend2\base

----------------------
23830 files in pk3 files
execing mpdefault.cfg
execing openjk.cfg
couldn't exec autoexec.cfg

------- Input Initialization -------
Skipping check for DirectInput
Joystick is not active.
------------------------------------
----- Initializing Renderer ----
Trying to load "rd-rend2_x86.dll" from "C:\Users\Jon\Desktop\OpenJK Rend2"...
QKEY found.
----- R_Init -----
...initializing QGL
succeeded
...setting mode 7: 1152 864 W
...created window@324,84 (1168x902)
Initializing OpenGL driver
...getting DC: succeeded
...GLW_ChoosePFD( 32, 24, 8 )
...133 PFDs found
...hardware acceleration found
...PIXELFORMAT 9 selected
...creating GL context: succeeded
...making context current: succeeded
Initializing OpenGL extensions
...GL_S3_s3tc available
...GL_EXT_texture_compression_s3tc available
...no tc preference specified
.....using GL_EXT_texture_compression_s3tc
...using GL_EXT_texture_env_add
...GL_EXT_texture_filter_anisotropic available
...using GL_EXT_texture_filter_anisotropic
...using GL_EXT_texture_edge_clamp
...using WGL_EXT_swap_control
...using GL_ARB_multitexture
...using GL_EXT_compiled_vertex_array
...using GLSL version 4.40 NVIDIA via Cg compiler
...using GL_EXT_texture_compression_latc
...ignoring GL_ARB_texture_compression_bptc
...using GL_ARB_texture_storage
------- FBO_Init -------
------- GLSL_InitGPUShaders -------
------- R_InitVBOs -------
Initializing Shaders
#version 150 core
#define attribute in
#define varying out
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifndef deformGen_t
#define deformGen_t
#define DEFORM_NONE 0
#define DEFORM_WAVE 1
#define DEFORM_NORMALS 2
#define DEFORM_BULGE 3
#define DEFORM_MOVE 4
#define DEFORM_PROJECTION_SHADOW 5
#define WF_NONE 0
#define WF_SIN 1
#define WF_SQUARE 2
#define WF_TRIANGLE 3
#define WF_SAWTOOTH 4
#define WF_INVERSE_SAWTOOTH 5
#endif
#ifndef tcGen_t
#define tcGen_t
#define TCGEN_LIGHTMAP 2
#define TCGEN_LIGHTMAP1 3
#define TCGEN_LIGHTMAP2 4
#define TCGEN_LIGHTMAP3 5
#define TCGEN_TEXTURE 6
#define TCGEN_ENVIRONMENT_MAPPED 7
#define TCGEN_FOG 8
#define TCGEN_VECTOR 9
#endif
#ifndef colorGen_t
#define colorGen_t
#define CGEN_LIGHTING_DIFFUSE 11
#endif
#ifndef alphaGen_t
#define alphaGen_t
#define AGEN_LIGHTING_SPECULAR 6
#define AGEN_PORTAL 8
#endif
#ifndef texenv_t
#define texenv_t
#define TEXENV_MODULATE 8448
#define TEXENV_ADD 260
#define TEXENV_REPLACE 7681
#endif
#ifndef r_FBufScale
#define r_FBufScale 
ec2(0.000868, 0.001157)
#endif
#define USE_DEFORM_VERTEXES
#define RGBM_LIGHTMAP
#line 0
attribute vec3 attr_Position;
attribute vec3 attr_Normal;
#if defined(USE_VERTEX_ANIMATION)
attribute vec3 attr_Position2;
attribute vec3 attr_Normal2;
#elif defined(USE_SKELETAL_ANIMATION)
attribute vec4 attr_BoneIndexes;
attribute vec4 attr_BoneWeights;
#endif
attribute vec4 attr_Color;
attribute vec2 attr_TexCoord0;
#if defined(USE_LIGHTMAP) || defined(USE_TCGEN)
attribute vec2 attr_TexCoord1;
#endif
uniform vec4   u_DiffuseTexMatrix;
uniform vec4   u_DiffuseTexOffTurb;
#if defined(USE_TCGEN) || defined(USE_RGBAGEN)
uniform vec3   u_LocalViewOrigin;
#endif
#if defined(USE_TCGEN)
uniform int    u_TCGen0;
uniform vec3   u_TCGen0Vector0;
uniform vec3   u_TCGen0Vector1;
#endif
#if defined(USE_FOG)
uniform vec4   u_FogDistance;
uniform vec4   u_FogDepth;
uniform float  u_FogEyeT;
uniform vec4   u_FogColorMask;
#endif
#if defined(USE_DEFORM_VERTEXES)
uniform int    u_DeformType;
uniform int    u_DeformFunc;
uniform float  u
DeformParams[7];
uniform float  u_Time;
#endif
uniform mat4   u_ModelViewProjectionMatrix;
uniform vec4   u_BaseColor;
uniform vec4   u_VertColor;
#if defined(USE_RGBAGEN)
uniform int    u_ColorGen;
uniform int    u_AlphaGen;
uniform vec3   u_AmbientLight;
uniform vec3   u_DirectedLight;
uniform vec3   u_ModelLightDir;
uniform float  u_PortalRange;
#endif
#if defined(USE_VERTEX_ANIMATION)
uniform float  u_VertexLerp;
#elif defined(USE_SKELETAL_ANIMATION)
uniform mat4   u_BoneMatrices[20];
#endif
varying vec2   var_DiffuseTex;
#if defined(USE_LIGHTMAP)
varying vec2   var_LightTex;
#endif
varying vec4   var_Color;
#if defined(USE_DEFORM_VERTEXES)
float GetNoiseValue( float x, float y, float z, float t )
{
	// Variation on the 'one-liner random function'.
	// Not sure if this is still 'correctly' random
	return fract( sin( dot(
		vec4( x, y, z, t ),
		vec4( 12.9898, 78.233, 12.9898, 78.233 )
	)) * 43758.5453 );
}
float CalculateDeformScale( in int func, in float time, in float phase, in float frequency )
{
	flo
t value = phase + time * frequency;
	switch ( func )
	{
		case WF_SIN:
			return sin(value * 2.0 * M_PI);
		case WF_SQUARE:
			return sign(0.5 - fract(value));
		case WF_TRIANGLE:
			return abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0;
		case WF_SAWTOOTH:
			return fract(value);
		case WF_INVERSE_SAWTOOTH:
			return 1.0 - fract(value);
		default:
			return 0.0;
	}
}
vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st)
{
	switch ( u_DeformType )
	{
		default:
		{
			return pos;
		}
		case DEFORM_BULGE:
		{
			float bulgeHeight = u_DeformParams[1]; // amplitude
			float bulgeWidth = u_DeformParams[2]; // phase
			float bulgeSpeed = u_DeformParams[3]; // frequency
			float scale = CalculateDeformScale( WF_SIN, u_Time, bulgeWidth * st.x, bulgeSpeed );
			return pos + normal * scale * bulgeHeight;
		}
		case DEFORM_WAVE:
		{
			float base = u_DeformParams[0];
			float amplitude = u_DeformParams[1];
			float phase = u_DeformParams[2];
			float frequency = u_DeformParams[3];
			float spread = u_Defor
Params[4];
			float offset = dot( pos.xyz, vec3( spread ) );
			float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase + offset, frequency );
			return pos + normal * (base + scale * amplitude);
		}
		case DEFORM_MOVE:
		{
			float base = u_DeformParams[0];
			float amplitude = u_DeformParams[1];
			float phase = u_DeformParams[2];
			float frequency = u_DeformParams[3];
			vec3 direction = vec3( u_DeformParams[4], u_DeformParams[5], u_DeformParams[6] );
			float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase, frequency );
			return pos + direction * (base + scale * amplitude);
		}
		case DEFORM_PROJECTION_SHADOW:
		{
			vec3 ground = vec3(
				u_DeformParams[0],
				u_DeformParams[1],
				u_DeformParams[2]);
			float groundDist = u_DeformParams[3];
			vec3 lightDir = vec3(
				u_DeformParams[4],
				u_DeformParams[5],
				u_DeformParams[6]);
			float d = dot( lightDir, ground );
			lightDir = lightDir * max( 0.5 - d, 0.0 ) + ground;
			d = 1.0 / dot( lightDir, ground );
			vec3 lightPos 
 lightDir * d;
			return pos - lightPos * dot( pos, ground ) + groundDist;
		}
	}
}
vec3 DeformNormal( in const vec3 position, in const vec3 normal )
{
	if ( u_DeformType != DEFORM_NORMALS )
	{
		return normal;
	}
	float amplitude = u_DeformParams[1];
	float frequency = u_DeformParams[3];
	vec3 outNormal = normal;
	const float scale = 0.98;
	
	outNormal.x += amplitude * GetNoiseValue(
		position.x * scale,
		position.y * scale,
		position.z * scale,
		u_Time * frequency );
	outNormal.y += amplitude * GetNoiseValue(
		100.0 * position.x * scale,
		position.y * scale,
		position.z * scale,
		u_Time * frequency );
	outNormal.z += amplitude * GetNoiseValue(
		200.0 * position.x * scale,
		position.y * scale,
		position.z * scale,
		u_Time * frequency );
	return outNormal;
}
#endif
#if defined(USE_TCGEN)
vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 TCGenVector1)
{
	vec2 tex = attr_TexCoord0.st;
	if (TCGen >= TCGEN_LIGHTMAP && TCGen <= TCGEN_LIGHTMAP3)
	{
		tex = attr_TexCoord1.
t;
	}
	else if (TCGen == TCGEN_ENVIRONMENT_MAPPED)
	{
		vec3 viewer = normalize(u_LocalViewOrigin - position);
		vec2 ref = reflect(viewer, normal).yz;
		tex.s = ref.x * -0.5 + 0.5;
		tex.t = ref.y *  0.5 + 0.5;
	}
	else if (TCGen == TCGEN_VECTOR)
	{
		tex = vec2(dot(position, TCGenVector0), dot(position, TCGenVector1));
	}
	
	return tex;
}
#endif
#if defined(USE_TCMOD)
vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb)
{
	float amplitude = offTurb.z;
	float phase = offTurb.w * 2.0 * M_PI;
	vec2 st2;
	st2.x = st.x * texMatrix.x + (st.y * texMatrix.z + offTurb.x);
	st2.y = st.x * texMatrix.y + (st.y * texMatrix.w + offTurb.y);
	vec2 offsetPos = vec2(position.x + position.z, position.y);
	
	vec2 texOffset = sin(offsetPos * (2.0 * M_PI / 1024.0) + vec2(phase));
	
	return st2 + texOffset * amplitude;	
}
#endif
#if defined(USE_RGBAGEN)
vec4 CalcColor(vec3 position, vec3 normal)
{
	vec4 color = u_VertColor * attr_Color + u_BaseColor;
	
	if (u_ColorGen == CGEN_LIGHTING_DIFFUSE)
	{
		float incom
ng = clamp(dot(normal, u_ModelLightDir), 0.0, 1.0);
		color.rgb = clamp(u_DirectedLight * incoming + u_AmbientLight, 0.0, 1.0);
	}
	
	vec3 viewer = u_LocalViewOrigin - position;
	if (u_AlphaGen == AGEN_LIGHTING_SPECULAR)
	{
		vec3 lightDir = normalize(vec3(-960.0, 1980.0, 96.0) - position);
		vec3 reflected = -reflect(lightDir, normal);
		
		color.a = clamp(dot(reflected, normalize(viewer)), 0.0, 1.0);
		color.a *= color.a;
		color.a *= color.a;
	}
	else if (u_AlphaGen == AGEN_PORTAL)
	{
		color.a = clamp(length(viewer) / u_PortalRange, 0.0, 1.0);
	}
	
	return color;
}
#endif
#if defined(USE_FOG)
float CalcFog(vec3 position)
{
	float s = dot(vec4(position, 1.0), u_FogDistance) * 8.0;
	float t = dot(vec4(position, 1.0), u_FogDepth);
	float eyeOutside = float(u_FogEyeT < 0.0);
	float fogged = float(t < eyeOutside);
	t += 1e-6;
	t *= fogged / (t - u_FogEyeT * eyeOutside);
	return s * t;
}
#endif
void main()
{
#if defined(USE_VERTEX_ANIMATION)
	vec3 position  = mix(attr_Position, attr_Position2, u_VertexLerp);
	
ec3 normal    = mix(attr_Normal,   attr_Normal2,   u_VertexLerp);
	normal = normalize(normal - vec3(0.5));
#elif defined(USE_SKELETAL_ANIMATION)
	vec4 position4 = vec4(0.0);
	vec4 normal4 = vec4(0.0);
	vec4 originalPosition = vec4(attr_Position, 1.0);
	vec4 originalNormal = vec4(attr_Normal - vec3 (0.5), 0.0);
	for (int i = 0; i < 4; i++)
	{
		int boneIndex = int(attr_BoneIndexes[i]);
		position4 += (u_BoneMatrices[boneIndex] * originalPosition) * attr_BoneWeights[i];
		normal4 += (u_BoneMatrices[boneIndex] * originalNormal) * attr_BoneWeights[i];
	}
	vec3 position = position4.xyz;
	vec3 normal = normalize(normal4.xyz);
#else
	vec3 position  = attr_Position;
	vec3 normal    = attr_Normal * 2.0 - vec3(1.0);
#endif
#if defined(USE_DEFORM_VERTEXES)
	position = DeformPosition(position, normal, attr_TexCoord0.st);
	normal = DeformNormal( position, normal );
#endif
	gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0);
#if defined(USE_TCGEN)
	vec2 tex = GenTexCoords(u_TCGen0, position, normal, u_TCGen0V
ctor0, u_TCGen0Vector1);
#else
	vec2 tex = attr_TexCoord0.st;
#endif
#if defined(USE_TCMOD)
	var_DiffuseTex = ModTexCoords(tex, position, u_DiffuseTexMatrix, u_DiffuseTexOffTurb);
#else
    var_DiffuseTex = tex;
#endif
#if defined(USE_LIGHTMAP)
	var_LightTex = attr_TexCoord1.st;
#endif
#if defined(USE_RGBAGEN)
	var_Color = CalcColor(position, normal);
#else
	var_Color = u_VertColor * attr_Color + u_BaseColor;
#endif
#if defined(USE_FOG)
	var_Color *= vec4(1.0) - u_FogColorMask * sqrt(clamp(CalcFog(position), 0.0, 1.0));
#endif
}

compile log:
0(143) : error C7538: OpenGL does not allow 'const' after 'inout'
0(143) : error C7538: OpenGL does not allow 'const' after 'inout'

*******************
ERROR: Couldn't compile shader
********************
RE_Shutdown( 0 )
----- R_Init -----
------- FBO_Init -------
R_CheckFBO: (_msaaResolve) Framebuffer incomplete attachment
R_CheckFBO: (*glowScaled0) Framebuffer incomplete attachment
R_CheckFBO: (*glowScaled1) Framebuffer incomplete attachment
R_CheckFBO: (*glowScaled2) Framebuffer incomplete attachment
R_CheckFBO: (*glowScaled3) Framebuffer incomplete attachment
R_CheckFBO: (_sunshadowmap) Framebuffer incomplete attachment
R_CheckFBO: (_sunshadowmap) Framebuffer incomplete attachment
R_CheckFBO: (_sunshadowmap) Framebuffer incomplete attachment
R_CheckFBO: (_screenshadow) Framebuffer incomplete attachment
R_CheckFBO: (_texturescratch0) Framebuffer incomplete attachment
R_CheckFBO: (_texturescratch1) Framebuffer incomplete attachment
R_CheckFBO: (_calclevels) Framebuffer incomplete attachment
R_CheckFBO: (_targetlevels) Framebuffer incomplete attachment
R_CheckFBO: (_quarter0) Framebuffer incomplete attachment
R_CheckFBO: (_quarter1) Framebuffer incomplete attachment
------- GLSL_InitGPUShaders -------
------- R_InitVBOs -------
Initializing Shaders
#version 150 core
#define attribute in
#define varying out
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifndef deformGen_t
#define deformGen_t
#define DEFORM_NONE 0
#define DEFORM_WAVE 1
#define DEFORM_NORMALS 2
#define DEFORM_BULGE 3
#define DEFORM_MOVE 4
#define DEFORM_PROJECTION_SHADOW 5
#define WF_NONE 0
#define WF_SIN 1
#define WF_SQUARE 2
#define WF_TRIANGLE 3
#define WF_SAWTOOTH 4
#define WF_INVERSE_SAWTOOTH 5
#endif
#ifndef tcGen_t
#define tcGen_t
#define TCGEN_LIGHTMAP 2
#define TCGEN_LIGHTMAP1 3
#define TCGEN_LIGHTMAP2 4
#define TCGEN_LIGHTMAP3 5
#define TCGEN_TEXTURE 6
#define TCGEN_ENVIRONMENT_MAPPED 7
#define TCGEN_FOG 8
#define TCGEN_VECTOR 9
#endif
#ifndef colorGen_t
#define colorGen_t
#define CGEN_LIGHTING_DIFFUSE 11
#endif
#ifndef alphaGen_t
#define alphaGen_t
#define AGEN_LIGHTING_SPECULAR 6
#define AGEN_PORTAL 8
#endif
#ifndef texenv_t
#define texenv_t
#define TEXENV_MODULATE 8448
#define TEXENV_ADD 260
#define TEXENV_REPLACE 7681
#endif
#ifndef r_FBufScale
#define r_FBufScale 
ec2(0.000868, 0.001157)
#endif
#define USE_DEFORM_VERTEXES
#define RGBM_LIGHTMAP
#line 0
attribute vec3 attr_Position;
attribute vec3 attr_Normal;
#if defined(USE_VERTEX_ANIMATION)
attribute vec3 attr_Position2;
attribute vec3 attr_Normal2;
#elif defined(USE_SKELETAL_ANIMATION)
attribute vec4 attr_BoneIndexes;
attribute vec4 attr_BoneWeights;
#endif
attribute vec4 attr_Color;
attribute vec2 attr_TexCoord0;
#if defined(USE_LIGHTMAP) || defined(USE_TCGEN)
attribute vec2 attr_TexCoord1;
#endif
uniform vec4   u_DiffuseTexMatrix;
uniform vec4   u_DiffuseTexOffTurb;
#if defined(USE_TCGEN) || defined(USE_RGBAGEN)
uniform vec3   u_LocalViewOrigin;
#endif
#if defined(USE_TCGEN)
uniform int    u_TCGen0;
uniform vec3   u_TCGen0Vector0;
uniform vec3   u_TCGen0Vector1;
#endif
#if defined(USE_FOG)
uniform vec4   u_FogDistance;
uniform vec4   u_FogDepth;
uniform float  u_FogEyeT;
uniform vec4   u_FogColorMask;
#endif
#if defined(USE_DEFORM_VERTEXES)
uniform int    u_DeformType;
uniform int    u_DeformFunc;
uniform float  u
DeformParams[7];
uniform float  u_Time;
#endif
uniform mat4   u_ModelViewProjectionMatrix;
uniform vec4   u_BaseColor;
uniform vec4   u_VertColor;
#if defined(USE_RGBAGEN)
uniform int    u_ColorGen;
uniform int    u_AlphaGen;
uniform vec3   u_AmbientLight;
uniform vec3   u_DirectedLight;
uniform vec3   u_ModelLightDir;
uniform float  u_PortalRange;
#endif
#if defined(USE_VERTEX_ANIMATION)
uniform float  u_VertexLerp;
#elif defined(USE_SKELETAL_ANIMATION)
uniform mat4   u_BoneMatrices[20];
#endif
varying vec2   var_DiffuseTex;
#if defined(USE_LIGHTMAP)
varying vec2   var_LightTex;
#endif
varying vec4   var_Color;
#if defined(USE_DEFORM_VERTEXES)
float GetNoiseValue( float x, float y, float z, float t )
{
	// Variation on the 'one-liner random function'.
	// Not sure if this is still 'correctly' random
	return fract( sin( dot(
		vec4( x, y, z, t ),
		vec4( 12.9898, 78.233, 12.9898, 78.233 )
	)) * 43758.5453 );
}
float CalculateDeformScale( in int func, in float time, in float phase, in float frequency )
{
	flo
t value = phase + time * frequency;
	switch ( func )
	{
		case WF_SIN:
			return sin(value * 2.0 * M_PI);
		case WF_SQUARE:
			return sign(0.5 - fract(value));
		case WF_TRIANGLE:
			return abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0;
		case WF_SAWTOOTH:
			return fract(value);
		case WF_INVERSE_SAWTOOTH:
			return 1.0 - fract(value);
		default:
			return 0.0;
	}
}
vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st)
{
	switch ( u_DeformType )
	{
		default:
		{
			return pos;
		}
		case DEFORM_BULGE:
		{
			float bulgeHeight = u_DeformParams[1]; // amplitude
			float bulgeWidth = u_DeformParams[2]; // phase
			float bulgeSpeed = u_DeformParams[3]; // frequency
			float scale = CalculateDeformScale( WF_SIN, u_Time, bulgeWidth * st.x, bulgeSpeed );
			return pos + normal * scale * bulgeHeight;
		}
		case DEFORM_WAVE:
		{
			float base = u_DeformParams[0];
			float amplitude = u_DeformParams[1];
			float phase = u_DeformParams[2];
			float frequency = u_DeformParams[3];
			float spread = u_Defor
Params[4];
			float offset = dot( pos.xyz, vec3( spread ) );
			float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase + offset, frequency );
			return pos + normal * (base + scale * amplitude);
		}
		case DEFORM_MOVE:
		{
			float base = u_DeformParams[0];
			float amplitude = u_DeformParams[1];
			float phase = u_DeformParams[2];
			float frequency = u_DeformParams[3];
			vec3 direction = vec3( u_DeformParams[4], u_DeformParams[5], u_DeformParams[6] );
			float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase, frequency );
			return pos + direction * (base + scale * amplitude);
		}
		case DEFORM_PROJECTION_SHADOW:
		{
			vec3 ground = vec3(
				u_DeformParams[0],
				u_DeformParams[1],
				u_DeformParams[2]);
			float groundDist = u_DeformParams[3];
			vec3 lightDir = vec3(
				u_DeformParams[4],
				u_DeformParams[5],
				u_DeformParams[6]);
			float d = dot( lightDir, ground );
			lightDir = lightDir * max( 0.5 - d, 0.0 ) + ground;
			d = 1.0 / dot( lightDir, ground );
			vec3 lightPos 
 lightDir * d;
			return pos - lightPos * dot( pos, ground ) + groundDist;
		}
	}
}
vec3 DeformNormal( in const vec3 position, in const vec3 normal )
{
	if ( u_DeformType != DEFORM_NORMALS )
	{
		return normal;
	}
	float amplitude = u_DeformParams[1];
	float frequency = u_DeformParams[3];
	vec3 outNormal = normal;
	const float scale = 0.98;
	
	outNormal.x += amplitude * GetNoiseValue(
		position.x * scale,
		position.y * scale,
		position.z * scale,
		u_Time * frequency );
	outNormal.y += amplitude * GetNoiseValue(
		100.0 * position.x * scale,
		position.y * scale,
		position.z * scale,
		u_Time * frequency );
	outNormal.z += amplitude * GetNoiseValue(
		200.0 * position.x * scale,
		position.y * scale,
		position.z * scale,
		u_Time * frequency );
	return outNormal;
}
#endif
#if defined(USE_TCGEN)
vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 TCGenVector1)
{
	vec2 tex = attr_TexCoord0.st;
	if (TCGen >= TCGEN_LIGHTMAP && TCGen <= TCGEN_LIGHTMAP3)
	{
		tex = attr_TexCoord1.
t;
	}
	else if (TCGen == TCGEN_ENVIRONMENT_MAPPED)
	{
		vec3 viewer = normalize(u_LocalViewOrigin - position);
		vec2 ref = reflect(viewer, normal).yz;
		tex.s = ref.x * -0.5 + 0.5;
		tex.t = ref.y *  0.5 + 0.5;
	}
	else if (TCGen == TCGEN_VECTOR)
	{
		tex = vec2(dot(position, TCGenVector0), dot(position, TCGenVector1));
	}
	
	return tex;
}
#endif
#if defined(USE_TCMOD)
vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb)
{
	float amplitude = offTurb.z;
	float phase = offTurb.w * 2.0 * M_PI;
	vec2 st2;
	st2.x = st.x * texMatrix.x + (st.y * texMatrix.z + offTurb.x);
	st2.y = st.x * texMatrix.y + (st.y * texMatrix.w + offTurb.y);
	vec2 offsetPos = vec2(position.x + position.z, position.y);
	
	vec2 texOffset = sin(offsetPos * (2.0 * M_PI / 1024.0) + vec2(phase));
	
	return st2 + texOffset * amplitude;	
}
#endif
#if defined(USE_RGBAGEN)
vec4 CalcColor(vec3 position, vec3 normal)
{
	vec4 color = u_VertColor * attr_Color + u_BaseColor;
	
	if (u_ColorGen == CGEN_LIGHTING_DIFFUSE)
	{
		float incom
ng = clamp(dot(normal, u_ModelLightDir), 0.0, 1.0);
		color.rgb = clamp(u_DirectedLight * incoming + u_AmbientLight, 0.0, 1.0);
	}
	
	vec3 viewer = u_LocalViewOrigin - position;
	if (u_AlphaGen == AGEN_LIGHTING_SPECULAR)
	{
		vec3 lightDir = normalize(vec3(-960.0, 1980.0, 96.0) - position);
		vec3 reflected = -reflect(lightDir, normal);
		
		color.a = clamp(dot(reflected, normalize(viewer)), 0.0, 1.0);
		color.a *= color.a;
		color.a *= color.a;
	}
	else if (u_AlphaGen == AGEN_PORTAL)
	{
		color.a = clamp(length(viewer) / u_PortalRange, 0.0, 1.0);
	}
	
	return color;
}
#endif
#if defined(USE_FOG)
float CalcFog(vec3 position)
{
	float s = dot(vec4(position, 1.0), u_FogDistance) * 8.0;
	float t = dot(vec4(position, 1.0), u_FogDepth);
	float eyeOutside = float(u_FogEyeT < 0.0);
	float fogged = float(t < eyeOutside);
	t += 1e-6;
	t *= fogged / (t - u_FogEyeT * eyeOutside);
	return s * t;
}
#endif
void main()
{
#if defined(USE_VERTEX_ANIMATION)
	vec3 position  = mix(attr_Position, attr_Position2, u_VertexLerp);
	
ec3 normal    = mix(attr_Normal,   attr_Normal2,   u_VertexLerp);
	normal = normalize(normal - vec3(0.5));
#elif defined(USE_SKELETAL_ANIMATION)
	vec4 position4 = vec4(0.0);
	vec4 normal4 = vec4(0.0);
	vec4 originalPosition = vec4(attr_Position, 1.0);
	vec4 originalNormal = vec4(attr_Normal - vec3 (0.5), 0.0);
	for (int i = 0; i < 4; i++)
	{
		int boneIndex = int(attr_BoneIndexes[i]);
		position4 += (u_BoneMatrices[boneIndex] * originalPosition) * attr_BoneWeights[i];
		normal4 += (u_BoneMatrices[boneIndex] * originalNormal) * attr_BoneWeights[i];
	}
	vec3 position = position4.xyz;
	vec3 normal = normalize(normal4.xyz);
#else
	vec3 position  = attr_Position;
	vec3 normal    = attr_Normal * 2.0 - vec3(1.0);
#endif
#if defined(USE_DEFORM_VERTEXES)
	position = DeformPosition(position, normal, attr_TexCoord0.st);
	normal = DeformNormal( position, normal );
#endif
	gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0);
#if defined(USE_TCGEN)
	vec2 tex = GenTexCoords(u_TCGen0, position, normal, u_TCGen0V
ctor0, u_TCGen0Vector1);
#else
	vec2 tex = attr_TexCoord0.st;
#endif
#if defined(USE_TCMOD)
	var_DiffuseTex = ModTexCoords(tex, position, u_DiffuseTexMatrix, u_DiffuseTexOffTurb);
#else
    var_DiffuseTex = tex;
#endif
#if defined(USE_LIGHTMAP)
	var_LightTex = attr_TexCoord1.st;
#endif
#if defined(USE_RGBAGEN)
	var_Color = CalcColor(position, normal);
#else
	var_Color = u_VertColor * attr_Color + u_BaseColor;
#endif
#if defined(USE_FOG)
	var_Color *= vec4(1.0) - u_FogColorMask * sqrt(clamp(CalcFog(position), 0.0, 1.0));
#endif
}

compile log:
0(143) : error C7538: OpenGL does not allow 'const' after 'inout'
0(143) : error C7538: OpenGL does not allow 'const' after 'inout'

recursive error after: Couldn't compile shader

 

 

Guest
This topic is now closed to further replies.
×
×
  • Create New...