fixes mipmap issue with parsing Sampler

This commit is contained in:
Ricardo Quesada 2015-05-13 10:24:32 -07:00
parent 1007c0bfdb
commit e95de4de62
4 changed files with 16 additions and 179 deletions

View File

@ -248,7 +248,7 @@ bool Material::parseSampler(Pass* pass, Properties* textureProperties)
// valid options: NEAREST, LINEAR, NEAREST_MIPMAP_NEAREST, LINEAR_MIPMAP_NEAREST, NEAREST_MIPMAP_LINEAR, LINEAR_MIPMAP_LINEAR // valid options: NEAREST, LINEAR, NEAREST_MIPMAP_NEAREST, LINEAR_MIPMAP_NEAREST, NEAREST_MIPMAP_LINEAR, LINEAR_MIPMAP_LINEAR
const char* minFilter = getOptionalString(textureProperties, "minFilter", mipmap ? "LINEAR_MIPMAP_NEAREST" : "LINEAR"); const char* minFilter = getOptionalString(textureProperties, "minFilter", usemipmap ? "LINEAR_MIPMAP_NEAREST" : "LINEAR");
if (strcasecmp(minFilter, "NEAREST")==0) if (strcasecmp(minFilter, "NEAREST")==0)
texParams.minFilter = GL_NEAREST; texParams.minFilter = GL_NEAREST;
else if(strcasecmp(minFilter, "LINEAR")==0) else if(strcasecmp(minFilter, "LINEAR")==0)

View File

@ -199,7 +199,7 @@ void Material_3DEffects::onEnter()
auto light2 = DirectionLight::create(Vec3(-1,1,0), Color3B::GREEN); auto light2 = DirectionLight::create(Vec3(-1,1,0), Color3B::GREEN);
addChild(light2); addChild(light2);
this->schedule(CC_CALLBACK_1(Material_3DEffects::changeMaterial, this), 3, "cookie"); this->schedule(CC_CALLBACK_1(Material_3DEffects::changeMaterial, this), 1, "cookie");
_techniqueState = 0; _techniqueState = 0;
} }

View File

@ -4,42 +4,22 @@ material sample
{ {
pass 0 pass 0
{ {
renderState
{
blend = true
blendSrc = ONE
blendDst = ONE_MINUS_SRC_ALPHA
}
shader shader
{ {
defines = THIS_IS_AN_EXAMPLE 1;TOMORROW_IS_HOLIDAY 2 defines = THIS_IS_AN_EXAMPLE 1;TOMORROW_IS_HOLIDAY 2
vertexShader = Shaders/example_simple.vsh vertexShader = Shaders/example_simple.vsh
fragmentShader = Shaders/example_Blur.fsh fragmentShader = Shaders/example_Blur.fsh
blurRadius = 10 // Uniforms
blurRadius = 3
sampleNum = 5 sampleNum = 5
resolution = 100,100 resolution = 100,100
} }
sampler 0
{
path = Images/grossinis_sister1.png
wrapS = CLAMP_TO_EDGE
wrapT = CLAMP_TO_EDGE
minFilter = LINEAR
magFilter = LINEAR
mipmap = false
}
} }
} }
technique outline technique outline
{ {
pass 0 pass 0
{ {
renderState
{
blend = true
blendSrc = ONE
blendDst = ONE_MINUS_SRC_ALPHA
}
shader shader
{ {
vertexShader = Shaders/example_simple.vsh vertexShader = Shaders/example_simple.vsh
@ -48,53 +28,23 @@ material sample
u_radius = 0.01 u_radius = 0.01
u_threshold = 1.75 u_threshold = 1.75
} }
sampler 0
{
path = Images/grossinis_sister1.png
wrapS = CLAMP_TO_EDGE
wrapT = CLAMP_TO_EDGE
minFilter = LINEAR
magFilter = LINEAR
mipmap = false
}
} }
} }
technique noise { technique noise {
pass 0 pass 0
{ {
renderState
{
blend = true
blendSrc = ONE
blendDst = ONE_MINUS_SRC_ALPHA
}
shader shader
{ {
vertexShader = Shaders/example_simple.vsh vertexShader = Shaders/example_simple.vsh
fragmentShader = Shaders/example_Noisy.fsh fragmentShader = Shaders/example_Noisy.fsh
resolution = 100,100 resolution = 100,100
} }
sampler 0
{
path = Images/grossinis_sister1.png
wrapS = CLAMP_TO_EDGE
wrapT = CLAMP_TO_EDGE
minFilter = LINEAR
magFilter = LINEAR
mipmap = false
}
} }
} }
technique edge_detect technique edge_detect
{ {
pass 0 pass 0
{ {
renderState
{
blend = true
blendSrc = ONE
blendDst = ONE_MINUS_SRC_ALPHA
}
shader shader
{ {
defines = defines =
@ -102,69 +52,6 @@ material sample
fragmentShader = Shaders/example_edgeDetection.fsh fragmentShader = Shaders/example_edgeDetection.fsh
resolution = 100, 100 resolution = 100, 100
} }
sampler 0
{
path = Images/grossinis_sister1.png
wrapS = CLAMP_TO_EDGE
wrapT = CLAMP_TO_EDGE
minFilter = LINEAR
magFilter = LINEAR
mipmap = false
}
}
}
technique gray+blur
{
pass 0
{
renderState
{
blend = true
blendSrc = ONE
blendDst = ONE_MINUS_SRC_ALPHA
}
shader
{
defines = TEXTURE_REPEAT
vertexShader = Shaders/example_simple.vsh
fragmentShader = Shaders/example_Blur.fsh
blurRadius = 10
sampleNum = 5
resolution = 100, 100
}
sampler 0
{
path = Images/grossinis_sister1.png
wrapS = CLAMP_TO_EDGE
wrapT = CLAMP_TO_EDGE
minFilter = LINEAR
magFilter = LINEAR
mipmap = false
}
}
pass 1
{
renderState
{
blend = true
blendSrc = ONE_MINUS_SRC_ALPHA
blendDst = ONE_MINUS_SRC_ALPHA
}
shader
{
defines =
vertexShader = Shaders/example_simple.vsh
fragmentShader = Shaders/example_greyScale.fsh
}
sampler 0
{
path = Images/grossinis_sister1.png
wrapS = CLAMP_TO_EDGE
wrapT = CLAMP_TO_EDGE
minFilter = LINEAR
magFilter = LINEAR
mipmap = false
}
} }
} }
} }

View File

@ -4,12 +4,6 @@ material spaceship
{ {
pass 0 pass 0
{ {
renderState
{
blend = true
blendSrc = ONE
blendDst = ONE_MINUS_SRC_ALPHA
}
shader shader
{ {
vertexShader = Shaders3D/3d_position_tex.vert vertexShader = Shaders3D/3d_position_tex.vert
@ -18,11 +12,6 @@ material spaceship
sampler 0 sampler 0
{ {
path = Sprite3DTest/boss.png path = Sprite3DTest/boss.png
wrapS = CLAMP_TO_EDGE
wrapT = CLAMP_TO_EDGE
minFilter = LINEAR
magFilter = LINEAR
mipmap = false
} }
} }
} }
@ -31,12 +20,6 @@ material spaceship
{ {
pass 0 pass 0
{ {
renderState
{
blend = true
blendSrc = ONE
blendDst = ONE_MINUS_SRC_ALPHA
}
shader shader
{ {
defines = MAX_POINT_LIGHT_NUM 1;MAX_SPOT_LIGHT_NUM 1;MAX_DIRECTIONAL_LIGHT_NUM 1 defines = MAX_POINT_LIGHT_NUM 1;MAX_SPOT_LIGHT_NUM 1;MAX_DIRECTIONAL_LIGHT_NUM 1
@ -46,11 +29,6 @@ material spaceship
sampler 0 sampler 0
{ {
path = Sprite3DTest/boss.png path = Sprite3DTest/boss.png
wrapS = CLAMP_TO_EDGE
wrapT = CLAMP_TO_EDGE
minFilter = LINEAR
magFilter = LINEAR
mipmap = false
} }
} }
} }
@ -61,82 +39,54 @@ material spaceship
{ {
renderState renderState
{ {
blend = true cullFace = true
blendSrc = ONE cullFaceSide = BACK
blendDst = ONE_MINUS_SRC_ALPHA depthTest = false
cullFace = true
cullFaceSide = FRONT
depthTest = true
} }
shader shader
{ {
vertexShader = Shaders3D/OutLine.vert vertexShader = Shaders3D/OutLine.vert
fragmentShader = Shaders3D/OutLine.frag fragmentShader = Shaders3D/OutLine.frag
OutLineColor = 1,0,0 // Uniforms
OutlineWidth = 0.01 OutLineColor = 1,1,0
OutlineWidth = 0.04
} }
sampler 0 sampler 0
{ {
path = Sprite3DTest/boss.png path = Sprite3DTest/boss.png
wrapS = CLAMP_TO_EDGE
wrapT = CLAMP_TO_EDGE
minFilter = LINEAR
magFilter = LINEAR
mipmap = false
} }
} }
pass outline thick pass outline thick
{ {
renderState renderState
{ {
blend = true cullFace = true
blendSrc = ONE cullFaceSide = FRONT
blendDst = ONE_MINUS_SRC_ALPHA depthTest = true
cullFace = true
cullFaceSide = FRONT
depthTest = true
} }
shader shader
{ {
vertexShader = Shaders3D/OutLine.vert vertexShader = Shaders3D/OutLine.vert
fragmentShader = Shaders3D/OutLine.frag fragmentShader = Shaders3D/OutLine.frag
OutLineColor = 0,0,1 // Uniforms
OutlineWidth = 0.02 OutLineColor = 0,0,1
OutlineWidth = 0.02
} }
sampler 0 sampler 0
{ {
path = Sprite3DTest/boss.png path = Sprite3DTest/boss.png
wrapS = CLAMP_TO_EDGE
wrapT = CLAMP_TO_EDGE
minFilter = LINEAR
magFilter = LINEAR
mipmap = false
} }
} }
pass 1 pass 1
{ {
renderState
{
blend = true
blendSrc = ONE
blendDst = ONE_MINUS_SRC_ALPHA
}
shader shader
{ {
vertexShader = Shaders3D/3d_position_tex.vert vertexShader = Shaders3D/3d_position_tex.vert
fragmentShader = Shaders3D/3d_color_tex.frag fragmentShader = Shaders3D/3d_color_tex.frag
} }
sampler 0 sampler 0
{ {
path = Sprite3DTest/boss.png path = Sprite3DTest/boss.png
wrapS = CLAMP_TO_EDGE
wrapT = CLAMP_TO_EDGE
minFilter = LINEAR
magFilter = LINEAR
mipmap = false
} }
} }
} }